tech-userlevel archive

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

Re: Results of || and && operators in /bin/sh $(( )) evaluation



    Date:        Mon, 14 Mar 2016 00:09:22 +0300
    From:        Aleksej Saushev <asau%inbox.ru@localhost>
    Message-ID:  <87twka9jb1.fsf%inbox.ru@localhost>

  | Are "&&" and "||" arithmetic expressions or ones of more general kind?

The ones in question are arithmetic (inside an $(( )) expansion.)

The "command line" || and && operate exactly as you described, and no-one
is planning to (or ever would) change that.

In my initial message, what was "odd" was not lazy eval of && and ||,
that's been around forever, but that it would be implemented that way
in ash (and remain in NetBSD's sh) in an environment when it is supposed
to be copying C expressions (so much so that the posix shell definition of
expressions in $(( )) just says "the same as this..." and points at the C
std, "except for no need for" ++, --, sizeof (and C statements, if/while/switch
etc).

kre



Home | Main Index | Thread Index | Old Index