[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
the '-n' conditional
From: |
Per Fransson |
Subject: |
the '-n' conditional |
Date: |
Sun, 03 Jun 2001 04:18:56 +0200 |
If this is the wrong group for this question can you please tell me who
to ask?
Isn't
[-n string]
and
[string]
supposed to evaluate to exactly the same thing?
When I run the following script:
#!/bin/sh
if [ -n $1 ]
then
echo Foo
fi
# end of script
it echoes "Foo" regardless of whether there's a first parameter or not.
#!/bin/sh
if [ $1 ]
then
echo Foo
fi
# end of script
on the other hand, only echoes "Foo" if the script is presented with a
parameter.
Why is this?
Thanx in advance.
/Per Fransson
- the '-n' conditional,
Per Fransson <=