bug-bash
[Top][All Lists]
Advanced

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

Re: man mention case of null word in ${parameter#word}


From: Paul Jarc
Subject: Re: man mention case of null word in ${parameter#word}
Date: Fri, 23 Nov 2001 05:09:00 -0500
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7 (i386-redhat-linux-gnu)

Dan Jacobson <address@hidden> wrote:
> In the manual, for
>        ${parameter#word}
> etc. it doesn't mention the case of when word is null.

Except in certain documented cases, an unset variable is just like one
set to an empty string, and the empty string case is covered by the
current documentation of this feature.  There's no need to also
mention the unset case here.

> Furthermore, for
> $ a=(123 456);echo address@hidden/#/1}
> 1123 1456
>
> one might have never thought this possible, due to the manual only
> saying:
>
>        ${parameter/pattern/string}
>
>               ...If string is null, matches of pattern are deleted and
>               the / following pattern may be omitted.

No, it says more than that:
       ${parameter/pattern/string}
       ${parameter//pattern/string}
              The  pattern  is expanded to produce a pattern just
              as in pathname expansion.   Parameter  is  expanded
              and  the longest match of pattern against its value
              is replaced with string.  In the first  form,  only
              the  first  match  is  replaced.   The  second form
              causes all matches of pattern to be  replaced  with
              string.  If pattern begins with #, it must match at
              the beginning of the expanded value  of  parameter.
              If  pattern begins with %, it must match at the end
              of the expanded value of parameter.  If  string  is
              null, matches of pattern are deleted and the / folĀ­
              lowing pattern may be omitted.  If parameter  is  @
              or *, the substitution operation is applied to each
              positional parameter in turn, and the expansion  is
              the resultant list.  If parameter is an array variĀ­
              able subscripted with  @  or  *,  the  substitution
              operation is applied to each member of the array in
              turn, and the expansion is the resultant list.


paul



reply via email to

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