two very minor items

two very minor items…

  1. on the Linux releases, when you make a sh script you do not have a full path specification for the location of the module launcher. so it works fine when clicked directly in its spot but if you make a shortcut to it from another directory the launch fails because it is not the current directory.

I find I have to change…
cd dirname "$0" && java -classpath lib/Vengine.jar VASSAL.launch.ModuleManager “$@”
to…
cd dirname "$0" && java -classpath /home/john-murphy/VASSAL-3.1.0-beta5/lib/Vengine.jar VASSAL.launch.ModuleManager “$@”

now… maybe this is something in my setup related to classpath but I am using the default setup out of the package manager’s java box.

also, a fix could be difficult because you do not know the location where it will be installed, and even worse where the shortcut could be run from.

(and it is not a difficult problem for the, what, five or ten?, vassal linux users to figure out and edit the script post-extraction)

  1. module editor… which I know is a low priority… some (most really) windows can grow quite large if you hog-wild with command keys for options, and there is no mechanism built into the windows to permit them to become scrollable. so at some point they push the keys to close them or edit them off the screen.

I am not sure maybe I had already reported this but I do not think so. it is in a grey area between bug and rfe.

and another minor one…

in the module editor when you cut and paste a piece (or probably most things?) then when you go to paste it again, there is no longer anything to paste. I believe the norm would be for you to be able to continue pasting the object just like if you had copied it rather than cut it?

IrishBouzouki wrote:

But is is the current directory…

…that’s what the first ‘cd’ part does - it changes directory to
wherever the script actually lives, so that the ‘lib/Vengine.jar’
relative path is correct.

The only thing I can think of why this doesn’t work for you is that you
don’t have ‘.’ (the current directory) on your classpath. If you try
changing the script to ‘./lib/Vengine.jar’, does that work instead?

I have a launcher on my desktop (/home/tim/Desktop) pointing to an
installed script in /usr/local/VASSAL, and it works just fine without
any changes at all.

Cheers,
Tim.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

*********** REPLY SEPARATOR ***********

I’m not sure I understand what you are talking about. Could you please list some specific examples where this is a problem.

Thx,
B.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

You can recreate this by building a restrict commands traits with 35 or so commands. But if you need a particular example I think the following shows where I notices it.

If you go back to one of the older (before the last week or so) versions of Strategos there is rather lengthy list of commands in the restrict commands trait for a combat unit. If you keep adding commands to the list it will push the bottom buttons past the end of the screen and you can no longer add/edit. Sure you can workaround it. But I also expect if you have a DP with 30 or 40 key commands (why, who knows, but is that an artifical limit you want to impose) it would be the same issue.

Essentially most items like this where lists of commands or properties are being added (okay, my opinion) be made scrollable, such as when you add players to player side definitions or to restricted access… those give you scrollable boxes.

I will try this later tonite, do not have my linux machine up now. But from memory I think you may be correct re my classpath, at least when I was using a manual install of java. But I would have thought when I installed java from the package manager it would have done that?

Tried it, did not work. Something else may be the issue here.
Here is the original line…

cd `dirname "$0"` && java -classpath lib/Vengine.jar VASSAL.launch.ModuleManager "$@"

Here is the edited line

cd `dirname "$0"` && java -classpath ./lib/Vengine.jar VASSAL.launch.ModuleManager "$@"

which does not work… giving the following in my xsession errors

Exception in thread "main" java.lang.NoClassDefFoundError: VASSAL/launch/ModuleManager Caused by: java.lang.ClassNotFoundException: VASSAL.launch.ModuleManager at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:323) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:268) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336) Could not find the main class: VASSAL.launch.ModuleManager. Program will exit.
but… the following line does work…

cd `dirname "$0"` && java -classpath /home/john-murphy/VASSAL-3.1.0-beta6/lib/Vengine.jar VASSAL.launch.ModuleManager "$@"

which is hard-coded to where the module launcher java code is located on my machine.

I think since this is using a -classpath command the classpath MUST be being set, and the problem lies in that the cd is NOT going to the location of the script but remaining on the desktop where the icon is located that has the shortcut to the VASSAL.sh file.
what is the following actually supposed to do and how?

cd `dirname "$0"`

On Dec 1, 2008, at 5:24 AM, IrishBouzouki wrote:

I wonder if it would be useful, for debugging purposes, to insert
“pwd” (print the current working directory) after the “cd” command.
That would at least give some additional information:

