Current-Users archive

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

Re: Proposed updated sh(1) relating to $(( ))



    Date:        Mon, 20 Mar 2017 10:19:59 -0400
    From:        matthew sporleder <msporleder%gmail.com@localhost>
    Message-ID:  <CAHKF-AvGQ-Nf04xBNovUEzFdKtbwdDqgJ8+w02AobrU8rrQSwA%mail.gmail.com@localhost>

  | 
  | I know it's redundant but because man pages tend to be searched rather
  | than read, I would like to see this paragraph:
  |      The expression is treated as if it were in double quotes, except that a
  |      double quote inside the expression is not treated specially.  The shell
  |      expands all tokens in the expression for parameter expansion, command
  |      substitution, and quote removal.

That's unchanged from what was there before, and while I wasn't the one
who added it, I recognise that text, it's more or less lifted unchanged from
the posix spec (where "is not treated specially") actually has a very
specific meaning.

  | Read like this:
  |      In Arithmetic Expansion the expression is treated as if it were
  | in double quotes, except that a

That can certainly be done.

  | I didn't know this:
  | Shell variables may be referenced by name inside an arithmetic
  | expression, without needing a ``$'' sign.

Been like that for ages (its's part of the basic spec), though before if
the var was null/unset it generated an error rather than being treated as 0
which meant it didn't really matter which form you used.   Now there's
an advantage to omitting the $ ...

Note that "variables" are in strict shell lexicography, things like $? $!
etc are not variables, they're special parameters (as the args are
positional parameters) and those don't get magically expanded, a reference
to ! in an arith expression remains the unary (boolean) not operator, not
the pid of the last background process started, and 1 is just 1, not the
first arg to the script or function...

kre



Home | Main Index | Thread Index | Old Index