Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Robert Elz 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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Date: Mon, 9 Mar 2020 20:28:30 +0059.55 From: Martin Castillo 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