]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
sh: Expand assignment-like words specially for export/readonly/local.
authorjilles <jilles@FreeBSD.org>
Sun, 15 Jul 2012 10:19:43 +0000 (10:19 +0000)
committerjilles <jilles@FreeBSD.org>
Sun, 15 Jul 2012 10:19:43 +0000 (10:19 +0000)
commit689774f8e79cc120c6606a52baf8a4a0a17ed6b6
tree2e7b1c68d295b04b7db1b3b87ea0c5a9c84a9291
parent057a8ab456da82a3e40e6fba4629ba852dd79255
sh: Expand assignment-like words specially for export/readonly/local.

Examples:
  export x=~
now expands the tilde
  local y=$1
is now safe, even if $1 contains IFS characters or metacharacters.

For a word to "look like an assignment", it must start with a name followed
by an equals sign, none of which may be quoted.

The special treatment applies when the first word (potentially after
"command") is "export", "readonly" or "local". There may be quoting
characters but no expansions. If "local" is overridden with a function there
is no special treatment ("export" and "readonly" cannot be overridden with a
function).

If things like
  local arr=(1 2 3)
are ever allowed in the future, they cannot call a "local" function. This
would either be a run-time error or it would call the builtin.

This matches Austin Group bug #351, planned for the next issue of POSIX.1.

PR: bin/166771
bin/sh/eval.c
bin/sh/exec.c
bin/sh/exec.h
bin/sh/sh.1
tools/regression/bin/sh/expansion/export2.0 [new file with mode: 0644]
tools/regression/bin/sh/expansion/export3.0 [new file with mode: 0644]
tools/regression/bin/sh/expansion/local1.0 [new file with mode: 0644]
tools/regression/bin/sh/expansion/local2.0 [new file with mode: 0644]
tools/regression/bin/sh/expansion/readonly1.0 [new file with mode: 0644]