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

Re: bashism question



Lars Wirzenius wrote:
To clarify: is "local foo=bar" policy-compliant or not?

(If not, *sigh*.)

To the best of my knowledge, no, it's not compliant. The relevant section reads:

<snip>
      * `local' to create a scoped variable must be supported; however,
         `local' may or may not preserve the variable value from an outer
         scope and may or may not support arguments more complex than
         simple variables.  Only uses such as:
              fname () {
                  local a
                  a=''
                  # ... use a ...
              }
         must be supported.
<snip>

As "foo=bar" is an argument "more complex than simple variables" and the example explicitly shows the use of local to declare the variable followed by assignment to it, my reading of policy is that "local foo=bar" is not permitted.

Adam
Reply to: