bug-bash
[Top][All Lists]
Advanced

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

Re: Bash string substitution bug (?)


From: Chet Ramey
Subject: Re: Bash string substitution bug (?)
Date: Fri, 11 Jan 2008 18:19:02 -0500
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)

Bernd Eggink wrote:
Chet Ramey schrieb:
Bernd Eggink wrote:

      prompt: CLUSTER='1 2'; echo ${CLUSTER/${HOSTNAME/.*}}
      output:             -bash: ${HOSTNAME: bad substitution

Apparently bash interprets this as  ${parameter/pattern/string}
where pattern = ${HOSTNAME. Looks like a bug; it works in ksh.

That is, in fact, what is happening.  I'm not sure you can call it
a bug, though -- bash is behaving exactly as documented.

Where exactly is that documented? The only statement I can find in the documentation referring to this problem is:

The pattern and `string' in ${parameter/pattern/string} aren't defined
to obey the rules of parameter brace expansions.  The search for the
matching `/' is just a string search.

It would be less confusing if the code that searched for the closing
slash were smarter about skipping over embedded brace expansions, though.
It shouldn't be too hard to change that for the next release.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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