[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



Thanks for the quick response, Russ.

On Thu 2008-03-27 16:16:31 -0400, Russ Allbery wrote:

> The intention when I originally wrote the text was to not allow declaring
> multiple variables with one local line, since at the time I was told that
> some shells didn't support this.
>
> I think your first patch is therefore correct and intend to apply it
> unless someone tells me that my understanding of shellology is incorrect.

fwiw, bash, dash, zsh, and busybox's sh all allow multiple variables
to be locally scoped with a single declaration, though i recognize
that's not an exhaustive list:

[0 dkg@squeak ~]$ PS1='$? $0$ '
0 bash$ c () { local a b; a=foo; b=bar; echo c: $a $b; } ; c ; echo x: $a $b
c: foo bar
x:
0 bash$ dash
0 dash$ c () { local a b; a=foo; b=bar; echo c: $a $b; } ; c ; echo x: $a $b
c: foo bar
x:
0 dash$ exit
0 bash$ zsh
$? $0$ c () { local a b; a=foo; b=bar; echo c: $a $b; } ; c ; echo x: $a $b
c: foo bar
x:
$? $0$ exit
0 bash$ busybox sh


BusyBox v1.1.3 (Debian 1:1.1.3-5) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

$? $0$ c () { local a b; a=foo; b=bar; echo c: $a $b; } ; c ; echo x: $a $b
c: foo bar
x:
$? $0$ exit
0 bash$ 

At any rate, the conservative patch is probably the least
objectionable one, even if i'd prefer the liberal one as a shell
script author ;).

Regards,

        --dkg

Attachment: pgphH4DXd3s_C.pgp
Description: PGP signature


Reply to: