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

Bug#473019: debian-policy: clarification needed for "local" builtin exception for /bin/sh



On Sat, 2008-07-05 at 13:31:20 -0700, Russ Allbery wrote:
> Clint Adams <schizo@debian.org> 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

Seconded.

regards,
guillem

Attachment: signature.asc
Description: Digital signature


Reply to: