George Herson <gherson@snet.net> wrote:
> Chet Ramey wrote:
>>>How can i use set -n to check scripts? It fails with a script argument.
>>>
>> `bash -n scriptname'
>
> Has the same problem as when I run w/o an argument, as i've said
> twice before.
What problem is that?
> [root@geodollar /root]# cat > /tmp/tmpscript
> echo "hello"
> echobad
> [root@geodollar /root]# bash -c "set -n /tmp/tmpscript" # line 2
This sets the -n flag, and then sets $1 to "/tmp/tmpscript". If you
want to set the -n flag, and then source the script, do this:
bash -c 'set -n; . /tmp/tmpscript'
> tmpscript has a syntax error so why didn't I get any output from line 2?
It's not a syntax error, it's just a nonexistent command. But you
didn't get an error message because you didn't tell bash to run the
script.
paul