summaryrefslogtreecommitdiffstats
path: root/bin/sh/sh.1
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2012-07-15 10:19:43 +0000
committerjilles <jilles@FreeBSD.org>2012-07-15 10:19:43 +0000
commit689774f8e79cc120c6606a52baf8a4a0a17ed6b6 (patch)
tree2e7b1c68d295b04b7db1b3b87ea0c5a9c84a9291 /bin/sh/sh.1
parent057a8ab456da82a3e40e6fba4629ba852dd79255 (diff)
downloadFreeBSD-src-689774f8e79cc120c6606a52baf8a4a0a17ed6b6.zip
FreeBSD-src-689774f8e79cc120c6606a52baf8a4a0a17ed6b6.tar.gz
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
Diffstat (limited to 'bin/sh/sh.1')
-rw-r--r--bin/sh/sh.116
1 files changed, 15 insertions, 1 deletions
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index 34b6b2b..908f78d 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -32,7 +32,7 @@
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\" $FreeBSD$
.\"
-.Dd November 5, 2011
+.Dd July 15, 2012
.Dt SH 1
.Os
.Sh NAME
@@ -1164,6 +1164,20 @@ Assignments are expanded differently from other words:
tilde expansion is also performed after the equals sign and after any colon
and usernames are also terminated by colons,
and field splitting and pathname expansion are not performed.
+.Pp
+This special expansion applies not only to assignments that form a simple
+command by themselves or precede a command word,
+but also to words passed to the
+.Ic export ,
+.Ic local
+or
+.Ic readonly
+built-in commands that have this form.
+For this, the builtin's name must be literal
+(not the result of an expansion)
+and may optionally be preceded by one or more literal instances of
+.Ic command
+without options.
.Ss Positional Parameters
A positional parameter is a parameter denoted by a number greater than zero.
The shell sets these initially to the values of its command line
OpenPOWER on IntegriCloud