Clint Adams <[EMAIL PROTECTED]> writes:

> I observe that
>
> a) POSIX specifies the behavior of 'export' and 'readonly'
> b) Implementation of 'local' is often very similar to 'export' and 'readonly'
>    and in the absence of a standardized 'local', it makes sense to
>    specify a similar form.
> c) 'export' and 'readonly' both take multiple variables as arguments,
>    assignments, and the -p switch for printing
> d) the Bourne-type shells in Debian support multiple arguments to 'local'
> e) the Bourne-type shells in Debian (except for posh) support variable
>    assignments with 'local'
> f) some of the Bourne-type shells in Debian produce output (which is not
>    necessarily useful) in response to 'local -p', and some produce an
>    error
> g) bash disallows use of 'local' outside of a shell function
>
> I suggest that Policy be amended to require that
>
> local a b c=delta e
>
> scope variables a, b, c, and e as local, and assign the
> string "delta" to the local c.

Here is a proposed patch that implements Clint's suggestion.  Seconds?

diff --git a/policy.sgml b/policy.sgml
index c9bd84f..2bc0d93 100644
--- a/policy.sgml
+++ b/policy.sgml
@@ -7040,18 +7040,19 @@ strip --strip-unneeded <var>your-lib</var>
              support <tt>-a</tt> and <tt>-o</tt> as binary logical
              operators.</item>
            <item><tt>local</tt> to create a scoped variable must be
-             supported; however, <tt>local</tt> 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:
+             supported, including listing multiple variables in a single
+             local command and assigning a value to a variable at the
+             same time as localizing it.  <tt>local</tt> may or
+             may not preserve the variable value from an outer scope if
+             no assignment is present.  Uses such as:
 <example compact>
 fname () {
-    local a
-    a=''
-    # ... use a ...
+    local a b c=delta d
+    # ... use a, b, c, d ...
 }
 </example>
-              must be supported.
+             must be supported and must set the value of <tt>c</tt> to
+             <tt>delta</tt>.
             </item>
          </list>
          If a shell script requires non-SUSv3 features from the shell

-- 
Russ Allbery ([EMAIL PROTECTED])               <http://www.eyrie.org/~eagle/>



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to