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
[EMAIL PROTECTED]
http://sudrala.de


Reply via email to