bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Documentation inconsistency (?)


From: Alexis Reynouard
Subject: Documentation inconsistency (?)
Date: Thu, 06 Feb 2025 11:26:08 +0100
User-agent: Evolution 3.52.3-0ubuntu1

Hello,

This concern:
https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion

In the bash documentation, section “shell parameter expansion,” in the
paragraph “${parameter:-word},” the example given uses
   ${parameter-word}
which is a Bourne Shell compatible expansion but behaves differently
for defined but empty parameters. For greater clarity, shouldn't we
write the following documentation (Please excuse the RST syntax):

``${parameter:-word}``
----------------------

If parameter is unset or null, the expansion of word is substituted.
Otherwise, the value of parameter is substituted.

::

   $ v=123
   $ echo ${v:-unset}
   123
   $ e=''
   $ echo ${e:-unset}
   unset
   $ echo ${u:-unset}
   unset

``${parameter-word}``
---------------------

If parameter is unset, the expansion of word is substituted. Otherwise,
the value of parameter is substituted.
This differs from ``${parameter:-word}`` in the case where
``parameter`` is set but not null.
This expansion comes from Bourne-Shell.

::

   $ v=123
   $ echo ${v:-unset}
   123
   $ e=''
   $ echo ${e:-unset}
   
   $ echo ${u:-unset}
   unset

P.-S. This is my first report to a GNU project. Please point out any
important best practices that I have not followed.
-- 
Alexis Reynouard <alexis.reynouard@gmail.com>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]