On Fri, Dec 20, 2002 at 12:48:01PM +0100, jipe wrote:
> On Fri, 20 Dec 2002 18:18:10 +0900
> "ath1410" <[EMAIL PROTECTED]> wrote:
> > 
> > $test -z (there is no space after -z, no argment) returns 0 which means 'test 
>command thinks no argment equals to the
> > empty string'.
> > 
> > However, $test -n (no space after, no argment) return 0 which
> > means 'test command in this case thinks no argment equals to
> > NO-empty string'.
> > 
> > When no argment is given, why test command thinks differenly
> > depending on the options -z and -n. 
> > 
oh, didn't saw that. ok. this' kinda twisted to understand. 
first of all, in the '-z' example u r giving a string, 
which means 'test' has something to test for. depending on
the argument, it returns its exit code.

the '-n' example u showed has NO argument, which means 'test'
has nothing to test for. it returns zero.

i understand ur confusion. it is common in programms to return 
a >0 value if a needed argument is missing. but this is 
not a programm, it's a shell builtin. end you do not got the
exit code from the command explizitly, but from that what
happend for the shell (namely bash, 4example).

so what happens for the shell? a 'strace test -n' reveals
here many secrets ;). the shell takes the command, validates
it, than takes the option, validates it. than nothing more is
to do. no more 'commands' r available to the shell. now here
plays strace. as u may see at the very end, it makes a close of
a library it opened befor to get ur locale. the close is 
successful, end THIS returns your exit (0).

clear now?

hope didn't confused u more, hehe.


> 
> this page can help you:
> http://tldp.org/LDP/abs/html/testconstructs.html
nice site, but doesnt explain he's problem. at least i
didn't found an explanation there.

have phun ;)
miLosh

-- 
DONT ATTACK IRAQ !!!

this message was sent by:
+------------------------------+
|.::|[ The pleXus Network ]|::.|
+------------------------------+

Attachment: msg63097/pgp00000.pgp
Description: PGP signature

Reply via email to