bug-bash
[Top][All Lists]
Advanced

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

Re: Bash string substitution bug (?)


From: Bernd Eggink
Subject: Re: Bash string substitution bug (?)
Date: Fri, 11 Jan 2008 17:28:41 +0100
User-agent: Thunderbird 2.0.0.9 (X11/20071031)

Dmitry V Golovashkin schrieb:

Description:
   unexpected bad substitution:
   enter the following simple list:

    prompt:  CLUSTER='1 2'; echo ${CLUSTER/${HOSTNAME%%.*}}
    output:       1 2

the idea of the above line is to remove short HOSTNAME (without the trailing domain) from the CLUSTER - works fine (CLUSTER was assigned a dummy value - irrelevant) however the same operation with slash results in a bad substitution error.
   the substitution appears to be a valid one.

      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.

As a workaround, you could use:

        H=${HOSTNAME/.*}
        echo ${CLUSTER/$H}

Regards,
Bernd

--
Bernd Eggink
monoped@sudrala.de
http://sudrala.de




reply via email to

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