summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-07-16 17:27:54 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-07-16 17:30:54 -0700
commit2ff883c27e55b0c0d4a448614c1dee0492c9a7da (patch)
tree3af730421d527acd3139a122cb4ed0e5e7016d37
parent7c08375081545e1eaf96461319ffec0a02e9f959 (diff)
downloadautoconf-2ff883c27e55b0c0d4a448614c1dee0492c9a7da.tar.gz
Document that VAL must be a word in ${VAR-VALUE}
* doc/autoconf.texi (Shell Substitutions): Document that in ${VAR-VALUE}, VALUE must be a shell word, and omit examples implying otherwise.
-rw-r--r--doc/autoconf.texi49
1 files changed, 30 insertions, 19 deletions
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index b7b9e4a5..f178b385 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -16193,11 +16193,16 @@ j a0
@end example
@item $@{@var{var}:-@var{value}@}
+@itemx $@{@var{var}:=@var{value}@}
+@itemx $@{@var{var}:?@var{value}@}
+@itemx $@{@var{var}:+@var{value}@}
@c Info cannot handle ':' in index entries.
@ifnotinfo
@cindex @code{$@{@var{var}:-@var{value}@}}
+@cindex @code{$@{@var{var}:=@var{value}@}}
+@cindex @code{$@{@var{var}:?@var{value}@}}
+@cindex @code{$@{@var{var}:+@var{value}@}}
@end ifnotinfo
-@cindex @code{$@{@var{var}-@var{value}@}}
Old BSD shells, including the Ultrix @code{sh}, don't accept the
colon for any shell substitution, and complain and die.
Similarly for @code{$@{@var{var}:=@var{value}@}},
@@ -16206,13 +16211,31 @@ However, all shells that support functions allow the use of colon in
shell substitution, and since m4sh requires functions, you can portably
use null variable substitution patterns in configure scripts.
-@item $@{@var{var}+@var{value}@}
+@item $@{@var{var}-@var{value}@}
+@itemx $@{@var{var}:-@var{value}@}
+@itemx $@{@var{var}=@var{value}@}
+@itemx $@{@var{var}:=@var{value}@}
+@itemx $@{@var{var}?@var{value}@}
+@itemx $@{@var{var}:?@var{value}@}
+@itemx $@{@var{var}+@var{value}@}
+@itemx $@{@var{var}:+@var{value}@}
+@cindex @code{$@{@var{var}-@var{value}@}}
+@cindex @code{$@{@var{var}=@var{value}@}}
+@cindex @code{$@{@var{var}?@var{value}@}}
@cindex @code{$@{@var{var}+@var{value}@}}
+@c Info cannot handle ':' in index entries.
+@ifnotinfo
+@cindex @code{$@{@var{var}:-@var{value}@}}
+@cindex @code{$@{@var{var}:=@var{value}@}}
+@cindex @code{$@{@var{var}:?@var{value}@}}
+@cindex @code{$@{@var{var}:+@var{value}@}}
+@end ifnotinfo
When using @samp{$@{@var{var}-@var{value}@}} or
-@samp{$@{@var{var}-@var{value}@}} for providing alternate substitutions,
-@var{value} must either be a single shell word, quoted, or in the
-context of an unquoted here-document. Solaris
-@command{/bin/sh} complains otherwise.
+similar notations that modify a parameter expansion,
+Posix requires that @var{value} must be a single shell word,
+which can contain quoted strings but cannot contain unquoted spaces.
+If this requirement is not met Solaris 10 @command{/bin/sh}
+sometimes complains, and anyway the behavior is not portable.
@example
$ @kbd{/bin/sh -c 'echo $@{a-b c@}'}
@@ -16335,19 +16358,7 @@ user 0m0.002s
sys 0m0.003s
@end example
-As with @samp{+} and @samp{-}, you must use quotes when using @samp{=}
-if the @var{value} contains more than one shell word; either single
-quotes for just the @var{value}, or double quotes around the entire
-expansion:
-
-@example
-$ @kbd{: $@{var1='Some words'@}}
-$ @kbd{: "$@{var2=like this@}"}
-$ @kbd{echo $var1 $var2}
-Some words like this
-@end example
-
-@noindent
+As with @samp{+} and @samp{-}, @var{value} must be a single shell word,
otherwise some shells, such as Solaris @command{/bin/sh} or on Digital
Unix V 5.0, die because of a ``bad substitution''. Meanwhile, Posix
requires that with @samp{=}, quote removal happens prior to the