tech-userlevel archive

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

Re: Weirdness in /bin/sh of 8.0



    Date:        Tue, 14 Aug 2018 20:52:49 +0100
    From:        David Brownlee <abs%netbsd.org@localhost>
    Message-ID:  <CAGN_6pZ9fjNNNtxGShFZkxJSB7X3JVg3gLGMweuezKMJ=TDb=g%mail.gmail.com@localhost>

  | If you had any other comments on obvious things you noticed which
  | could be transitioned from "technically works" to "correct" I would be
  | all ears :-p

Another is that the test (aka '[') command produces undefined results
with more than 4 args (the closing ']' does not count when the command
is '[') - I counted the args of one invocation and found 11 ... (and there are
lots with more than 4).   The test "language" is really badly designed,
in that operands and operators are indistinguishable, other than by
guesswork ... so the order in which to try iguessing s defined for everything
up 
to 4 args (well, some cases of 4 args) and undefined beyond that.

Use sh primitives { }, && ||  instead of test ( ) -a -o (and usually ! as well),
and stick to using test with 1, 2, or 3 args (the defined 4 arg cases provide
nothing useful that cannot be done other ways.)

Since I have a copy now, I will look more at it sometime, and send you
(probably off-list) comments if I see more.

kre



Home | Main Index | Thread Index | Old Index