cd dirname "$0" && pwd && java -classpath lib/Vengine.jar
VASSAL.launch.ModuleManager “$@”

The only thing that comes to mind is that the method of creating the
shortcut may be one that causes the shell to execute in the
environment (directory) where the shortcut is located rather than in
the environment where the original is located.

So, a couple of questions that I have that may lead to a solution:

  1. How was the alias/shortcut/link created?
  2. Is it possible that the vassal.sh file was copied instead of linked?
  3. What happens when you change the script as shown. What directory
    gets printed?

Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Yes, that is what I believe is supposed to happen when you run a shortcut in xubuntu. However, if the cd command actually changes the directory to the location of the sh script rather than the shortcut that should work provided the cd command is actually doing that.

  1. The shortcut was created under xubuntu by right-clicking on VASSAL.sh in the Thunar (?) GUI for the folder where it was extracted, then selecting “send to…” and “desktop(shortcut)”. Or something like that, if not the exact wording (it was the other machine).
  2. No not possible. When I open the shortcut with mousepad it opens the original VASSAL.sh file, and if I make a change and then go open the original VASSAL.sh I see the change there also.
  3. Where is this pwd is going to be printed? This is all happening with GUI’s, only printout shows up on errors. <<>>… I manually try it from the command line from the desktop directory. I will try that later tonite or in the morning and let you know.

Here is the terminal spew showing that the cd command is failing to change the working directory. Of course, running this like this from a command line, so one can see the output, means that the arguments on which the cd command is relying are probably not present. Game for any ideas how to do this so it can be captured.

I would like to know the theory behind how cd dirname "$0" is supposed to take a shell script located in directory A and , when executed from directory B, change the directory to directory A. I do not know what the shell script argument mechanism is supposed to be that this is relying on. If I had a pointer to how it was supposed to work I could do some troubleshooting.

john-murphy@john-murphy-laptop:~/Desktop$ cd `dirname "$0"` && pwd && java -classpath lib/Vengine.jar VASSAL.launch.ModuleManager "$@" /home/john-murphy/Desktop Exception in thread "main" java.lang.NoClassDefFoundError: VASSAL/launch ModuleManager Caused by: java.lang.ClassNotFoundException: VASSAL.launch.ModuleManager at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:323) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:268) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336) Could not find the main class: VASSAL.launch.ModuleManager. Program will exit.

Thus spake “IrishBouzouki”:

First, note that ‘.’ refers to the current directory, and that relative
paths are relative to the current directory. Therefore, there is no
difference between ‘./lib/Vengine.jar’ and ‘lib/Vengine.jar’ for the
purposes of specifying a path.

Here’s how to read this:

The backticks () cause whatever they enclose to be run in a subshell, after which the output of that is substituted in place of what was enclosed in backticks. That is, 'cd dirname “$0”`’ is equivalent to ‘cd FOO’, where
FOO is whatever you get when you run ‘dirname “$0”’.

In the bash shell, $0 is a variable which holds the path of the script which
is currently running, or the name of your shell if no script is running. You
can see this yourself by typing ‘echo $0’ in your shell. In the context of
this script, $0 will be the script’s path. In your case, this will be
something like ‘/home/john-murphy/VASSAL-3.1.0-beta6/VASSAL.sh’.

The dirname command takes a path as an arugment, strips off everything from
the last ‘/’ to the end, and returns as output what’s left. So, in your
case it should be getting ‘/home/john-murphy/VASSAL-3.1.0-beta6/VASSAL.sh’
as input, and returning ‘/home/john-murphy/VASSAL-3.1.0-beta6’ as output.

Finally, the cd command changes the current directory to be whatever it
is given as an arugment. In your case, it should be getting
‘/home/john-murphy/VASSAL-3.1.0-beta6’ as an argument, and so will make
that the current directory.

Therefore, when the second half of the command in VASSAL.sh is run, the
current directory will be the directory which VASSAL.sh is in. If you
haven’t moved VASSAL.sh, then the directory which VASSAL.sh is in will
also contain the lib directory, and in that will be Vengine.jar, which
is why the classpath is given as ‘lib/Vengine.jar’.

Therefore: If you want to run VASSAL, (1) you should not need to edit
VASSAL.sh, and (2) you should not move VASSAL.sh relative to the lib
directory.

If you want to launch VASSAL from your desktop, you should have your
shortcut run VASSAL.sh. This is not the same as having your shortcut be
a copy of VASSAL.sh. The principle here is the same as with any other
program, say, Firefox. If you want a shortcut to Firefox on your desktop,
you would not copy or move /usr/bin/firfox to your desktop; rather, you
would make a shortcut which runs /usr/bin/firefox.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “IrishBouzouki”:

