Hello list,
i have a strange problem in bash with the test command.
Here is my simple bash script 'tst' that checks wether the first char of
an argument is a slash.
If the first char of the argument is a special char like '(' then it
works if there is one expression,
but not with multiple expressions.
Test script 'tst':
#!/bin/bash
set -x
h="$1"
if [ "${h:0:1}" = "/" ]; then echo slash; fi
if [ "true" = "true" -a "${h:0:1}" = "/" ]; then echo slash; fi
Results OK:
# ./tst /path
+ h=/path
+ '[' / = / ']'
+ echo slash
slash
+ '[' true = true -a / = / ']'
+ echo slash
slash
Results wrong:
# ./tst '(nopath)'
+ h='(nopath)'
+ '[' '(' = / ']'
+ '[' true = true -a '(' = / ']'
./tst: Zeile 7: [: `)' erwartet, / gefunden.
Seems to be a bug?
Kind regards
Helmut
--
Helmut Koeberle Tel. : +49-(0)7541-585-1005
Senior System Engineer Fax : +49-(0)7541-585-2005
BYTEC GmbH mailto:[email protected]
Hermann-Metzger-Str.7 http://www.bytec.eu
88045 Friedrichshafen
Geschäftsführer Dipl.-Ing. Matthias Bodry
Amtsgericht Ulm HRB 630959