bug-bash
[Top][All Lists]
Advanced

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

Re: Assign Default Value expansion inserts ASCII DEL for empty 'word'


From: Robert Elz
Subject: Re: Assign Default Value expansion inserts ASCII DEL for empty 'word'
Date: Tue, 10 Mar 2020 12:16:33 +0700

    Date:        Mon, 9 Mar 2020 20:28:30 +0059.55
    From:        Martin Castillo <address@hidden>
    Message-ID:  <address@hidden>

  | Repeat-By:
  | $ unset foo bar
  | $ echo "${foo:=}/baz:${foo}/bat"|xxd
  | 00000000: 7f2f 6261 7a3a 2f62 6174 0a              ./baz:/bat.
  | $ echo "${foo:=$bar}/baz:${foo}/bat"|xxd
  | 00000000: 7f2f 6261 7a3a 2f62 6174 0a              ./baz:/bat.

Your tests are overly complex, and arguably stretch into unspecified
behaviour (not that that should have any bearing on this).

The problem occurs to happen when (and only when) a empty "default"
value is assigned to a variable which is (within the same quoted string)
concatenated with some non-empty text (before or after).

So
        "${foo:=}y"
or
        "x${foo:=}"
or
        "x${foo:=}y"

but not for any of

        "${foo:=}"
        x"${foo:=}"
        "${foo:=}"y
        x${foo:=}

(etc).   It is irrelevant whether the x & y here are literals, or the
results of expansions, provided that there is actual data, that is

        x= ; echo "${x}${foo:=}"
works
        x=x ; echo ${x}${foo:=}"
inserts the DEL as the value of ${foo:=}


kre




reply via email to

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