[GRASS-dev] Variable quoting problem (and solution)

Hi,

in 6.4 (and later) there is still a quoting problem. Together with Helmut,
I reduced the existing problems to this one (example v.in.geonames):

GRASS 6.4> v.in.geonames input=C:\dl\AT\AT.txt output=vgeotest6
+ '[' -z '/C/Program Files/GRASS 6.4.SVN' ']'
+ '[' input=C:dlATAT.txt '!=' @ARGS_PARSED@ ']'
++ basename /C/Program Files/GRASS 6.4.SVN/scripts/v.in.geonames
basename: extra operand `6.4.SVN/scripts/v.in.geonames'
Try `basename --help' for more information.
+ CMDLINE=
+ for arg in '"$@"'
+ CMDLINE=' "input=C:dlATAT.txt"'
+ for arg in '"$@"'
+ CMDLINE=' "input=C:dlATAT.txt" "output=vgeotest6"'
+ export CMDLINE
+ exec g.parser '/C/Program Files/GRASS 6.4.SVN/scripts/v.in.geonames'
input=C:dlATAT.txt output=vgeotest6
basename: extra operand `6.4.SVN/scripts/v.in.geonames'
Try `basename --help' for more information.
FEHLER: File 'C:dlATAT.txt' not found
GRASS 6.4>

Patching the script like this:
--- scripts/v.in.geonames/v.in.geonames (revision 45246)
+++ scripts/v.in.geonames/v.in.geonames (working copy)
@@ -49,7 +49,7 @@

# save command line
if [ "$1" != "@ARGS_PARSED@" ] ; then
- CMDLINE="`basename $0`"
+ CMDLINE=`basename "$0"`
     for arg in "$@" ; do
         CMDLINE="$CMDLINE \"$arg\""
     done
@@ -57,7 +57,7 @@
     exec g.parser "$0" "$@"
fi

-PROG="`basename $0`"
+PROG=`basename "$0"`

we now get

GRASS 6.4> v.in.geonames input="C:\dl\AT\AT.txt" output=vgeotest9
+ '[' -z '/C/Program Files/GRASS 6.4.SVN' ']'
+ '[' 'input=C:\dl\AT\AT.txt' '!=' @ARGS_PARSED@ ']'
++ basename '/C/Program Files/GRASS 6.4.SVN/scripts/v.in.geonames'
+ CMDLINE=v.in.geonames
+ for arg in '"$@"'
+ CMDLINE='v.in.geonames "input=C:\dl\AT\AT.txt"'
+ for arg in '"$@"'
+ CMDLINE='v.in.geonames "input=C:\dl\AT\AT.txt" "output=vgeotest9"'
+ export CMDLINE
+ exec g.parser '/C/Program Files/GRASS 6.4.SVN/scripts/v.in.geonames'
'input=C:\dl\AT\AT.txt' output=vgeotest9
...

which looks fine. So I'll change all scripts accordingly.

Markus

On Sun, Jan 30, 2011 at 1:26 PM, Markus Neteler <neteler@osgeo.org> wrote:

Hi,

in 6.4 (and later) there is still a quoting problem. Together with Helmut,
I reduced the existing problems to this one (example v.in.geonames):

GRASS 6.4> v.in.geonames input=C:\dl\AT\AT.txt output=vgeotest6
+ '[' -z '/C/Program Files/GRASS 6.4.SVN' ']'
+ '[' input=C:dlATAT.txt '!=' @ARGS_PARSED@ ']'
++ basename /C/Program Files/GRASS 6.4.SVN/scripts/v.in.geonames
basename: extra operand `6.4.SVN/scripts/v.in.geonames'
Try `basename --help' for more information.
+ CMDLINE=
+ for arg in '"$@"'
+ CMDLINE=' "input=C:dlATAT.txt"'
+ for arg in '"$@"'
+ CMDLINE=' "input=C:dlATAT.txt" "output=vgeotest6"'
+ export CMDLINE
+ exec g.parser '/C/Program Files/GRASS 6.4.SVN/scripts/v.in.geonames'
input=C:dlATAT.txt output=vgeotest6
basename: extra operand `6.4.SVN/scripts/v.in.geonames'
Try `basename --help' for more information.
FEHLER: File 'C:dlATAT.txt' not found
GRASS 6.4>

Patching the script like this:
--- scripts/v.in.geonames/v.in.geonames (revision 45246)
+++ scripts/v.in.geonames/v.in.geonames (working copy)
@@ -49,7 +49,7 @@

# save command line
if [ "$1" != "@ARGS_PARSED@" ] ; then
- CMDLINE="`basename $0`"
+ CMDLINE=`basename "$0"`
for arg in "$@" ; do
CMDLINE="$CMDLINE \"$arg\""
done
@@ -57,7 +57,7 @@
exec g.parser "$0" "$@"
fi

-PROG="`basename $0`"
+PROG=`basename "$0"`

we now get

GRASS 6.4> v.in.geonames input="C:\dl\AT\AT.txt" output=vgeotest9
+ '[' -z '/C/Program Files/GRASS 6.4.SVN' ']'
+ '[' 'input=C:\dl\AT\AT.txt' '!=' @ARGS_PARSED@ ']'
++ basename '/C/Program Files/GRASS 6.4.SVN/scripts/v.in.geonames'
+ CMDLINE=v.in.geonames
+ for arg in '"$@"'
+ CMDLINE='v.in.geonames "input=C:\dl\AT\AT.txt"'
+ for arg in '"$@"'
+ CMDLINE='v.in.geonames "input=C:\dl\AT\AT.txt" "output=vgeotest9"'
+ export CMDLINE
+ exec g.parser '/C/Program Files/GRASS 6.4.SVN/scripts/v.in.geonames'
'input=C:\dl\AT\AT.txt' output=vgeotest9
...

which looks fine. So I'll change all scripts accordingly.

Done in r45247 (6.4) and r45248 (6.5).

Markus

On Sun, Jan 30, 2011 at 2:14 PM, Markus Neteler <neteler@osgeo.org> wrote:

On Sun, Jan 30, 2011 at 1:26 PM, Markus Neteler <neteler@osgeo.org> wrote:

...

Done in r45247 (6.4) and r45248 (6.5).

Now the wxGUI is finally generated properly on Windows (will be valid also for
a series of other scripts) in case that the installation path contains
white space.

A wxGUI problem remains (received from Helmut), autogenerated GUI
command:

v.in.geonames --verbose input=C:\dl\AT\AT.txt output=vingeowxgui
ERROR: File 'C:dlATAT.txt' not found
(Sun Jan 30 17:31:15 2011) Command finished (1 sec)

While it now works on command line (when quoting the input path/file, otherwise
not), it still fails in the GUI.
Any chance to protect the backslashes in the GUI environment?

Markus