This is your problem.

Let me demonstrate why:

I created a shell script called foo.sh, with the following contents:

#!/bin/bash

echo $0

Then, I made a symlink to it, called bar.sh:

[uckelman@scylla ~]$ ln -s foo.sh bar.sh

Here’s what happened when I ran the script as itself and the script from the
link:

[uckelman@scylla ~]$ ./foo.sh
./foo.sh
[uckelman@scylla ~]$ ./bar.sh
./bar.sh

What this shows is that the value of $0 depends on where the script believes
it is. When you run a script from a symbolic link, it will be have as though
it really is where the link is.

What you need to do is make sure that what’s on your desktop is NOT a symlink.

One way you could do that is via another shell script, which you put on your
desktop:

#!/bin/bash
/path/to/VASSAL.sh

Or, you could do it in whatever way your desktop environment does it. What
window manager are you using?


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

I guess we could canonicalize the path in $0, if this is going to be such a
problem.

Put:

cd $( dirname $( readlink -f “$0” ))

instead of:

cd dirname "$0"

However, now I’m not certain that $() is valid in sh scripts—it might be
a bashism, but I can’t test that myself, as on my system /bin/sh is a symlink
to /bin/bash.

the managers xubuntu 8.10 ships with…
window manager is xfce 4.4.2 (which i know is the most up to date xfce)
file manager is Thunar 0.9.0

Yes this works on my system (which I can not guarantee does not have the same sh-bash link as yours - ah there it is… mine says in the properties it links to dash not bash - is that “died again shell”? hehehe). Sorry to be a pain… I can certainly live with editing the sh file. Just want to avoid a new vassal user running ubuntu hitting the same issue and having to figure it out, or giving up before trying to solve it. But as said if it is not a real easy quick fix it should not be a real high-priority item given all the other things in work at the moment.

Thus spake “IrishBouzouki”:

I tried XFCE on my system in the office just now, so I could see what you’re
seeing. It appears that what you see on your desktop just is the contents
of the ~/Desktop directory (‘~’ is an abbreviation for whatever your home
directory is).

What you’ll ultimately want to do is have a symbolic link to VASSAL.sh
on your desktop, but that won’t work with the current VASSAL.sh. This
isn’t a bug per se, but I’d like to change VASSAL.sh so that it doesn’t
behave unexpectedly when linked to.

So, here’s what I propose be in VASSAL.sh instead of what we have now:

#!/bin/bash

cd $(dirname $(readlink -f “$0”)) && java -classpath lib/Vengine.jar VASSAL.launch.ModuleManager “$@”

This would make us dependent on bash (due to the subshell capture syntax) but
are there really any machines out there which don’t have bash these days?


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “IrishBouzouki”:

Debian Almquist SHell.

This is something which is important to get resolved, and involves a change
to a single line of one file, so it’s no problem. I agree that it could be
confusing for people unfamiliar with UNIX.

Aftrer looking at the sh standard, I think $() is not a bashism, so we don’t
end up dependent on bash after all.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “IrishBouzouki”:

I’ve commited a fix for this to trunk@4595.

Try svn4596:

nomic.net/~uckelman/tmp/vass … eneric.zip


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

On Tue, December 2, 2008 1:08 pm, IrishBouzouki wrote:

Regular Ubuntu users who haven’t been messing with anything will get a
Gnome desktop, where the usual method of “add a launcher” (to either the
desktop or one of the application menus) will give something that does the
Right Thing. (i.e. run the script from its original location, not
symlinked to the Desktop folder).

I don’t know xfce to say if it has a similar mechnaism, or if creating
symlinks from ~/Desktop is the expected way to work there.

Cheers,
Tim.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

On Dec 2, 2008, at 5:30 AM, Joel Uckelman wrote:

I just checked this on Darwin (Mac OS X Unix), using sh, and the $()
works.

The problem is that Darwin uses the BSD readlink rather than the Gnu
readlink and they behave differently:

  • The “-f” flag is not supported. The only flag available is “-n” to
    suppress a trailing newline.
  • If the argument given to readlink is NOT a symbolic link, then
    NOTHING is printed. This is serious.

Now, granted, one doesn’t need to be able to run the Unix stuff on Mac
OS, but could it be a problem for other Unix systems and the
particular command set they have available?


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)