Hi,
Got an annoying shell script bug. I'm using GNU bash, version 3.1.17(1)-release. Here's a testcase.sh shell script:
#!/bin/bash -v myfiles="/home/samwise/Desktop/file\ with\ spaces.txt /tmp/otherfile.txt" echo binary --usethese $myfiles binary --usethese $myfiles
Relevant output to console:
$ ./testcase.sh #!/bin/bash -v myfiles="/home/samwise/Desktop/file\ with\ spaces.txt /tmp/otherfile.txt" echo binary --usethese $myfiles binary --usethese /home/samwise/Desktop/file\ with\ spaces.txt /tmp/otherfile.txt binary --usethese $myfiles $
I want to call an external binary with a parameter made of filenames which may contain spaces.
If I run the output of the echo statement above (4th line of output) manually by cutting and pasting into the console, the scanner works fine.
However, it always fails if the same command is manually called with quotes around the parameter value:
WORKS: binary --usethis /home/samwise/Desktop/file\ with\ spaces.txt /tmp/otherfile.txt
DOESN'T WORK: binary --usethis "/home/samwise/Desktop/file\ with\ spaces.txt /tmp/otherfile.txt"
Now, despite me *not* putting in quotation marks in the shell script, it appears that the call on the third line is being interpreted as though I have used them ... and so the call fails.
Anyone got any suggestions?
Peter.