You are here > Les forums > PlayOnLinux > New Command Line Parameter Issue in v2.0.6 sv ru pl es fr

Forums

New Command Line Parameter Issue in v2.0.6

New topic  - Reply
Author Replies
hasi Wednesday 23 January 2008 at 14:30 - [Quote]
Membre

Membre
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.playonlinux.com/topic-995-Passing_command_line_arguments_to_Apps_AGAIN.html and http://www.playonlinux.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:

Console:

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

Console:

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 Wednesday 23 January 2008 at 14:44 - [Quote]
Membre

Membre
I did some research and found that the command line parameters are handled inside

Console:

/usr/share/playonlinux/lib/main

I kind of understand what's happening after looking at the following section where the things are done:

Console:

	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

Console:

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

Console:

        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 Tuesday 29 January 2008 at 2:48 - [Quote]
Membre

Membre
OK, it looks like it was addressed in 2.0.7.
--hasi.
Il n'y a rien à voir ici