Forums

New Command Line Parameter Issue in v2.0.6

Auteur Réponses
hasi Mercredi 23 Janvier 2008 à 14:30
hasiAnonymous

I had previously raised the issue that command line parameters were incorrectly passed from POL to wine: I found that there was a leading space which caused some problems with a few programs. (see my postings at http://www.playonmac.com/topic-995-Passing_command_line_arguments_to_Apps_AGAIN.html and http://www.playonmac.com/topic-989-Passing_command_line_arguments_to_Apps.html).

This was fixed in 2.0.6 (thanks, Tinou!). However, I found a new problem:
When I do not give another command line argument except the script name, for example:
playonlinux --run "Word 2003"
the first parameter ($1) as seen inside the script "Word 2003" will be "Word 2003", which is probably not the desired action.
When I give an additional argument to playonlinux, for example
playonlinux --run "Word 2003" "C:\asdf.doc"
the first argument as seen inside the script "Word 2003" will be "C:\asdf.doc", as expected. This I believe that something is wrong with the handling of command line parameters inside POL.
hasi Mercredi 23 Janvier 2008 à 14:44
hasiAnonymous

I did some research and found that the command line parameters are handled inside
/usr/share/playonlinux/lib/main
I kind of understand what's happening after looking at the following section where the things are done:
     if [ "$1" = "--run" ]
     then
          #Arg contient tout apres l'option --run
          #Supporte le lancement de jeu avec option POL >> 1.7.5
          Arg=$(echo $@ | cut -b7-)
          Arg=${Arg//"$2 "/""}
          lancer "$2" "$Arg"
          exit 0
     fi

The problem is the parameter replacement
Arg=${Arg//"$2 "/""}, where $2 and an additional space are replaced by /"". The problem is that if $2 is the only parameter, there is no space, and nothing is replaced! Therefore the script name is transmitted twice: in $2 and in $Arg. This is probably not the desired behavior.
I replaced this code by
if [ "$1" = "--run" ]
then
#App is the name of the script to be called,
#$@" contains the rest of the parameters to be given to the script
#Supporte le lancement de jeu avec option POL >> 1.7.5
App=$2
shift
shift
lancer "$App" "$@"
exit 0
fi

I believe using "shift" twice is a better way to drop the first two command line parameters, "--run", and (following my example above), "Word 2003". Can someone please check this, I am not exactly a bash expert, but it works fine for me.
--hasi
hasi Mardi 29 Janvier 2008 à 2:48
hasiAnonymous

OK, it looks like it was addressed in 2.0.7.
--hasi.

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmcayonlinux.com