tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Next steps for /bin/sh



   Date: Mon, 29 Feb 2016 12:45:03 +0700
   From: Robert Elz <kre%munnari.OZ.AU@localhost>

       Date:        Sun, 28 Feb 2016 17:11:17 -0500
       From:        "James K. Lowden" <jklowden%schemamania.org@localhost>
       Message-ID:  <20160228171117.a160d8ea72909ecdae77857f%schemamania.org@localhost>

     | IMO, in the presence of -e, "false && false" should terminate
     | execution, just as "false && true" should.  The entire compound
     | statement is false because the first one is.  

   No, it shouldn't. [...]

   If it had been that simple, it would be easy, but that doesn't do what
   anyone wants if the script is something like

           if [ -z "$1" ]; then
                   # whatever
           fi
           # more stuff here

   as if the test fails ($1 is not empty) then the test ('[') command
   exits with non-zero status, then the 'more stuff' would never be done.

I think all that James meant was that when executing `false && false'
or `false && true' as a top-level command, that whole `&&' term should
return nonzero -- and hence cause the script to fail as a top-level
command -- because the first subterm, `false', returns nonzero.

Of course, if it weren't in a top-level command, e.g. if it were in
the condition of an `if', then it would only cause the alternative
branch of the `if' to be taken, &c.


Home | Main Index | Thread Index | Old Index