Not sure this is correct. The ] is parsed by the shell but only if it
surrounded by whitespace. This is why the -n option reports an error,
since -n suppresses command execution.
I suspect the behaviour is required by posix or at least historical
precedent.
jon.
On 12/02/2009, at 7:04, p...@po.cwru.edu (Paul Jarc) wrote:
Ronny Standtke <ronny.stand...@fhnw.ch> wrote:
The "-n" option not seem to work. Example with a little stupid
nonsense
script:
-----------
ro...@ronny-desktop:/tmp$ cat test.sh
#!/bin/sh
if [ $blah == "test"]
This sort of error can't be caught by -n, because it's part of a
specific command, not the shell grammar. Checking for ] is done when
the [ command is executed. Since -n disables execution of all
commands, [ won't have a chance to check for a matching ].
Another strange thing: The man page of bash does only implicitly
mention
the "-n" option in the description of the "-D" option: "This
implies the
-n option; no commands will be executed."
It's documented under the "set" builtin.
paul