Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #12109
| From | Bytec GmbH - Helmut Koeberle <helmut.koeberle@bytec.de> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Strange Problem with 'test' or '[' |
| Date | 2015-12-23 11:26 +0100 |
| Organization | Bytec GmbH |
| Message-ID | <mailman.443.1450878758.843.bug-bash@gnu.org> (permalink) |
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:helmut.koeberle@bytec.eu
Hermann-Metzger-Str.7 http://www.bytec.eu
88045 Friedrichshafen
Geschäftsführer Dipl.-Ing. Matthias Bodry
Amtsgericht Ulm HRB 630959
Back to gnu.bash.bug | Previous | Next | Find similar
Strange Problem with 'test' or '[' Bytec GmbH - Helmut Koeberle <helmut.koeberle@bytec.de> - 2015-12-23 11:26 +0100
csiph-web