Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16005

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

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Robert Elz <kre@munnari.OZ.AU>
Newsgroups gnu.bash.bug
Subject Re: Assign Default Value expansion inserts ASCII DEL for empty 'word'
Date Tue, 10 Mar 2020 12:16:33 +0700
Lines 44
Approved bug-bash@gnu.org
Message-ID <mailman.2377.1583817423.2412.bug-bash@gnu.org> (permalink)
References <5ad25080-7c13-9b9c-cff6-12ffee7afeb8@uni-bremen.de> <7846.1583817393@jinx.noi.kre.to>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1583817424 3097 209.51.188.17 (10 Mar 2020 05:17:04 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org
To Martin Castillo <castilma@uni-bremen.de>
Envelope-to bug-bash@gnu.org
In-Reply-To <5ad25080-7c13-9b9c-cff6-12ffee7afeb8@uni-bremen.de>
X-detected-operating-system by eggs.gnu.org: GNU/Linux 3.x [generic]
X-Received-From 2001:3c8:9009:181::2
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <7846.1583817393@jinx.noi.kre.to>
X-Mailman-Original-References <5ad25080-7c13-9b9c-cff6-12ffee7afeb8@uni-bremen.de>
Xref csiph.com gnu.bash.bug:16005

Show key headers only | View raw


    Date:        Mon, 9 Mar 2020 20:28:30 +0059.55
    From:        Martin Castillo <castilma@uni-bremen.de>
    Message-ID:  <5ad25080-7c13-9b9c-cff6-12ffee7afeb8@uni-bremen.de>

  | 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

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Assign Default Value expansion inserts ASCII DEL for empty 'word' Robert Elz <kre@munnari.OZ.AU> - 2020-03-10 12:16 +0700

csiph-web