[comp.unix.questions] return code fun!

mark@hsi86.hsi.com (Mark Sicignano) (02/13/91)

Let me just show you...

$ false
$ echo $?
1

$ false ; echo $?
1

$ false | echo $?
0

Ok... so the $? must be from the previously executed command, which 
is the previous echo, which returned 0?

So, this should print 1?

$ false
$ false | echo $?
0

wrong...

What is this 0 return status coming from?  The pipe?  When a pipe
is created, does the shell set $? depending on whether or not the 
pipe was successful?

Don't tell me that "false | echo $?" has no useful purpose.  I know
that!!!!  I'm just trying to use it as a simple example!

-mark
-- 
Mark Sicignano                                  ...!uunet!hsi!mark
3M Health Information Systems                   mark@hsi.com