Bug 185481 - sh/bash Parameter Expansion +/- syntax not documented
Summary: sh/bash Parameter Expansion +/- syntax not documented
Status: In Progress
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Benjamin Kaduk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-05 04:00 UTC by Ronald F. Guilmette
Modified: 2018-04-09 07:06 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ronald F. Guilmette 2014-01-05 04:00:00 UTC
Both /bin/sh and /usr/local/bin/bash appear to correctly implement the
following forms of shell parameter expansion syntax, as required by POSIX
ISO/IEC 9945-2 & ANSI/IEEE Std 1003.3 (1993-12-22):

	${parameter-word}
	${parameter+word}

These forms are not however documented in the "Parameter Expansion"
sections of either the man page for sh or the man page for bash.
(I should perhaps be filing this PR as two separate PRs, one for sh
and one for bash, and will do so upon request.  However my hope is
that whoever fixes one of the two relevant man pages will also have
the courtesy to fix the other as well.)

Note:  The semantics of the two forms of parameter expansion syntax
mentioned above are helpfully and briefly described on the following web
page:

http://serverfault.com/questions/7503/how-to-determine-if-a-bash-variable-is-empty

Fix: 

The author of this PR will provide diffs/patches for the relevant man pages
upon request, however the fix in each case (sh and bash) should be both
trivial and obvious, I believe.
How-To-Repeat: 
man 1 sh
man 1 bash
Comment 1 Taras Korenko 2014-01-05 10:30:13 UTC
On Sat, Jan 04, 2014 at 07:45:19PM -0800, Ronald F.Guilmette wrote:
> ...
> 	${parameter-word}
> 	${parameter+word}
> 
> These forms are not however documented in the "Parameter Expansion"
> sections of either the man page for sh or the man page for bash.
> ...

"In the parameter expansions shown previously, use of the colon in the
format results in a test for a parameter that is unset or null; omission
of the colon results in a test for a parameter that is only unset."

(c) sh(1) under "Parameter Expansion" section (also on web -> [1]).

--
1. http://www.freebsd.org/cgi/man.cgi?query=sh&apropos=0&sektion=1&manpath=FreeBSD+9.2-RELEASE&arch=default&format=html
-- 
  WBR, Taras Korenko
Comment 2 Benjamin Kaduk freebsd_committer 2014-06-08 01:14:28 UTC
As noted in comment 1, these expansion syntaxes are documented, albeit not in a very obvious fashion.

bash is not part of the FreeBSD base system; the manual page for bash is installed as part of the bash package,so issues with the bash manual page should be reported to the bash upstream.

I will think about whether there are ways to reword the sh manual page to make these syntaxes more clear.