From MAILER-DAEMON Sat Apr 01 16:49:46 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cuPxy-0006XC-Ga
	for mharc-bug-bash@gnu.org; Sat, 01 Apr 2017 16:49:46 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:45101)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cuPxw-0006Vs-42
	for bug-bash@gnu.org; Sat, 01 Apr 2017 16:49:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cuPxs-0004M8-QR
	for bug-bash@gnu.org; Sat, 01 Apr 2017 16:49:44 -0400
Received: from mpv3-2015.cwru.edu ([129.22.103.194]:58095
	helo=mpv3-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cuPxs-0004Lh-MU
	for bug-bash@gnu.org; Sat, 01 Apr 2017 16:49:40 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv3-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALC68900; Sat, 01 Apr 2017 16:49:39 -0400 (EDT)
Received: from h105.242.21.98.dynamic.ip.windstream.net (EHLO
	_192.168.254.13_) ([98.21.242.105])
	by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GTD00478 (AUTH cpr);
	Sat, 01 Apr 2017 16:49:38 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Subject: Re: "$@" eats adjacent quoted nulls when expanding to quoted null
References: <CAMu=BrpxfFwES410AL6yMVJi8AhN6LBtQeBQikc3Rc2ukX0Sig@mail.gmail.com>
To: Grisha Levit <grishalevit@gmail.com>, bug-bash <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <bac9ea4a-f008-b3e7-0dcf-d5f7e7e92155@case.edu>
Date: Sat, 1 Apr 2017 16:49:37 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAMu=BrpxfFwES410AL6yMVJi8AhN6LBtQeBQikc3Rc2ukX0Sig@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv3-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.194
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 01 Apr 2017 20:49:45 -0000

On 3/30/17 3:19 AM, Grisha Levit wrote:
> (This is very similar to a fixed issue[1] from 4.4-beta)
> 
> A quoted null string will fail to generate a field when it is adjacent
> to a double-quoted expansion of $@ which itself expands to a null string:

Thanks for the report. I'll take a look.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sat Apr 01 21:05:15 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cuTxD-0007jG-LF
	for mharc-bug-bash@gnu.org; Sat, 01 Apr 2017 21:05:15 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34139)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cuTxB-0007j7-S9
	for bug-bash@gnu.org; Sat, 01 Apr 2017 21:05:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cuTx8-0007j5-L8
	for bug-bash@gnu.org; Sat, 01 Apr 2017 21:05:13 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:25202
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cuTx8-0007fK-Eo
	for bug-bash@gnu.org; Sat, 01 Apr 2017 21:05:10 -0400
Received: from mpv8-2015.CWRU.Edu (EHLO mpv8-2015.case.edu) ([129.22.103.210])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AKX70765; Sat, 01 Apr 2017 21:05:08 -0400 (EDT)
Received: from h105.242.21.98.dynamic.ip.windstream.net (EHLO
	_192.168.254.13_) ([98.21.242.105])
	by mpv8-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GTO68726 (AUTH cpr);
	Sat, 01 Apr 2017 21:05:07 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Subject: Re: splitting/whitespace in expansions of ${*} vs ${*/}
References: <CAMu=BrpnD7tEB72+ik+92aGq6hk4iSZqR6uE8mdNyriwXd+4Nw@mail.gmail.com>
	<1944099d-0d99-8499-8151-188c21748e7b@case.edu>
	<CAMu=BroRYpKKNcye9Hu9CcoPQHpJZfXU8bu9Jsq9To8zA9yCCg@mail.gmail.com>
To: Grisha Levit <grishalevit@gmail.com>
Cc: chet.ramey@case.edu, bug-bash <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <d42a1794-6d1d-b69b-fa88-84a676ae1533@case.edu>
Date: Sat, 1 Apr 2017 21:05:06 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAMu=BroRYpKKNcye9Hu9CcoPQHpJZfXU8bu9Jsq9To8zA9yCCg@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv4-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 02 Apr 2017 01:05:15 -0000

On 3/30/17 4:30 AM, Grisha Levit wrote:
> Sorry if you already noticed this: The latest devel push fixes the reported
> field-splitting case but there is a regression with the fields getting
> re-joined with spaces when performing an assignment:
> 
>    $ set -- 1 2; IFS=; a=$* b=${*/}; printf '<%s>' "$a" "$b"
>    <12><1 2>
> 
> and with the expansion producing fields in the PE assignment case:
> 
>    $ set -- 1 2; IFS=; unset a b; printf '<%s>' ${a=$*} ${b=${*/}}
>    <12><1><2>

Thanks for the report.  This will be fixed in the next devel branch push.

> Also, upon closer inspection, I suspect the unset IFS case in my report is
> actually an issue with the a=$* case and that b=${*/} behaves correctly
> (aside from not matching the a=$* behavior).  The whitespace-trimming-when-
> not-field-splitting thing is something that changed in bash-4.3:
> 
>    bash-4.2$ unset IFS; set ' '; a=$*; printf '<%s>' "$a"
>    < >
>    bash-4.3$ unset IFS; set ' '; a=$*; printf '<%s>' "$a"
>    <>

This, too, but we're getting into more and more corner cases here, as
evidenced by the fact that this hasn't been reported until now.

> 
> Also also, the field-splitting issue is also present for arrays subscripted
> with * when undergoing case modification or pattern substitution:
> 
>    $ A=(1 2); IFS=; printf '<%s>' ${A[*]} ${A[*]/}
>    <1><2><12>

That's next to look at. I haven't made analogous changes to the array
expansion code yet.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sun Apr 02 20:34:23 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cupwt-0001Io-CS
	for mharc-bug-bash@gnu.org; Sun, 02 Apr 2017 20:34:23 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:56947)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <martijn@inlv.org>) id 1cupwq-0001Ie-Px
	for bug-bash@gnu.org; Sun, 02 Apr 2017 20:34:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <martijn@inlv.org>) id 1cupwn-00028b-MG
	for bug-bash@gnu.org; Sun, 02 Apr 2017 20:34:20 -0400
Received: from kahlil.inlv.org ([37.59.109.123]:48248)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <martijn@inlv.org>) id 1cupwn-00026c-DI
	for bug-bash@gnu.org; Sun, 02 Apr 2017 20:34:17 -0400
Received: from breedzicht.local (inlv.demon.nl [212.238.240.159])
	(authenticated bits=0)
	by kahlil.inlv.org (8.14.9/8.14.4) with ESMTP id v330YEQw018951
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO)
	for <bug-bash@gnu.org>; Mon, 3 Apr 2017 02:34:14 +0200
To: bug-bash@gnu.org
From: Martijn Dekker <martijn@inlv.org>
Subject: another case from the case corner case casualty case files
Message-ID: <255d3725-e5d4-1274-551e-955701cbe5d9@inlv.org>
Date: Mon, 3 Apr 2017 02:34:13 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 37.59.109.123
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 03 Apr 2017 00:34:21 -0000

$ x=$'\\a\\b\\c\\\001\\d\\e\\f'
$ case $'abc\001def' in $x) echo ok ;; *) echo oops; esac
oops
$ x=$'\\a\\b\\c\\\002\\d\\e\\f'
$ case $'abc\002def' in $x) echo ok ;; *) echo oops; esac
ok

'case' can't match an escaped $'\001' character passed from a variable.
Any other character from $'\002' up works fine. Curious that $'\001'
seems to be handled specially somehow.

- M


From MAILER-DAEMON Mon Apr 03 15:49:07 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cv7yN-0000sN-BJ
	for mharc-bug-bash@gnu.org; Mon, 03 Apr 2017 15:49:07 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40493)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cv7yK-0000om-N1
	for bug-bash@gnu.org; Mon, 03 Apr 2017 15:49:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cv7yF-0005Jt-KM
	for bug-bash@gnu.org; Mon, 03 Apr 2017 15:49:04 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:64194
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cv7yF-0005Je-Fs
	for bug-bash@gnu.org; Mon, 03 Apr 2017 15:48:59 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AKZ82661; Mon, 03 Apr 2017 15:48:55 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCM35296 (AUTH cpr);
	Mon, 03 Apr 2017 15:48:54 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: another case from the case corner case casualty case files
References: <255d3725-e5d4-1274-551e-955701cbe5d9@inlv.org>
To: Martijn Dekker <martijn@inlv.org>, bug-bash@gnu.org
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <601195d3-d68e-fc93-7d39-13e02d6e7339@case.edu>
Date: Mon, 3 Apr 2017 15:48:54 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <255d3725-e5d4-1274-551e-955701cbe5d9@inlv.org>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv4-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 03 Apr 2017 19:49:06 -0000

On 4/2/17 8:34 PM, Martijn Dekker wrote:
> $ x=$'\\a\\b\\c\\\001\\d\\e\\f'
> $ case $'abc\001def' in $x) echo ok ;; *) echo oops; esac
> oops
> $ x=$'\\a\\b\\c\\\002\\d\\e\\f'
> $ case $'abc\002def' in $x) echo ok ;; *) echo oops; esac
> ok
> 
> 'case' can't match an escaped $'\001' character passed from a variable.
> Any other character from $'\002' up works fine. Curious that $'\001'
> seems to be handled specially somehow.

Thanks.  This will, in the fullness of time, be fixed.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Tue Apr 04 11:33:31 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cvQSZ-0003zh-D0
	for mharc-bug-bash@gnu.org; Tue, 04 Apr 2017 11:33:31 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:41490)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <nesrovnal.tomas@gmail.com>) id 1cvKyl-0003It-GM
	for bug-bash@gnu.org; Tue, 04 Apr 2017 05:42:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <nesrovnal.tomas@gmail.com>) id 1cvKyk-0008WN-Jt
	for bug-bash@gnu.org; Tue, 04 Apr 2017 05:42:23 -0400
Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:33058)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <nesrovnal.tomas@gmail.com>)
	id 1cvKyk-0008UA-D8
	for bug-bash@gnu.org; Tue, 04 Apr 2017 05:42:22 -0400
Received: by mail-wr0-x231.google.com with SMTP id w43so205789142wrb.0
	for <bug-bash@gnu.org>; Tue, 04 Apr 2017 02:42:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:sender:from:date:message-id:subject:to;
	bh=tpFcTOlak+kVI8Mk1aY5eZj4t2hPHBmSGJ0SI/YEmd4=;
	b=arScOMay1tnvBnsLQX7UNCslU6WELhpwZ/STKosnHizHpvqkI+LoBwsgCEufwkpiiy
	sDnwrJ07DHwo6e8Brqgiz4KumS1NMo0nO7fyF958X/IxJ787yLrTsZkn5oNrbXkUxtDN
	qU03QpHriIlOKPLNI6LqzCkAZLLBuubBkPvmuF4dtJ5WJ9QGFkwaaRLa7r1YZaVUMLT6
	OjQpPatpj1dVR4BzO/YVBJr2VQ8MvnxA+z4Ku81w27XRSc2eDtx90cPfcaMpfVpCNJ5C
	622rsiKEHEQPFdiWLAfA6NNTEoI5U81v0ddH5vLxRordElT/i6UzdoR7Q2mnNIlr3vzh
	bKCA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:sender:from:date:message-id:subject
	:to; bh=tpFcTOlak+kVI8Mk1aY5eZj4t2hPHBmSGJ0SI/YEmd4=;
	b=roo40hnPCXg6Dqf122D95H77Z6TrMe8UhVGH3cjL1BFNf41vy7gq6ckC+UAcfDc+Jp
	ijjPCAo7pJn+oiD9rcDMus3zWwhcu4cv9krAfhjF9YbVNlSf5+EG1x5VNNHyM/5GeuQl
	SJEJu4D3sKGUJ0IIaclDIBkwYGm9j2OMIwpvwgUIlQdfUWCNWSOaw/csShZdYkRoQ9Lp
	WOFmh+UzRo2morPZxqzsoWkXEmh7Wm/gvqW7WZVhosATE6KMWMM/QdYCwHu50knvgokz
	YF9DozY9ewIBqB3bQjbBFcRqJBp15ChsNptasRLnQVUE0a1jjCvB5NW2LiyJICDw7c3Y
	58Yw==
X-Gm-Message-State: AFeK/H3q0hkkh+jgd+kLGf/nhSEopIkoEHQKXwZD4yFSOpIrvP9pQRVsr1sHvbiCp+P5H1KZpDjcTKaFkcYqTw==
X-Received: by 10.28.234.71 with SMTP id i68mr14358345wmh.81.1491298940633;
	Tue, 04 Apr 2017 02:42:20 -0700 (PDT)
MIME-Version: 1.0
Sender: nesrovnal.tomas@gmail.com
Received: by 10.28.66.216 with HTTP; Tue, 4 Apr 2017 02:41:40 -0700 (PDT)
From: nesro <nesro@nesro.cz>
Date: Tue, 4 Apr 2017 11:41:40 +0200
X-Google-Sender-Auth: fuqpUyqP4ppME8K7_lFwD6CDykE
Message-ID: <CAF3CqmuTtn8qnfHjeOJschWEhfZOxa6iVxEbhfs3di7cmG_THw@mail.gmail.com>
Subject: while loop with extdebug + debug trap always returning 1
To: bug-bash@gnu.org
Content-Type: multipart/alternative; boundary=001a1147232a9c46ba054c541799
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2a00:1450:400c:c0c::231
X-Mailman-Approved-At: Tue, 04 Apr 2017 11:33:30 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 04 Apr 2017 09:42:24 -0000

--001a1147232a9c46ba054c541799
Content-Type: text/plain; charset=UTF-8

Hi bash-bug,

I think I've found a bug in bash.

I'm working on a project that skips** all commands that are going to be
executed. I achieved this by a combination of a debug trap and extdebug.
Once,
for the entire list of commands to be executed, I'm going to execute it via
eval
from the debug trap. It works surprisingly well and it opens a possibility
of
really cool things.

**Excerpt from man bash extdebug: "If the command run by the DEBUG trap
returns
a nonzero value, the next command is skipped and not executed."

I found out that the while cycle is not working, but the for cycle is. Which
made me think that I found a bug in bash.

There are the instructions to reproduce the bug:


# create a new shell
bash --norc


# set up xtrace to see what's happening (not mandatory for reproduction)
set -x


# set up the debug trap with extdebug so that every command is not executed
# (be sure to close and reopen the shell, because trying to set it
differently
# will not work)
t() { return 1; }
trap t DEBUG
shopt -s extdebug


# run an empty for cycle. we can see from the output that bash ran :, then
# false and stopped to it. which is the right behavior
for (( :; false; )); do :; done


# now run this while cycle. it just cycle the debug trap forever
while false; do :; done



I've tried it on two versions of bash under lubuntu gnu/linux:
- 4.3.46(1)-release
- 4.4.0(1)-release


Please let me know if I overlooked something, or if this really looks like
a bug.

Thank you,
Tomas Nesrovnal

--001a1147232a9c46ba054c541799
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div>Hi bash-bug,</div><div><br></div><div>I think I&=
#39;ve found a bug in bash.</div><div><br></div><div>I&#39;m working on a p=
roject that skips** all commands that are going to be</div><div>executed. I=
 achieved this by a combination of a debug trap and extdebug. Once,</div><d=
iv>for the entire list of commands to be executed, I&#39;m going to execute=
 it via eval</div><div>from the debug trap. It works surprisingly well and =
it opens a possibility of</div><div>really cool things.</div><div><br></div=
><div>**Excerpt from man bash extdebug: &quot;If the command run by the DEB=
UG trap returns</div><div>a nonzero value, the next command is skipped and =
not executed.&quot;</div><div><br></div><div>I found out that the while cyc=
le is not working, but the for cycle is. Which</div><div>made me think that=
 I found a bug in bash.</div><div><br></div><div>There are the instructions=
 to reproduce the bug:</div><div><br></div><div><br></div><div># create a n=
ew shell</div><div>bash --norc</div><div><br></div><div><br></div><div># se=
t up xtrace to see what&#39;s happening (not mandatory for reproduction)</d=
iv><div>set -x</div><div><br></div><div><br></div><div># set up the debug t=
rap with extdebug so that every command is not executed</div><div># (be sur=
e to close and reopen the shell, because trying to set it differently</div>=
<div># will not work)</div><div>t() { return 1; }</div><div>trap t DEBUG</d=
iv><div>shopt -s extdebug</div><div><br></div><div><br></div><div># run an =
empty for cycle. we can see from the output that bash ran :, then</div><div=
># false and stopped to it. which is the right behavior</div><div>for (( :;=
 false; )); do :; done</div><div><br></div><div><br></div><div># now run th=
is while cycle. it just cycle the debug trap forever</div><div>while false;=
 do :; done</div><div><br></div><div><br></div><div><br></div><div>I&#39;ve=
 tried it on two versions of bash under lubuntu gnu/linux:</div><div>- 4.3.=
46(1)-release</div><div>- 4.4.0(1)-release</div><div><br></div><div><br></d=
iv><div>Please let me know if I overlooked something, or if this really loo=
ks like</div><div>a bug.</div><div><br></div><div>Thank you,</div><div>Toma=
s Nesrovnal</div></div>
</div>

--001a1147232a9c46ba054c541799--


From MAILER-DAEMON Tue Apr 04 11:57:32 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cvQpo-0000n7-Bk
	for mharc-bug-bash@gnu.org; Tue, 04 Apr 2017 11:57:32 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40663)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <martijn@inlv.org>) id 1cvQpm-0000mn-Ha
	for bug-bash@gnu.org; Tue, 04 Apr 2017 11:57:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <martijn@inlv.org>) id 1cvQpj-0005bT-CJ
	for bug-bash@gnu.org; Tue, 04 Apr 2017 11:57:30 -0400
Received: from kahlil.inlv.org ([37.59.109.123]:52774)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <martijn@inlv.org>) id 1cvQpj-0005Zh-3X
	for bug-bash@gnu.org; Tue, 04 Apr 2017 11:57:27 -0400
Received: from breedzicht.local ([193.173.216.141]) (authenticated bits=0)
	by kahlil.inlv.org (8.14.9/8.14.4) with ESMTP id v34FvMG1031031
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);
	Tue, 4 Apr 2017 17:57:23 +0200
Subject: Re: while loop with extdebug + debug trap always returning 1
To: nesro <nesro@nesro.cz>, bug-bash@gnu.org
References: <CAF3CqmuTtn8qnfHjeOJschWEhfZOxa6iVxEbhfs3di7cmG_THw@mail.gmail.com>
From: Martijn Dekker <martijn@inlv.org>
Message-ID: <03cbe7d4-27c2-968f-fed3-6500e7ab8d5b@inlv.org>
Date: Tue, 4 Apr 2017 17:57:20 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAF3CqmuTtn8qnfHjeOJschWEhfZOxa6iVxEbhfs3di7cmG_THw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 37.59.109.123
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 04 Apr 2017 15:57:31 -0000

Op 04-04-17 om 11:41 schreef nesro:
> # run an empty for cycle. we can see from the output that bash ran :, then
> # false and stopped to it. which is the right behavior
> for (( :; false; )); do :; done

This is a syntax error. 'for' takes arithmetic expressions, not shell
commands.

> # now run this while cycle. it just cycle the debug trap forever
> while false; do :; done

The 'false' command is never executed so never has the chance to return
an exit status of "false" (1).

- M.



From MAILER-DAEMON Tue Apr 04 15:29:28 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cvU8t-0007DD-Uc
	for mharc-bug-bash@gnu.org; Tue, 04 Apr 2017 15:29:27 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55125)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cvU8r-0007Bs-VC
	for bug-bash@gnu.org; Tue, 04 Apr 2017 15:29:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cvU8r-00088g-9u
	for bug-bash@gnu.org; Tue, 04 Apr 2017 15:29:26 -0400
Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:35188)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <grishalevit@gmail.com>)
	id 1cvU8r-00088Y-3G
	for bug-bash@gnu.org; Tue, 04 Apr 2017 15:29:25 -0400
Received: by mail-oi0-x22b.google.com with SMTP id f193so175398463oib.2
	for <bug-bash@gnu.org>; Tue, 04 Apr 2017 12:29:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=SMT86K6kKHvXy79uae+eGlYjTzQJki/vzxutBysvq1g=;
	b=mUpCdDaSnb7v+YUe2hsu9+yZHfpn+fftagfclsC2LOzayQZ6o8jQvSMXLYIGJx9hpp
	zQmaZN29Uhz3v7Lq0eNG42n3iqSK49x2mb6npAOMOtKPfHfiMuGyo1lVUlnrckgfkFfn
	rA0OWTppV7PC3T7iAFvcXZL+PoDiAfVENHzVxpIcE2K9cgy6GN+EatccCgwi65WScqZj
	gwOx1jZMvC8GS2h9WhDnpFX+mAM7duphiR30BD65Z1LTDJKT1JCa1knnwfR8DcTglHqn
	oxDK7aAbTOv3SG9B+/Ze6rqOEZl/jyutRb9h7XfexU6yAi403ipK0mdvyUSX2Hys226J
	CkcQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=SMT86K6kKHvXy79uae+eGlYjTzQJki/vzxutBysvq1g=;
	b=gziXHyrX0yKwPgKbOeX/z8gkh7i3ax5XBe1RQJxp6shwxVKg2QSH3V1IhqyqztWyn6
	4HYbkm7p35w1ZfU9nz7r9pfKkiTMfkSVJCbS0ZQ9+kyB/jWSgCzUg8K3IZOsJdp2v1ZM
	NFJTmE8o+jp+mSgQPh1hjSsRUazep89UBbGjYnjz4x9BBoGyWKjlJMViyBHYnWJEzWu2
	Xs5BEm6TcWsvrI4vAHO0YuL2d93dMI0UcJALdjDixUvHMduRTB2gX5stPjf3vGZCzWVu
	YqxAvfzrOQ/wSXZK1Ml0tkaO+xel+ScRMblmY2WfxK6vjSQX/q/SnsYshCoubPbyxfhj
	9rGQ==
X-Gm-Message-State: AFeK/H3UxpbDiidU5XZPAWhZEpWdAX/Icx7cQpwmBSocHrIFsSfbj07bx2kCv96QQr/T8L/rrmThEdf6DbjZJg==
X-Received: by 10.202.56.130 with SMTP id f124mr12469664oia.204.1491334164025; 
	Tue, 04 Apr 2017 12:29:24 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.6.133 with HTTP; Tue, 4 Apr 2017 12:29:03 -0700 (PDT)
In-Reply-To: <d42a1794-6d1d-b69b-fa88-84a676ae1533@case.edu>
References: <CAMu=BrpnD7tEB72+ik+92aGq6hk4iSZqR6uE8mdNyriwXd+4Nw@mail.gmail.com>
	<1944099d-0d99-8499-8151-188c21748e7b@case.edu>
	<CAMu=BroRYpKKNcye9Hu9CcoPQHpJZfXU8bu9Jsq9To8zA9yCCg@mail.gmail.com>
	<d42a1794-6d1d-b69b-fa88-84a676ae1533@case.edu>
From: Grisha Levit <grishalevit@gmail.com>
Date: Tue, 4 Apr 2017 15:29:03 -0400
Message-ID: <CAMu=BrovBftEfwDBzBkiPndOYA9cpjMaGttwEEmnFXaLCn_Ugw@mail.gmail.com>
Subject: Re: splitting/whitespace in expansions of ${*} vs ${*/}
To: Chester Ramey <chet.ramey@case.edu>
Cc: bug-bash <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4003:c06::22b
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 04 Apr 2017 19:29:27 -0000

There are a few small regressions in the latest devel relative to the
previous two commits but they're all rather exotic. Again, sorry if this
is still WIP/too minor:

CTLESC present in output (even with default IFS)

   $ set -- 1; unset var; printf ${var-${*:1}} | xxd
   00000000: 0131                                     .1

   $ set -- 1; unset var; : ${var=${*:1}}; printf "$var" | xxd
   00000000: 0131                                     .1

Not splitting (with default IFS):

   $ set -- '1 1'; unset a b; printf '<%s>' ${a=$*} ${b=${*:1}}
   <1><1><1 1>

A few more cases below:

   # this worked correctly in the 20170324 push
   $ set -- 1 2; IFS=; unset a b; printf '<%s>' $* ${a-$*} ${b-${*/}}
   <1><2><1><2><12>

   # this worked correctly in the 20170317 push
   $ set -- 1 2; IFS=; unset a b; x=$*; printf '<%s>' $x ${a=$*} ${b=${*,}}
   <12><12><1><2>

   # as did this:
   $ set -- 1 2; IFS=; a=$* b=${*@E}; printf '<%s>' "$a" "$b"
   <12><1 2>

Another (rather unlikely-to-be-encountered) case of CTLESC showing up in
output (worked correctly in 20170317 but not in release):

   # both indexed and assoc array have this:
   $ A=(' '); IFS=; unset novar; var=${A[*]@E}
   $ printf '%s' "$var" ${novar-${A[*]@E}} | xxd
   00000000: 0120 0120                                . .


From MAILER-DAEMON Tue Apr 04 15:35:57 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cvUFB-0008KZ-3a
	for mharc-bug-bash@gnu.org; Tue, 04 Apr 2017 15:35:57 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:56684)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cvUF9-0008Jh-Fd
	for bug-bash@gnu.org; Tue, 04 Apr 2017 15:35:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cvUF4-0003Hq-Jl
	for bug-bash@gnu.org; Tue, 04 Apr 2017 15:35:55 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:26805
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cvUF4-0003Ge-Ei
	for bug-bash@gnu.org; Tue, 04 Apr 2017 15:35:50 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AML25786; Tue, 04 Apr 2017 15:35:48 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCO27475 (AUTH cpr);
	Tue, 04 Apr 2017 15:35:48 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: splitting/whitespace in expansions of ${*} vs ${*/}
References: <CAMu=BrpnD7tEB72+ik+92aGq6hk4iSZqR6uE8mdNyriwXd+4Nw@mail.gmail.com>
	<1944099d-0d99-8499-8151-188c21748e7b@case.edu>
	<CAMu=BroRYpKKNcye9Hu9CcoPQHpJZfXU8bu9Jsq9To8zA9yCCg@mail.gmail.com>
	<d42a1794-6d1d-b69b-fa88-84a676ae1533@case.edu>
	<CAMu=BrovBftEfwDBzBkiPndOYA9cpjMaGttwEEmnFXaLCn_Ugw@mail.gmail.com>
To: Grisha Levit <grishalevit@gmail.com>
Cc: chet.ramey@case.edu, bug-bash <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <62a0af25-6ec8-2861-079c-88bcfd1b012f@case.edu>
Date: Tue, 4 Apr 2017 15:35:48 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAMu=BrovBftEfwDBzBkiPndOYA9cpjMaGttwEEmnFXaLCn_Ugw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 04 Apr 2017 19:35:56 -0000

On 4/4/17 3:29 PM, Grisha Levit wrote:
> There are a few small regressions in the latest devel relative to the
> previous two commits but they're all rather exotic. Again, sorry if this
> is still WIP/too minor:

It is still a work in progress, but these are useful test cases.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Tue Apr 04 17:09:41 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cvVhs-0002CY-W9
	for mharc-bug-bash@gnu.org; Tue, 04 Apr 2017 17:09:41 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53056)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <nesrovnal.tomas@gmail.com>) id 1cvVhr-0002BN-0E
	for bug-bash@gnu.org; Tue, 04 Apr 2017 17:09:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <nesrovnal.tomas@gmail.com>) id 1cvVhq-0004WV-1b
	for bug-bash@gnu.org; Tue, 04 Apr 2017 17:09:38 -0400
Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:35302)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <nesrovnal.tomas@gmail.com>)
	id 1cvVhp-0004WA-Qr
	for bug-bash@gnu.org; Tue, 04 Apr 2017 17:09:37 -0400
Received: by mail-wr0-x22a.google.com with SMTP id k6so219648351wre.2
	for <bug-bash@gnu.org>; Tue, 04 Apr 2017 14:09:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:sender:from:date:message-id:subject:to:cc;
	bh=hBTib8jRTPh69lgIsA5KLFkKu7e1IbpD2VfmNKSvk8w=;
	b=PHM8tdJWyvEJwRJBt1oAX8Biyc14WD0NilPFwnUt0YUcF58KLlJTqDMVeilxGE5FL3
	35UgY2P/yuyEyEBE9e01YVUmMdkZzjL7TALniIp/vTBfSh6wwieINXJm0j5niOTmRxoc
	OCyLB8gOevVhM+Ykid/GT59xx4Fr45fPOrFbPq2L86AoUNPfgLsprFV5exuFm91lHdeP
	rO4p0NjbZAbMEbhPeLwANWE+tIs2bK2fgaZpKX4w3JtlSUk/K38COdZ4OmUEBGSch0Mb
	61i+rVwfpglmLSO9ZI3y5IBRJfiPlnikVbabgvjlv6WWk4DMDqB0p/yaaF8/0s4irYzn
	THxw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:sender:from:date:message-id:subject
	:to:cc;
	bh=hBTib8jRTPh69lgIsA5KLFkKu7e1IbpD2VfmNKSvk8w=;
	b=XBbVX8fO5BBHssD5GGlKR2IOf1K/RLnZVkV2FY61G+aBirqf03weDbd8epr3BXZcIY
	cX28hNxBxY37yxZKg8OD0iaBKZ2q9ovU7/NMGxsDwyyJy0ZwvIFyplZNpvehTAM9TWsS
	SEsYV48uKT+7z/iMfE1awWnTLIroNSA5Nk1AiQxsdY/PvSI6TtQ7Ha2Oh6phR/wnMsDV
	OQOCOzQBCXl7o4GZWgWwZnHaKVm8R+BOZSf6Y80sIDhEf/Wd9pXFSYflbkPHLXbjuwfB
	4xZgbeF41z0rIc+kZ7ysC3dUiVbeMFUQNNcm5aR6fOQ8YIcH+EgbimoycvR3rNkmHQ+U
	Vzvw==
X-Gm-Message-State: AFeK/H0jM+ANZL6GDMAJgqZ/mizP5JDPPnwAi9FSRY9IHGKKwpLW9oV61p22MBprdbCrmK0D8aU/XpyW46ZXGQ==
X-Received: by 10.223.171.179 with SMTP id s48mr21275986wrc.167.1491340176749; 
	Tue, 04 Apr 2017 14:09:36 -0700 (PDT)
MIME-Version: 1.0
Sender: nesrovnal.tomas@gmail.com
Received: by 10.28.66.216 with HTTP; Tue, 4 Apr 2017 14:08:56 -0700 (PDT)
From: nesro <nesro@nesro.cz>
Date: Tue, 4 Apr 2017 23:08:56 +0200
X-Google-Sender-Auth: Kn65GwEifrUjGvAxckfB-ltVvtE
Message-ID: <CAF3Cqmtb83RV4vdMVi4Kb45OiL6UKMeUgodgMsuOdq2pDodvDg@mail.gmail.com>
Subject: Re: while loop with extdebug + debug trap always returning 1
To: martijn@inlv.org
Cc: bug-bash@gnu.org
Content-Type: multipart/alternative; boundary=001a113c5b20797e1e054c5db177
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2a00:1450:400c:c0c::22a
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 04 Apr 2017 21:09:40 -0000

--001a113c5b20797e1e054c5db177
Content-Type: text/plain; charset=UTF-8

Hi Martin,
thanks for reply.

> > # run an empty for cycle. we can see from the output that bash ran :,
then
> > # false and stopped to it. which is the right behavior
> > for (( :; false; )); do :; done
>
> This is a syntax error. 'for' takes arithmetic expressions, not shell
> commands.

Sorry, my bad. I just wanted to make the command as simple as possible to
demonstrate the order of execution and I didn't notice that I got into an
invalid command. It's the same with this, valid, command:

for (( ; 1 > 2; )); do :; done


> > # now run this while cycle. it just cycle the debug trap forever
> > while false; do :; done

> The 'false' command is never executed so never has the chance to return
> an exit status of "false" (1).

To have both commands similar, let's assume the while as this:

while (( 1 > 2 )); do :; done

Thanks for explaining me why it happen, but now I don't know why for cycle
works and while does not.

The for cycle run the condition (after setting: t() { return 1; }; trap t
DEBUG; shopt -s extdebug)

bash-4.3$ for (( ; 1 > 2; )); do :; done
+ (( 1 ))
++ t
++ return 1
+ (( 1 > 2 ))
++ t
++ return 1

but the while cycle does not:

bash-4.3$ while (( 1 > 2 )); do :; done
++ t
++ return 1
++ t
++ return 1
.. loop forever ..


Is there any workaround to achieve the functionality I want? That is:
Prevent execution of everything by default. I will decide what to run by
using eval from the debug trap.

Thanks,
Tomas

--001a113c5b20797e1e054c5db177
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi Martin,</div><div>thanks for reply.</div><div><br>=
</div><div>&gt; &gt; # run an empty for cycle. we can see from the output t=
hat bash ran :, then</div><div>&gt; &gt; # false and stopped to it. which i=
s the right behavior</div><div>&gt; &gt; for (( :; false; )); do :; done</d=
iv><div>&gt;</div><div>&gt; This is a syntax error. &#39;for&#39; takes ari=
thmetic expressions, not shell</div><div>&gt; commands.</div><div><br></div=
><div>Sorry, my bad. I just wanted to make the command as simple as possibl=
e to</div><div>demonstrate the order of execution and I didn&#39;t notice t=
hat I got into an</div><div>invalid command. It&#39;s the same with this, v=
alid, command:</div><div><br></div><div>for (( ; 1 &gt; 2; )); do :; done</=
div><div><br></div><div><br></div><div>&gt; &gt; # now run this while cycle=
. it just cycle the debug trap forever</div><div>&gt; &gt; while false; do =
:; done</div><div><br></div><div>&gt; The &#39;false&#39; command is never =
executed so never has the chance to return</div><div>&gt; an exit status of=
 &quot;false&quot; (1).</div><div><br></div><div>To have both commands simi=
lar, let&#39;s assume the while as this:</div><div><br></div><div>while (( =
1 &gt; 2 )); do :; done</div><div><br></div><div>Thanks for explaining me w=
hy it happen, but now I don&#39;t know why for cycle</div><div>works and wh=
ile does not.</div><div><br></div><div>The for cycle run the condition (aft=
er setting: t() { return 1; }; trap t DEBUG; shopt -s extdebug)</div><div><=
br></div><div>bash-4.3$ for (( ; 1 &gt; 2; )); do :; done</div><div>+ (( 1 =
))</div><div>++ t</div><div>++ return 1</div><div>+ (( 1 &gt; 2 ))</div><di=
v>++ t</div><div>++ return 1</div><div><br></div><div>but the while cycle d=
oes not:</div><div><br></div><div>bash-4.3$ while (( 1 &gt; 2 )); do :; don=
e</div><div>++ t</div><div>++ return 1</div><div>++ t</div><div>++ return 1=
</div><div>.. loop forever ..</div><div><br></div><div><br></div><div>Is th=
ere any workaround to achieve the functionality I want? That is:</div><div>=
Prevent execution of everything by default. I will decide what to run by</d=
iv><div>using eval from the debug trap.</div><div><br></div><div>Thanks,</d=
iv><div>Tomas</div>
</div>

--001a113c5b20797e1e054c5db177--


From MAILER-DAEMON Tue Apr 04 19:54:35 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cvYHT-0007kd-7J
	for mharc-bug-bash@gnu.org; Tue, 04 Apr 2017 19:54:35 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53450)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cvYHQ-0007kV-Ej
	for bug-bash@gnu.org; Tue, 04 Apr 2017 19:54:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cvYHP-0004M5-St
	for bug-bash@gnu.org; Tue, 04 Apr 2017 19:54:32 -0400
Received: from mail-oi0-x234.google.com ([2607:f8b0:4003:c06::234]:34590)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <grishalevit@gmail.com>)
	id 1cvYHP-0004Kr-Mx
	for bug-bash@gnu.org; Tue, 04 Apr 2017 19:54:31 -0400
Received: by mail-oi0-x234.google.com with SMTP id d2so49089079oig.1
	for <bug-bash@gnu.org>; Tue, 04 Apr 2017 16:54:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=mWySwuTddCmruMHShNTn+gMvPgC8lrr7qXrK0J2qO6Y=;
	b=co3Dq+J52MS0sBfh1Hz0WarMZnYfx7SprmB8x5ceef819LWqmZTJrzaExi+avCGtSy
	XiGkRkJn0omU5gBC9KdVH/LzGuHdo3IFtXdH9xDrerXbchq2YvaarkyXC1cRk9nFZtnX
	TyTGJSWJYKrluOWwgkQJLeo8RtjpDGTQ9Cr4fdwEJVLIVtHll3kjUlsS4JmEtu7Wn/BF
	yavXKYpmoUQUBb1EyN/694hPpMu+iv7uY496tLhM2fmrVLscdnwwwD96MShulAbz3E9+
	gP++1N/+03gI5X1SpIcsqTBhC9r6+fzoK3MV0ye+ZJs7Eapc0qGBEzO4jielaJBor55x
	lNhA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=mWySwuTddCmruMHShNTn+gMvPgC8lrr7qXrK0J2qO6Y=;
	b=ZCb9ksXUGZSUDuW/ZHmoYuzUncuh5/lU7SyoHUzSEBybpogC+NGtymkNcKEXMiauzy
	JozGqYIICNFGR0VM5cfyJ3dGHtiIKX1cL1TOhB+TDkWADbAPad9Ck3Xe8zFLz+N2nA94
	EE2czHrtK1c14Pvn7p+hD6fdr+X2yimIsu177Mo3/trDpL99tDcdQl45oawsktbVlAbm
	pZhHY7fQSOL5okD/XA3yfJmil21i2tVBsjF7ZU8rIryCHpOs+gXJan98eB80eLCnCNYA
	pgmeA4Oc+dTrzuE+fAD1mDBbRnuHBQKD+ZbexFSk8Xvi2ui4q23ZKQB3bar91S2oMg/J
	K5XA==
X-Gm-Message-State: AFeK/H2d3QNrrBIXKj2TGarcb+qP5Y3h9MqOsVAeDBQIZ9//mq/fjsLjrC7rvPBCTdYwuV7c2uN8muTzTkaGFQ==
X-Received: by 10.202.48.19 with SMTP id w19mr11354744oiw.87.1491350070652;
	Tue, 04 Apr 2017 16:54:30 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.6.133 with HTTP; Tue, 4 Apr 2017 16:54:10 -0700 (PDT)
From: Grisha Levit <grishalevit@gmail.com>
Date: Tue, 4 Apr 2017 19:54:10 -0400
Message-ID: <CAMu=Bro5g-_YRMjaOBbhDnqCR32vJNuyj0tRyx7tBePf1_hEbw@mail.gmail.com>
Subject: segfault evaluating [[ $@ ]] when IFS is \t or \n and $1 == $IFS
To: bug-bash <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4003:c06::234
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 04 Apr 2017 23:54:33 -0000

Given:

set -- $'\t'; IFS=$1 A=$1   # or set -- $'\n'

These all segfault (in different places with -DDEBUG)

: ${x-$@}
[[ $@ ]]
: ${x-${A[@]}}
[[ ${A[@]} ]]


From MAILER-DAEMON Thu Apr 06 10:15:55 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cw8CZ-0002ax-9e
	for mharc-bug-bash@gnu.org; Thu, 06 Apr 2017 10:15:55 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43170)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stephane.chazelas@gmail.com>) id 1cw8CX-0002Zz-Az
	for bug-bash@gnu.org; Thu, 06 Apr 2017 10:15:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stephane.chazelas@gmail.com>) id 1cw8CU-00052N-4F
	for bug-bash@gnu.org; Thu, 06 Apr 2017 10:15:53 -0400
Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:34987)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <stephane.chazelas@gmail.com>)
	id 1cw8CT-00051i-UF
	for bug-bash@gnu.org; Thu, 06 Apr 2017 10:15:50 -0400
Received: by mail-wr0-x22b.google.com with SMTP id o21so36392497wrb.2
	for <bug-bash@gnu.org>; Thu, 06 Apr 2017 07:15:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=date:from:to:subject:message-id:mime-version:content-disposition
	:content-transfer-encoding:user-agent;
	bh=kJhauFsS/kXmunJzYWqV9z7BsxvJ938irFzQO1eQnfY=;
	b=HOCt4/3ZceYLUy83LZOR03P0GtZNExkwtNrVqZcdw0tjji5eHyimmnUHUhAlu0VjhB
	Gq0NB5R4lIlRLjUjbqEfB4aSo5sVWLQV85Hu9evrUIxCIwknnTuXZXWIeBhizQHkEkYA
	08rdghhDxISlbhET1uza/4TS0iLcGN1Xk9uIPafeqmMMNdNZP6bvogfU3bIHLihLO7v+
	p4XmAp3YdExpHpHyRfRzwPlzUmagYtyMvbND3pqvGbSPsfpV4uIeyrR75R5mw7TQozoG
	ouU/4xe2Di5evD/IMdaD6TeV8Fa69tC8c63rrBSwZMc9Az3iO7HO20fCholJf1mKKkXs
	qN5A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:date:from:to:subject:message-id:mime-version
	:content-disposition:content-transfer-encoding:user-agent;
	bh=kJhauFsS/kXmunJzYWqV9z7BsxvJ938irFzQO1eQnfY=;
	b=uAYVvrcf5LolbwsixnOOYOudMVlOLSQ45o7Fyd54EuKDLBwVX993M3pMXvVPBKNpYC
	pjusvrChjYw0MLTyvf8BeWfEfck/SQrfD7qMlkdb1L0loTVZ6v2AB0FB75HeSCoJSP5h
	+QtxqLqIEizfGHurXo2B74Cxnpzr261hm21x+rhERiq8Y/nO03WauZiWXn6rROixRF4I
	qaw6685/A2cWwyLpdFMbNK8PD6E09A7eTKOQt9IyVyaD5iLCJgh5xw0364Ky7NwCTK6z
	2b3wLAXhFrRoPqaalblv0hgJSmwPuPFaQyNisCKWdM8EkyZnQDbFJz852AV8EsCX7r7m
	TsDw==
X-Gm-Message-State: AFeK/H2lSUSFmJ5uBbGtSxwc/Hu5MXcWv91ZYY8Z1Ha/bNo3jenlmPFvb540mfK0wpXOYw==
X-Received: by 10.223.142.45 with SMTP id n42mr6317026wrb.131.1491488148344;
	Thu, 06 Apr 2017 07:15:48 -0700 (PDT)
Received: from chaz.gmail.com ([2.121.21.49]) by smtp.gmail.com with ESMTPSA id
	m90sm2589779wmi.34.2017.04.06.07.15.46 for <bug-bash@gnu.org>
	(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
	Thu, 06 Apr 2017 07:15:47 -0700 (PDT)
Date: Thu, 6 Apr 2017 15:15:46 +0100
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: bug-bash@gnu.org
Subject: read -N and UTF-8 characters
Message-ID: <20170406141546.GA7802@chaz.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
User-Agent: Mutt/1.5.24 (2015-08-30)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2a00:1450:400c:c0c::22b
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 06 Apr 2017 14:15:54 -0000

Using "read -N" on text containing multi-byte characters
produces incorrect result.

On Debian amd64 with the latest code from git:

$ locale charmap
UTF-8
$ printf '\ue9VWXYZ' | ./bash -c 'IFS= read -rN4 a; printf %s "$a"' | hd
00000000  c3 58 a9 56 57                                    |.X.VW|
00000005

(expected c3 a9 56 57 58)

$ ./bash --version
GNU bash, version 4.4.12(6)-maint (x86_64-unknown-linux-gnu)
[...]

It seems to be a regression (since 4.3). It was working OK with 4.2

-- 
Stephane


From MAILER-DAEMON Thu Apr 06 10:37:12 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cw8XA-0004MG-5C
	for mharc-bug-bash@gnu.org; Thu, 06 Apr 2017 10:37:12 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:45405)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <emlyn.jose@wipro.com>) id 1cw3ay-0007pu-KO
	for bug-bash@gnu.org; Thu, 06 Apr 2017 05:20:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <emlyn.jose@wipro.com>) id 1cw3av-00076P-A7
	for bug-bash@gnu.org; Thu, 06 Apr 2017 05:20:48 -0400
Received: from mail-pu1apc01on0078.outbound.protection.outlook.com
	([104.47.126.78]:6848
	helo=APC01-PU1-obe.outbound.protection.outlook.com)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <emlyn.jose@wipro.com>)
	id 1cw3au-00075l-LI
	for bug-bash@gnu.org; Thu, 06 Apr 2017 05:20:45 -0400
Received: from HKNPR03MB2308.apcprd03.prod.outlook.com (10.141.36.156) by
	HKNPR03MB2307.apcprd03.prod.outlook.com (10.141.36.155) with Microsoft
	SMTP Server (version=TLS1_2,
	cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id
	15.1.1019.8; Thu, 6 Apr 2017 07:47:35 +0000
Received: from HKNPR03MB2308.apcprd03.prod.outlook.com
	([fe80::e96d:4bf9:f1a8:d59a]) by
	HKNPR03MB2308.apcprd03.prod.outlook.com
	([fe80::e96d:4bf9:f1a8:d59a%15]) with mapi id 15.01.1019.021;
	Thu, 6 Apr 2017 07:47:35 +0000
From: "emlyn.jose@wipro.com" <emlyn.jose@wipro.com>
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
Subject: bash 4.4 null byte warning!!
Thread-Topic: bash 4.4 null byte warning!!
Thread-Index: AdKuqgsprHS+cCb0SAaOroTOd0ADog==
Date: Thu, 6 Apr 2017 07:47:35 +0000
Message-ID: <HKNPR03MB230809726ED57A0E4D87015C880D0@HKNPR03MB2308.apcprd03.prod.outlook.com>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: gnu.org; dkim=none (message not signed)
	header.d=none;gnu.org; dmarc=none action=none header.from=wipro.com;
x-originating-ip: [194.157.154.68]
x-microsoft-exchange-diagnostics: 1; HKNPR03MB2307;
	7:DrOcAGga6bwmfAvhtjmApd9sWNGhYDym+3Fo1JqfoU+aO42LTkE50eVgL0tz08AhyGLT7r6WNUCrNsf87qW2WzzleoQeCCPPCbWvDbQ5uehasDxr6DF+3SNy+vRAqcdwdHDsNqqeIvTG0CUG4F1B+pUxhB4139YWnYyyLHqMSjMM5pejfgCg7VYE9mZZ2Q9iPP76OKH8mGduAvKwLebOVHbRhIpr2D093+wpS5dwFBtHtTmHbL+0RqlRIFhmHLyne8iZSJ7SDe8nPMe71mEdqdCCx8W4CwcAUDSskdArfSk5cwA1EEr84wCZYAMvgLHPW/6gRyaGQhBEAkE3V+lNUw==
x-ms-office365-filtering-correlation-id: e1ea3f9c-29f2-40da-414d-08d47cc130d7
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: UriScan:; BCL:0; PCL:0;
	RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075);
	SRVR:HKNPR03MB2307; 
x-microsoft-antispam-prvs: <HKNPR03MB23079F810810B4444336454A880D0@HKNPR03MB2307.apcprd03.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(267259832677123)(22074186197030)(62627912741753)(21748063052155);
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0;
	RULEID:(61425038)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(6072148);
	SRVR:HKNPR03MB2307; BCL:0; PCL:0; RULEID:; SRVR:HKNPR03MB2307; 
x-forefront-prvs: 02698DF457
x-forefront-antispam-report: SFV:NSPM;
	SFS:(10009020)(39400400002)(39410400002)(39450400003)(39850400002)(39860400002)(39840400002)(8676002)(8936002)(189998001)(5890100001)(50986999)(7906003)(5640700003)(81166006)(54356999)(7736002)(5630700001)(53936002)(25786009)(15974865002)(86362001)(2351001)(74316002)(226693001)(9326002)(236005)(2906002)(3280700002)(55016002)(33656002)(102836003)(6116002)(99286003)(16297215004)(790700001)(3846002)(2501003)(606005)(5250100002)(2900100001)(66066001)(6436002)(54896002)(7696004)(6306002)(5660300001)(6506006)(3660700001)(110136004)(38730400002)(9686003)(6916009)(966004)(568214009)(225543005);
	DIR:OUT; SFP:1101; SCL:1; SRVR:HKNPR03MB2307;
	H:HKNPR03MB2308.apcprd03.prod.outlook.com; FPR:; SPF:None;
	MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; 
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/alternative;
	boundary="_000_HKNPR03MB230809726ED57A0E4D87015C880D0HKNPR03MB2308apcp_"
MIME-Version: 1.0
X-OriginatorOrg: wipro.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Apr 2017 07:47:35.4597 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 258ac4e4-146a-411e-9dc8-79a9e12fd6da
X-MS-Exchange-Transport-CrossTenantHeadersStamped: HKNPR03MB2307
X-MS-Exchange-CrossPremises-AuthAs: Internal
X-MS-Exchange-CrossPremises-AuthMechanism: 03
X-MS-Exchange-CrossPremises-AuthSource: HKNPR03MB2308.apcprd03.prod.outlook.com
X-MS-Exchange-CrossPremises-SCL: 1
X-MS-Exchange-CrossPremises-messagesource: StoreDriver
X-MS-Exchange-CrossPremises-BCC: 
X-MS-Exchange-CrossPremises-originalclientipaddress: 194.157.154.68
X-MS-Exchange-CrossPremises-avstamp-service: 1.0
X-MS-Exchange-CrossPremises-disclaimer-hash: ef6ed6a830673538406bd527e716551fd2daba1e446b50e7f1f30c79ce70f874
X-MS-Exchange-CrossPremises-antispam-scancontext: DIR:Originating; SFV:NSPM;
	SKIP:0; 
X-MS-Exchange-CrossPremises-processed-by-journaling: Journal Agent
X-OrganizationHeadersPreserved: HKNPR03MB2307.apcprd03.prod.outlook.com
X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy]
X-Received-From: 104.47.126.78
X-Mailman-Approved-At: Thu, 06 Apr 2017 10:37:10 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 06 Apr 2017 09:20:50 -0000

--_000_HKNPR03MB230809726ED57A0E4D87015C880D0HKNPR03MB2308apcp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi,

We are trying to use the bash 4.4 downloaded from http://ftp.gnu.org/gnu/ba=
sh/ on our RHEL 6.2 machine.
But while using a script that has this command :
FIND_RPM=3D`find /opt/RPM/components -type d -name enum-1.1.6 -print0`
It throws a warning as below:

bash: warning: command substitution: ignored null byte in input


Is there any patch available for this or is there any way to make bash sile=
ntly drop this warning(which has been the behavior on the lower versions of=
 bash)??

We cannot find this new bash version on the Redhat Portal.

Regards,
Emlyn Jose
Wipro Technologies
The information contained in this electronic message and any attachments to=
 this message are intended for the exclusive use of the addressee(s) and ma=
y contain proprietary, confidential or privileged information. If you are n=
ot the intended recipient, you should not disseminate, distribute or copy t=
his e-mail. Please notify the sender immediately and destroy all copies of =
this message and any attachments. WARNING: Computer viruses can be transmit=
ted via email. The recipient should check this email and any attachments fo=
r the presence of viruses. The company accepts no liability for any damage =
caused by any virus transmitted by this email. www.wipro.com

--_000_HKNPR03MB230809726ED57A0E4D87015C880D0HKNPR03MB2308apcp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
pre
	{mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted";
	font-family:"Courier New";}
span.pln
	{mso-style-name:pln;}
span.pun
	{mso-style-name:pun;}
span.lit
	{mso-style-name:lit;}
span.kwd
	{mso-style-name:kwd;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hi,<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">We are trying to use the bash 4.4 downloaded from <a=
 href=3D"http://ftp.gnu.org/gnu/bash/">
http://ftp.gnu.org/gnu/bash/</a> on our RHEL 6.2 machine.<o:p></o:p></p>
<p class=3D"MsoNormal">But while using a script that has this command : <o:=
p></o:p></p>
<p class=3D"MsoNormal" style=3D"background:#EFF0F1"><span style=3D"font-siz=
e:10.0pt;font-family:Consolas;color:#303336;border:none windowtext 1.0pt;pa=
dding:0in;background:#EFF0F1">FIND_RPM=3D`find /opt/RPM/components -type d =
-name enum-</span><span style=3D"font-size:10.0pt;font-family:Consolas;colo=
r:#7D2727;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">1.1<=
/span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#303336;bo=
rder:none windowtext 1.0pt;padding:0in;background:#EFF0F1">.</span><span st=
yle=3D"font-size:10.0pt;font-family:Consolas;color:#7D2727;border:none wind=
owtext 1.0pt;padding:0in;background:#EFF0F1">6</span><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:#303336;border:none windowtext 1.0pt;p=
adding:0in;background:#EFF0F1">
 -print0`</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:=
#393318"><o:p></o:p></span></p>
<p class=3D"MsoNormal">It throws a warning as below:<o:p></o:p></p>
<pre style=3D"background:#EFF0F1"><span class=3D"pln"><span style=3D"font-f=
amily:Consolas;color:#303336;border:none windowtext 1.0pt;padding:0in;backg=
round:#EFF0F1">bash</span></span><span class=3D"pun"><span style=3D"font-fa=
mily:Consolas;color:#303336;border:none windowtext 1.0pt;padding:0in;backgr=
ound:#EFF0F1">:</span></span><span class=3D"pln"><span style=3D"font-family=
:Consolas;color:#303336;border:none windowtext 1.0pt;padding:0in;background=
:#EFF0F1"> warning</span></span><span class=3D"pun"><span style=3D"font-fam=
ily:Consolas;color:#303336;border:none windowtext 1.0pt;padding:0in;backgro=
und:#EFF0F1">:</span></span><span class=3D"pln"><span style=3D"font-family:=
Consolas;color:#303336;border:none windowtext 1.0pt;padding:0in;background:=
#EFF0F1"> command substitution</span></span><span class=3D"pun"><span style=
=3D"font-family:Consolas;color:#303336;border:none windowtext 1.0pt;padding=
:0in;background:#EFF0F1">:</span></span><span class=3D"pln"><span style=3D"=
font-family:Consolas;color:#303336;border:none windowtext 1.0pt;padding:0in=
;background:#EFF0F1"> ignored null byte </span></span><span class=3D"kwd"><=
span style=3D"font-family:Consolas;color:#101094;border:none windowtext 1.0=
pt;padding:0in;background:#EFF0F1">in</span></span><span class=3D"pln"><spa=
n style=3D"font-family:Consolas;color:#303336;border:none windowtext 1.0pt;=
padding:0in;background:#EFF0F1"> input</span></span><span style=3D"font-fam=
ily:Consolas;color:#393318"><o:p></o:p></span></pre>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Is there any patch available for this or is there an=
y way to make bash silently drop this warning(which has been the behavior o=
n the lower versions of bash)??<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">We cannot find this new bash version on the Redhat P=
ortal.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Regards,<o:p></o:p></p>
<p class=3D"MsoNormal">Emlyn Jose<o:p></o:p></p>
<p class=3D"MsoNormal">Wipro Technologies<o:p></o:p></p>
</div>
The information contained in this electronic message and any attachments to=
 this message are intended for the exclusive use of the addressee(s) and ma=
y contain proprietary, confidential or privileged information. If you are n=
ot the intended recipient, you should
 not disseminate, distribute or copy this e-mail. Please notify the sender =
immediately and destroy all copies of this message and any attachments. WAR=
NING: Computer viruses can be transmitted via email. The recipient should c=
heck this email and any attachments
 for the presence of viruses. The company accepts no liability for any dama=
ge caused by any virus transmitted by this email. www.wipro.com
</body>
</html>

--_000_HKNPR03MB230809726ED57A0E4D87015C880D0HKNPR03MB2308apcp_--


From MAILER-DAEMON Thu Apr 06 10:46:00 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cw8fg-0003NU-Jl
	for mharc-bug-bash@gnu.org; Thu, 06 Apr 2017 10:46:00 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:56663)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1cw8fd-0003ND-Pf
	for bug-bash@gnu.org; Thu, 06 Apr 2017 10:45:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1cw8fa-0003az-Oq
	for bug-bash@gnu.org; Thu, 06 Apr 2017 10:45:57 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:38700 helo=svr4.eeg.ccf.org)
	by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1cw8fa-00038E-Ii
	for bug-bash@gnu.org; Thu, 06 Apr 2017 10:45:54 -0400
Received: (qmail 36152 invoked from network); 6 Apr 2017 14:45:24 -0000
Received: from imadev.eeg.ccf.org (qmailr@10.76.173.78)
	by gateway.eeg.ccf.org with SMTP; Thu, 06 Apr 2017 10:45:24 -0400
Received: (qmail 5512 invoked by uid 563); 6 Apr 2017 14:45:24 -0000
Date: Thu, 6 Apr 2017 10:45:24 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: "emlyn.jose@wipro.com" <emlyn.jose@wipro.com>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Subject: Re: bash 4.4 null byte warning!!
Message-ID: <20170406144523.GO17132@eeg.ccf.org>
References: <HKNPR03MB230809726ED57A0E4D87015C880D0@HKNPR03MB2308.apcprd03.prod.outlook.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <HKNPR03MB230809726ED57A0E4D87015C880D0@HKNPR03MB2308.apcprd03.prod.outlook.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 139.137.100.1
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 06 Apr 2017 14:45:58 -0000

On Thu, Apr 06, 2017 at 07:47:35AM +0000, emlyn.jose@wipro.com wrote:
> FIND_RPM=`find /opt/RPM/components -type d -name enum-1.1.6 -print0`
> It throws a warning as below:
> 
> bash: warning: command substitution: ignored null byte in input

Your command is broken, and bash is warning you of this.  Why do you want
to silence the warning instead of fixing the command?

If your find returns a single result, you get a filename followed by NUL,
and the NUL is discarded, leaving you a filename inside the command
substitution (and therefore the variable).  You could achieve the EXACT
same result by dropping the -print0.  Then, if you get a single result
from find, you get the filename followed by newline, and the command
substitution discards the trailing newline, leaving you just the filename
in the command substitution and therefore the variable.

On the other hand, if your find command returns MULTIPLE results, then
you have file1\000file2\000 and the command substitution drops the NUL
bytes, leaving you with file1file2 in your variable.  At least if you
dropped the -print0 you would have file1\nfile2 in your variable, which
is still wrong, but not as wrong as file1file2.

> Is there any patch available for this or is there any way to make bash silently drop this warning(which has been the behavior on the lower versions of bash)??

If you REALLY want to continue to run a broken command, you can explicitly
use tr to remove the NULs before the command substitution ever sees
them.

var=$(find ... -print0 | tr -d '\0')

That will prevent the warning and allow you to continue running a broken
script without letting your coworkers catch on to the bugs (or whatever
your issue with the warning is).

If you actually want to FIX the script, the results of find should be
read into an array, since there can be more than one.  Every place you
use your variable currently, you'd have to rewrite that to handle an
array with potentially multiple elements.


From MAILER-DAEMON Fri Apr 07 19:01:19 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cwcsY-0000aE-SE
	for mharc-bug-bash@gnu.org; Fri, 07 Apr 2017 19:01:18 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47299)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwcsW-0000Z6-LJ
	for bug-bash@gnu.org; Fri, 07 Apr 2017 19:01:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwcsR-00010f-Rr
	for bug-bash@gnu.org; Fri, 07 Apr 2017 19:01:16 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:63715
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cwcsR-000107-NK
	for bug-bash@gnu.org; Fri, 07 Apr 2017 19:01:11 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMJ49954; Fri, 07 Apr 2017 19:01:09 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GVT99769 (AUTH cpr);
	Fri, 07 Apr 2017 19:01:09 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: segfault evaluating [[ $@ ]] when IFS is \t or \n and $1 == $IFS
To: Grisha Levit <grishalevit@gmail.com>, bug-bash <bug-bash@gnu.org>
References: <CAMu=Bro5g-_YRMjaOBbhDnqCR32vJNuyj0tRyx7tBePf1_hEbw@mail.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <0d7486cd-b65b-06ed-3900-0ff83e80458b@case.edu>
Date: Fri, 7 Apr 2017 19:01:07 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <CAMu=Bro5g-_YRMjaOBbhDnqCR32vJNuyj0tRyx7tBePf1_hEbw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.7.222118:17:7.944, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __STOCK_PHRASE_7,
	__OEM_PRICE, __FRAUD_MONEY_CURRENCY_DOLLAR,
	__SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG,
	__FORWARDED_MSG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_500_599,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Fri, 07 Apr 2017 23:01:17 -0000

On 4/4/17 7:54 PM, Grisha Levit wrote:
> Given:
> 
> set -- $'\t'; IFS=$1 A=$1   # or set -- $'\n'
> 
> These all segfault (in different places with -DDEBUG)
> 
> : ${x-$@}
> [[ $@ ]]
> : ${x-${A[@]}}
> [[ ${A[@]} ]]

Thanks for the report.  This was a little bit tricker to fix than I thought
it would be.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Fri Apr 07 19:43:33 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cwdXQ-0007nE-Ue
	for mharc-bug-bash@gnu.org; Fri, 07 Apr 2017 19:43:32 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53651)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwdXO-0007ml-9X
	for bug-bash@gnu.org; Fri, 07 Apr 2017 19:43:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwdXJ-0005za-DN
	for bug-bash@gnu.org; Fri, 07 Apr 2017 19:43:30 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:2171
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cwdXJ-0005zL-7Z
	for bug-bash@gnu.org; Fri, 07 Apr 2017 19:43:25 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMJ50821; Fri, 07 Apr 2017 19:43:23 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GVU18459 (AUTH cpr);
	Fri, 07 Apr 2017 19:43:23 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu, bug-bash <bug-bash@gnu.org>
Subject: Re: splitting/whitespace in expansions of ${*} vs ${*/}
To: Grisha Levit <grishalevit@gmail.com>
References: <CAMu=BrpnD7tEB72+ik+92aGq6hk4iSZqR6uE8mdNyriwXd+4Nw@mail.gmail.com>
	<1944099d-0d99-8499-8151-188c21748e7b@case.edu>
	<CAMu=BroRYpKKNcye9Hu9CcoPQHpJZfXU8bu9Jsq9To8zA9yCCg@mail.gmail.com>
	<d42a1794-6d1d-b69b-fa88-84a676ae1533@case.edu>
	<CAMu=BrovBftEfwDBzBkiPndOYA9cpjMaGttwEEmnFXaLCn_Ugw@mail.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <e36fb5b7-20fd-d9c6-18b6-232975eba92e@case.edu>
Date: Fri, 7 Apr 2017 19:43:22 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <CAMu=BrovBftEfwDBzBkiPndOYA9cpjMaGttwEEmnFXaLCn_Ugw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.7.232117:17:8.317, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2,
	__CC_NAME, __CC_NAME_DIFF_FROM_ACC,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_900_999, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY,
	BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Fri, 07 Apr 2017 23:43:31 -0000

On 4/4/17 3:29 PM, Grisha Levit wrote:
> There are a few small regressions in the latest devel relative to the
> previous two commits but they're all rather exotic. Again, sorry if this
> is still WIP/too minor:
> 
> CTLESC present in output (even with default IFS)
> 
>    $ set -- 1; unset var; printf ${var-${*:1}} | xxd
>    00000000: 0131                                     .1
> 
>    $ set -- 1; unset var; : ${var=${*:1}}; printf "$var" | xxd
>    00000000: 0131                                     .1
> 
> Not splitting (with default IFS):
> 
>    $ set -- '1 1'; unset a b; printf '<%s>' ${a=$*} ${b=${*:1}}
>    <1><1><1 1>

Thanks, these are fixed.
> 
> A few more cases below:

I'll look at these.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Fri Apr 07 21:06:34 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cwepl-0000qu-UY
	for mharc-bug-bash@gnu.org; Fri, 07 Apr 2017 21:06:33 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39334)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwepk-0000qX-0o
	for bug-bash@gnu.org; Fri, 07 Apr 2017 21:06:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwepi-0006wF-UE
	for bug-bash@gnu.org; Fri, 07 Apr 2017 21:06:32 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:50381
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>)
	id 1cwepf-0006vT-8c; Fri, 07 Apr 2017 21:06:27 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALE74539; Fri, 07 Apr 2017 21:06:22 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GVU49280 (AUTH cpr);
	Fri, 07 Apr 2017 21:06:22 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu, bug-bash@gnu.org, Rocky Bernstein <rocky@gnu.org>
Subject: Re: while loop with extdebug + debug trap always returning 1
To: nesro <nesro@nesro.cz>, martijn@inlv.org
References: <CAF3Cqmtb83RV4vdMVi4Kb45OiL6UKMeUgodgMsuOdq2pDodvDg@mail.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <4f66b8f3-1e13-7be0-468d-f9e47d18ddd2@case.edu>
Date: Fri, 7 Apr 2017 21:06:14 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <CAF3Cqmtb83RV4vdMVi4Kb45OiL6UKMeUgodgMsuOdq2pDodvDg@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv4-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 08 Apr 2017 01:06:33 -0000

On 4/4/17 5:08 PM, nesro wrote:

> 
> To have both commands similar, let's assume the while as this:
> 
> while (( 1 > 2 )); do :; done
> 
> Thanks for explaining me why it happen, but now I don't know why for cycle
> works and while does not.
When extdebug is enabled, the command is skipped if the DEBUG trap returns
non-zero.  This doesn't change $? (traps never do) and it doesn't cause the
command that would have been run to return a non-zero exit status.  If it
did, the combination of DEBUG and `set -e' would exit the shell, for
example, and I'm sure it would not behave as the bash debugger would
expect.  For that matter, why should a command that's not run fail?

Since that command returns successfully, when it's used as the `while'
command test, it causes the while command to execute forever.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Fri Apr 07 22:18:11 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cwfx5-0001Vt-DA
	for mharc-bug-bash@gnu.org; Fri, 07 Apr 2017 22:18:11 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46844)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwfx3-0001Ue-Nt
	for bug-bash@gnu.org; Fri, 07 Apr 2017 22:18:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwfx0-0003sA-Js
	for bug-bash@gnu.org; Fri, 07 Apr 2017 22:18:09 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:53884
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cwfx0-0003s1-Ev
	for bug-bash@gnu.org; Fri, 07 Apr 2017 22:18:06 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALE75498; Fri, 07 Apr 2017 22:18:01 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GVU68162 (AUTH cpr);
	Fri, 07 Apr 2017 22:18:00 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: bash 4.4 null byte warning!!
To: "emlyn.jose@wipro.com" <emlyn.jose@wipro.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
References: <HKNPR03MB230809726ED57A0E4D87015C880D0@HKNPR03MB2308.apcprd03.prod.outlook.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <b83bed7f-4ed3-da27-fcc7-0a5dadfbc983@case.edu>
Date: Fri, 7 Apr 2017 22:17:59 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <HKNPR03MB230809726ED57A0E4D87015C880D0@HKNPR03MB2308.apcprd03.prod.outlook.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv4-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 08 Apr 2017 02:18:10 -0000

On 4/6/17 3:47 AM, emlyn.jose@wipro.com wrote:
> Hi,
> 
>  
> 
> We are trying to use the bash 4.4 downloaded from
> http://ftp.gnu.org/gnu/bash/ on our RHEL 6.2 machine.
> 
> But while using a script that has this command :
> 
> FIND_RPM=`find /opt/RPM/components -type d -name enum-1.1.6-print0`
> 
> It throws a warning as below:
> 
> bash:warning:command substitution:ignored null byte ininput

Yes.  It drops the null bytes because C strings can't handle them.  I
received bug reports asking why bash silently transforms the command
substitution output and added the warning while not changing the behavior.

If you want to suppress the warning, you'll have to edit the source and
rebuild.

This does beg the question of why you're using -print0 without something
on the receiving end to handle the null bytes.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sat Apr 08 10:57:44 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cwro8-00007M-LF
	for mharc-bug-bash@gnu.org; Sat, 08 Apr 2017 10:57:44 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46794)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwro6-000077-RT
	for bug-bash@gnu.org; Sat, 08 Apr 2017 10:57:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwro2-0007OQ-Qf
	for bug-bash@gnu.org; Sat, 08 Apr 2017 10:57:42 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:51234
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cwro2-0007Nu-LN
	for bug-bash@gnu.org; Sat, 08 Apr 2017 10:57:38 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMJ64053; Sat, 08 Apr 2017 10:57:36 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GVX56368 (AUTH cpr);
	Sat, 08 Apr 2017 10:57:35 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: read -N and UTF-8 characters
To: Stephane Chazelas <stephane.chazelas@gmail.com>, bug-bash@gnu.org
References: <20170406141546.GA7802@chaz.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <a43b8691-29d8-c007-b470-a5637f8bcaf9@case.edu>
Date: Sat, 8 Apr 2017 10:57:34 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <20170406141546.GA7802@chaz.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.8.141822:17:7.944, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME,
	__TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY,
	__URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_400_499,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, __SINGLE_URI_TEXT,
	SINGLE_URI_IN_BODY, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 08 Apr 2017 14:57:43 -0000

On 4/6/17 10:15 AM, Stephane Chazelas wrote:
> Using "read -N" on text containing multi-byte characters
> produces incorrect result.

Thanks for the report.  This will be fixed in the next devel branch push.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sat Apr 08 18:46:59 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cwz8F-0004Vj-N0
	for mharc-bug-bash@gnu.org; Sat, 08 Apr 2017 18:46:59 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47124)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwz8D-0004U6-An
	for bug-bash@gnu.org; Sat, 08 Apr 2017 18:46:59 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwz8A-0004m1-6T
	for bug-bash@gnu.org; Sat, 08 Apr 2017 18:46:57 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:18438
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cwz8A-0004li-0n
	for bug-bash@gnu.org; Sat, 08 Apr 2017 18:46:54 -0400
Received: from mpv8-2015.CWRU.Edu (EHLO mpv8-2015.case.edu) ([129.22.103.210])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMO91661; Sat, 08 Apr 2017 18:46:50 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv8-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GWJ72680 (AUTH cpr);
	Sat, 08 Apr 2017 18:46:49 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: another case from the case corner case casualty case files
To: Martijn Dekker <martijn@inlv.org>, bug-bash@gnu.org
References: <255d3725-e5d4-1274-551e-955701cbe5d9@inlv.org>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <fc738a7f-f0db-5d1b-586a-bc71f572bf58@case.edu>
Date: Sat, 8 Apr 2017 18:46:48 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <255d3725-e5d4-1274-551e-955701cbe5d9@inlv.org>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 08 Apr 2017 22:46:59 -0000

On 4/2/17 8:34 PM, Martijn Dekker wrote:
> $ x=$'\\a\\b\\c\\\001\\d\\e\\f'
> $ case $'abc\001def' in $x) echo ok ;; *) echo oops; esac
> oops
> $ x=$'\\a\\b\\c\\\002\\d\\e\\f'
> $ case $'abc\002def' in $x) echo ok ;; *) echo oops; esac
> ok

Thanks for the report.  This is another one that was tricky to fix.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sat Apr 08 18:48:35 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cwz9m-0004kV-VK
	for mharc-bug-bash@gnu.org; Sat, 08 Apr 2017 18:48:34 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47377)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rocky.bernstein@gmail.com>) id 1cwz9l-0004kP-2R
	for bug-bash@gnu.org; Sat, 08 Apr 2017 18:48:34 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rocky.bernstein@gmail.com>) id 1cwz9j-0005Mp-Ja
	for bug-bash@gnu.org; Sat, 08 Apr 2017 18:48:33 -0400
Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]:32836)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rocky.bernstein@gmail.com>)
	id 1cwz9j-0005Mf-E2
	for bug-bash@gnu.org; Sat, 08 Apr 2017 18:48:31 -0400
Received: by mail-oi0-x229.google.com with SMTP id b187so117633590oif.0
	for <bug-bash@gnu.org>; Sat, 08 Apr 2017 15:48:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:sender:in-reply-to:references:from:date:message-id
	:subject:to:cc;
	bh=UAqJXtQgt2NXWFtloKKbsmrbGl0iojn9yIJrMLAcTq8=;
	b=F/3MKQhy5Tn0BjYrrTnE0ic5nYeIgbHzA9pfFwzPvJ+gaUHqyqBnPxyGewNMGvDmK9
	YnEGMwTNU/ZrSK+4PkUS015KvAZPsMMNutvAQmQHXGKpuWP5Ass2J7cLlGQ7bloVLYCk
	p8AYpvMqWIhdikT26jEWPiQMHnOlg3DtFSDu8R6V1KYTv9U494pqA10JaEv/N1M4yoXa
	LOMUi+t1Fz0bdfEHodQ1JcQNlK1kwrsde0k631nyMHt4zXlhPE0qJK0Lq4CuFf1DUH5l
	XOQDiNioVpc6vGccfdamOeZi1DfaSFIpY+BXyWAgYHArsX+Ns14KJAsl+JpcvS+HHL7j
	j68g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
	:date:message-id:subject:to:cc;
	bh=UAqJXtQgt2NXWFtloKKbsmrbGl0iojn9yIJrMLAcTq8=;
	b=W7LEZCEO9YmY8lJuw31P/7V2gyaaB6pyzmx0P8iiwt058RUaWQFauuf/NpHxHJV9oP
	uiGg1VMq/rH/M+jI5IS4Dx3TmEAzEuvfQMhGl1Ph5zXfKBLw/xVL1CTqLbwJkbHAWJie
	psF7eUVmQlMXvHdaJZbTE0JhDZBxihiDntLqCX5Vv/xSjrOHg8GZUd9DuDWr5dmNMoZ4
	/XqUum15q2WDHHe05a5aFkZ9IhSXc3/MMjRtNGDyV72TfZo/TfzDLdNxfMuKi46D1dlD
	U+7CyPv6pLltvzMt/sJ1/1k/kRcwHSP2WwN7yUX+e326hO6cc39hHFbtQbVRJIfVDs/o
	ui/Q==
X-Gm-Message-State: AN3rC/4NoBVuhk1TusQMIgVLdoHYFXsHVQPk9nq/DiUv8U1wzWZcL7Bd4nGKhpd5CoqIB7HsMFg5zOOThCzTfQ==
X-Received: by 10.157.35.139 with SMTP id t11mr247679otb.42.1491691710320;
	Sat, 08 Apr 2017 15:48:30 -0700 (PDT)
MIME-Version: 1.0
Sender: rocky.bernstein@gmail.com
Received: by 10.74.144.205 with HTTP; Sat, 8 Apr 2017 15:48:29 -0700 (PDT)
In-Reply-To: <4f66b8f3-1e13-7be0-468d-f9e47d18ddd2@case.edu>
References: <CAF3Cqmtb83RV4vdMVi4Kb45OiL6UKMeUgodgMsuOdq2pDodvDg@mail.gmail.com>
	<4f66b8f3-1e13-7be0-468d-f9e47d18ddd2@case.edu>
From: Rocky Bernstein <rocky@gnu.org>
Date: Sat, 8 Apr 2017 18:48:29 -0400
X-Google-Sender-Auth: lWV0Cg9xhp6HWjO7jVKTL8sV_ZQ
Message-ID: <CANCp2gY1tqBNPhTHJgToS+w2bEJE1n0P+7G0mN3yvWP0a_YW7g@mail.gmail.com>
Subject: Re: while loop with extdebug + debug trap always returning 1
To: Chet Ramey <chet.ramey@case.edu>
Cc: nesro <nesro@nesro.cz>, martijn@inlv.org, bug-bash@gnu.org
Content-Type: multipart/alternative; boundary=001a1147ff94821794054caf8ac3
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4003:c06::229
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 08 Apr 2017 22:48:34 -0000

--001a1147ff94821794054caf8ac3
Content-Type: text/plain; charset=UTF-8

Thanks for giving me a heads up here. I have updated the bashdb
documentation for the skip command make clear that $? is no changed in
skipping an instruction.

More generally bash saves and restores some state on entry and exit to
extdebug, like the variable $? (the extdebug function can issue a command
which inside sets $? but on return $? I think is restored)

However there is other global state that isn't saved and restored. I think
this includes the set flags. I'm not sure that what gets saved and restored
is fully documented, but it probably should be.

On Fri, Apr 7, 2017 at 9:06 PM, Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/4/17 5:08 PM, nesro wrote:
>
> >
> > To have both commands similar, let's assume the while as this:
> >
> > while (( 1 > 2 )); do :; done
> >
> > Thanks for explaining me why it happen, but now I don't know why for
> cycle
> > works and while does not.
> When extdebug is enabled, the command is skipped if the DEBUG trap returns
> non-zero.  This doesn't change $? (traps never do) and it doesn't cause the
> command that would have been run to return a non-zero exit status.  If it
> did, the combination of DEBUG and `set -e' would exit the shell, for
> example, and I'm sure it would not behave as the bash debugger would
> expect.  For that matter, why should a command that's not run fail?
>
> Since that command returns successfully, when it's used as the `while'
> command test, it causes the while command to execute forever.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~
> chet/
>

--001a1147ff94821794054caf8ac3
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks for giving me a heads up here. I have updated the b=
ashdb documentation for the skip command make clear that $? is no changed i=
n skipping an instruction.<div><br></div><div>More generally bash saves and=
 restores some state on entry and exit to extdebug, like the variable $? (t=
he extdebug function can issue a command which inside sets $? but on return=
 $? I think is restored)=C2=A0</div><div><br></div><div>However there is ot=
her global state that isn&#39;t saved and restored. I think this includes t=
he set flags. I&#39;m not sure that what gets saved and restored is fully d=
ocumented, but it probably should be.=C2=A0</div></div><div class=3D"gmail_=
extra"><br><div class=3D"gmail_quote">On Fri, Apr 7, 2017 at 9:06 PM, Chet =
Ramey <span dir=3D"ltr">&lt;<a href=3D"mailto:chet.ramey@case.edu" target=
=3D"_blank">chet.ramey@case.edu</a>&gt;</span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">On 4/4/17 5:08 PM, nesro wrote:<br>
<br>
&gt;<br>
&gt; To have both commands similar, let&#39;s assume the while as this:<br>
&gt;<br>
&gt; while (( 1 &gt; 2 )); do :; done<br>
&gt;<br>
&gt; Thanks for explaining me why it happen, but now I don&#39;t know why f=
or cycle<br>
&gt; works and while does not.<br>
When extdebug is enabled, the command is skipped if the DEBUG trap returns<=
br>
non-zero.=C2=A0 This doesn&#39;t change $? (traps never do) and it doesn&#3=
9;t cause the<br>
command that would have been run to return a non-zero exit status.=C2=A0 If=
 it<br>
did, the combination of DEBUG and `set -e&#39; would exit the shell, for<br=
>
example, and I&#39;m sure it would not behave as the bash debugger would<br=
>
expect.=C2=A0 For that matter, why should a command that&#39;s not run fail=
?<br>
<br>
Since that command returns successfully, when it&#39;s used as the `while&#=
39;<br>
command test, it causes the while command to execute forever.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
``The lyf so short, the craft so long to lerne.&#39;&#39; - Chaucer<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0``Ars longa, =
vita brevis&#39;&#39; - Hippocrates<br>
Chet Ramey, UTech, CWRU=C2=A0 =C2=A0 <a href=3D"mailto:chet@case.edu">chet@=
case.edu</a>=C2=A0 =C2=A0 <a href=3D"http://cnswww.cns.cwru.edu/~chet/" rel=
=3D"noreferrer" target=3D"_blank">http://cnswww.cns.cwru.edu/~<wbr>chet/</a=
><br>
</font></span></blockquote></div><br></div>

--001a1147ff94821794054caf8ac3--


From MAILER-DAEMON Sat Apr 08 19:15:11 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cwzZX-00075T-M9
	for mharc-bug-bash@gnu.org; Sat, 08 Apr 2017 19:15:11 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49746)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwzZV-00072d-CY
	for bug-bash@gnu.org; Sat, 08 Apr 2017 19:15:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cwzZS-00046f-8P
	for bug-bash@gnu.org; Sat, 08 Apr 2017 19:15:09 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:18646
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>)
	id 1cwzZS-00046I-3B; Sat, 08 Apr 2017 19:15:06 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMJ72955; Sat, 08 Apr 2017 19:15:04 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GVZ62621 (AUTH cpr);
	Sat, 08 Apr 2017 19:15:03 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu, nesro <nesro@nesro.cz>, martijn@inlv.org,
	bug-bash@gnu.org
Subject: Re: while loop with extdebug + debug trap always returning 1
To: Rocky Bernstein <rocky@gnu.org>
References: <CAF3Cqmtb83RV4vdMVi4Kb45OiL6UKMeUgodgMsuOdq2pDodvDg@mail.gmail.com>
	<4f66b8f3-1e13-7be0-468d-f9e47d18ddd2@case.edu>
	<CANCp2gY1tqBNPhTHJgToS+w2bEJE1n0P+7G0mN3yvWP0a_YW7g@mail.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <3e7ca2db-ce5d-0cd0-36dd-d98ccdc1020a@case.edu>
Date: Sat, 8 Apr 2017 19:15:02 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <CANCp2gY1tqBNPhTHJgToS+w2bEJE1n0P+7G0mN3yvWP0a_YW7g@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.8.220320:17:8.317, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2,
	__CC_NAME, __CC_NAME_DIFF_FROM_ACC,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODY_SIZE_700_799, BODYTEXTP_SIZE_3000_LESS,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 08 Apr 2017 23:15:10 -0000

On 4/8/17 6:48 PM, Rocky Bernstein wrote:
> Thanks for giving me a heads up here. I have updated the bashdb
> documentation for the skip command make clear that $? is no changed in
> skipping an instruction.

OK. I was more concerned with documenting that using "skip" on the while
command test will result in it succeeding and the while command body
executing.

(And the state that the DEBUG trap saves is the same as any other trap
command: the only thing Posix says that gets saved and restored is $?.)

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sat Apr 08 19:52:19 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cx09T-0001TW-LK
	for mharc-bug-bash@gnu.org; Sat, 08 Apr 2017 19:52:19 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53513)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rocky.bernstein@gmail.com>) id 1cx09R-0001Sj-0m
	for bug-bash@gnu.org; Sat, 08 Apr 2017 19:52:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rocky.bernstein@gmail.com>) id 1cx09Q-0004iM-4b
	for bug-bash@gnu.org; Sat, 08 Apr 2017 19:52:17 -0400
Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]:35139)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rocky.bernstein@gmail.com>)
	id 1cx09P-0004hW-VV
	for bug-bash@gnu.org; Sat, 08 Apr 2017 19:52:16 -0400
Received: by mail-oi0-x229.google.com with SMTP id l63so10102058oig.2
	for <bug-bash@gnu.org>; Sat, 08 Apr 2017 16:52:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:sender:in-reply-to:references:from:date:message-id
	:subject:to:cc;
	bh=+HP4T+svzbaIBMRQeqzjtR6iJrmkqNKm0FJaUfktrjg=;
	b=txtHketHVzjB5FP3VWMyTvypmrCNnUAjDrwzJQV/womIVImHDnBi64pmmBl+n6pWTi
	qKBY1bGmrzq8ZiJ70AbdV7gM7mp4EgkCA0Dav5wGNZjk+bm/qicTIqhQfPyB6vQhhnkA
	zLliKzxjB6K1NTQe55wapP55MXoMB/hN61iSp/H6QzprgakFXr/EaiIibVOVsKcE7cge
	HZz6iIga4arP5pTmb1fxseGRfynbW1m4cOVnGmoVTD08OpzA5bs1AbC6B9ytmAMAk2xI
	aqyMd9CfHHNjr0QGuEMnXVVFfDpt+goVCxjdxlqn6iOecj+5f4kj7P8SH7Fz97Itnd9V
	ukfQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
	:date:message-id:subject:to:cc;
	bh=+HP4T+svzbaIBMRQeqzjtR6iJrmkqNKm0FJaUfktrjg=;
	b=guepRa1Om4RWFJ9naH8qEiFtfX48B/wunXiQ08MAELf2rPlioA44PUSLuEArnj5M3W
	G8s18UnUqYeyUZerGp6nS7RVEcjvlf0xbPKFGpoFUHzOMHHhiiScDsJRIk5yLSfmGDdw
	sKJAnoP94fGuteXPPMXUZmmwEm8BTP1KH2ARXpTXICm+535Ilo6R7LykF7IVy+QsNivb
	+sJGlcsHgOCEI0HcNGkUOE/19JKHcmkKIdGtwk0a4ePn7rJVouIwtbycVEPSPt6rcMw1
	5+j8zV7Rne4WiUbjHinvdTpzAWfLJYJ3YoBcZGPGfD9qpMfcbJdkczve2KKgj8nHMTJF
	sq5w==
X-Gm-Message-State: AN3rC/77zrJsndwq/4f4dPVW2I84KSN6oWzhubp0L/mlX6TZhCzHuMIFewyxwQmZbeQR8ZDUadPvDe+1pLdp9A==
X-Received: by 10.157.7.169 with SMTP id 38mr3106892oto.221.1491695534929;
	Sat, 08 Apr 2017 16:52:14 -0700 (PDT)
MIME-Version: 1.0
Sender: rocky.bernstein@gmail.com
Received: by 10.74.144.205 with HTTP; Sat, 8 Apr 2017 16:52:14 -0700 (PDT)
In-Reply-To: <3e7ca2db-ce5d-0cd0-36dd-d98ccdc1020a@case.edu>
References: <CAF3Cqmtb83RV4vdMVi4Kb45OiL6UKMeUgodgMsuOdq2pDodvDg@mail.gmail.com>
	<4f66b8f3-1e13-7be0-468d-f9e47d18ddd2@case.edu>
	<CANCp2gY1tqBNPhTHJgToS+w2bEJE1n0P+7G0mN3yvWP0a_YW7g@mail.gmail.com>
	<3e7ca2db-ce5d-0cd0-36dd-d98ccdc1020a@case.edu>
From: Rocky Bernstein <rocky@gnu.org>
Date: Sat, 8 Apr 2017 19:52:14 -0400
X-Google-Sender-Auth: Ol5xPLpD_kVoq_jDASKt0Sie5AM
Message-ID: <CANCp2gYc1wv44GJCh8Mrm5Lye56yYtoqhoh+8RzBPTDG0z=hqg@mail.gmail.com>
Subject: Re: while loop with extdebug + debug trap always returning 1
To: Chet Ramey <chet.ramey@case.edu>
Cc: nesro <nesro@nesro.cz>, martijn@inlv.org, bug-bash@gnu.org
Content-Type: multipart/alternative; boundary=94eb2c048196790d15054cb06e50
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4003:c06::229
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 08 Apr 2017 23:52:18 -0000

--94eb2c048196790d15054cb06e50
Content-Type: text/plain; charset=UTF-8

Good point! Will make note of that too.

On Sat, Apr 8, 2017 at 7:15 PM, Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/8/17 6:48 PM, Rocky Bernstein wrote:
> > Thanks for giving me a heads up here. I have updated the bashdb
> > documentation for the skip command make clear that $? is no changed in
> > skipping an instruction.
>
> OK. I was more concerned with documenting that using "skip" on the while
> command test will result in it succeeding and the while command body
> executing.
>
> (And the state that the DEBUG trap saves is the same as any other trap
> command: the only thing Posix says that gets saved and restored is $?.)
>
> Chet
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~
> chet/
>

--94eb2c048196790d15054cb06e50
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Good point! Will make note of that too. <br></div><div cla=
ss=3D"gmail_extra"><br><div class=3D"gmail_quote">On Sat, Apr 8, 2017 at 7:=
15 PM, Chet Ramey <span dir=3D"ltr">&lt;<a href=3D"mailto:chet.ramey@case.e=
du" target=3D"_blank">chet.ramey@case.edu</a>&gt;</span> wrote:<br><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><span class=3D"">On 4/8/17 6:48 PM, Rocky Bernstein =
wrote:<br>
&gt; Thanks for giving me a heads up here. I have updated the bashdb<br>
&gt; documentation for the skip command make clear that $? is no changed in=
<br>
&gt; skipping an instruction.<br>
<br>
</span>OK. I was more concerned with documenting that using &quot;skip&quot=
; on the while<br>
command test will result in it succeeding and the while command body<br>
executing.<br>
<br>
(And the state that the DEBUG trap saves is the same as any other trap<br>
command: the only thing Posix says that gets saved and restored is $?.)<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
Chet<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
``The lyf so short, the craft so long to lerne.&#39;&#39; - Chaucer<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0``Ars longa, =
vita brevis&#39;&#39; - Hippocrates<br>
Chet Ramey, UTech, CWRU=C2=A0 =C2=A0 <a href=3D"mailto:chet@case.edu">chet@=
case.edu</a>=C2=A0 =C2=A0 <a href=3D"http://cnswww.cns.cwru.edu/~chet/" rel=
=3D"noreferrer" target=3D"_blank">http://cnswww.cns.cwru.edu/~<wbr>chet/</a=
><br>
</div></div></blockquote></div><br></div>

--94eb2c048196790d15054cb06e50--


From MAILER-DAEMON Sat Apr 08 21:14:12 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cx1Qi-000722-3l
	for mharc-bug-bash@gnu.org; Sat, 08 Apr 2017 21:14:12 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33125)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rocky.bernstein@gmail.com>) id 1cx1Qf-00071o-Gu
	for bug-bash@gnu.org; Sat, 08 Apr 2017 21:14:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rocky.bernstein@gmail.com>) id 1cx1Qe-0006So-1Q
	for bug-bash@gnu.org; Sat, 08 Apr 2017 21:14:09 -0400
Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:35274)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rocky.bernstein@gmail.com>)
	id 1cx1Qd-0006Sk-R6
	for bug-bash@gnu.org; Sat, 08 Apr 2017 21:14:07 -0400
Received: by mail-oi0-x22b.google.com with SMTP id l63so10793672oig.2
	for <bug-bash@gnu.org>; Sat, 08 Apr 2017 18:14:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:sender:in-reply-to:references:from:date:message-id
	:subject:to:cc;
	bh=m6jrc+XUoXx9wlYrZZmmv0ceTprWFsSYyJ6YzbY0e5w=;
	b=YYLKCAF6sH0A65cqjtBvmEr1brZYEpay5BA56o3YaUTo12YOmqeui8CST9fBTN0X2R
	2b97qASjcIdG2vw7Ucrw9pKPjPeFxfKnBFfteUawZ7FhiF5czeV+hj1JwM5IUXX7ImHe
	3YpMdt2rlHMPFSEeFhv/a51VgYMxUrZctKh83eMbxvkz/87dJkmQtRRtsOd+13V33aey
	5KwYvknj3zQjTbDUM5zzMSaM+Iy/VvWLv22kc9q2snAVmoBrA3x47ka0rTAJe8RRjLs3
	Spbv1y/mr5ovLO36SX0mV/LIdMXuXFzCAUFc/q11Vlab/LrtrhUvxRY+ebf/KKz2QcCw
	ROmQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
	:date:message-id:subject:to:cc;
	bh=m6jrc+XUoXx9wlYrZZmmv0ceTprWFsSYyJ6YzbY0e5w=;
	b=jNqOGdqIcldh2IIH8C8h6kyuUIdVvVLIE5PV7DAdYioCerbTFUQmBq0+ZmMzNIX2kP
	zGy+pHB55rgcjjDAHt9lKqKISuT0Q4HwEgqFCpu3wxxNLUuB1g9yVIltumRRCt/jmx7b
	rAamvK3e6rARtWAQyw+b3KB8wek2z/N/uiX3ZDeI/UEODfUEyf1u8LeitQm5E5FXdlV4
	S5Y60yfWtVvKupLAI8gXDxwXl+Ip4c7gItDBMFDFQGn2bUJq+k5F/Hn7lepYTYEj+/td
	pKUfzIzXFNMWxD5GTJyyWTvZMvvq2WsEs14I+m1TomFOp98/GGY99MwQw7jFQLS2bL/e
	Ob5Q==
X-Gm-Message-State: AN3rC/46FeTqUnTpM5C5bs2aj6rX+XX4EfMUL8sbEzZ94dDbwQbyEVoQGkrFWP6fTg7IMu9MSDXawpjlRGouag==
X-Received: by 10.202.93.85 with SMTP id r82mr9339150oib.5.1491700447032; Sat,
	08 Apr 2017 18:14:07 -0700 (PDT)
MIME-Version: 1.0
Sender: rocky.bernstein@gmail.com
Received: by 10.74.144.205 with HTTP; Sat, 8 Apr 2017 18:14:06 -0700 (PDT)
In-Reply-To: <CANCp2gYc1wv44GJCh8Mrm5Lye56yYtoqhoh+8RzBPTDG0z=hqg@mail.gmail.com>
References: <CAF3Cqmtb83RV4vdMVi4Kb45OiL6UKMeUgodgMsuOdq2pDodvDg@mail.gmail.com>
	<4f66b8f3-1e13-7be0-468d-f9e47d18ddd2@case.edu>
	<CANCp2gY1tqBNPhTHJgToS+w2bEJE1n0P+7G0mN3yvWP0a_YW7g@mail.gmail.com>
	<3e7ca2db-ce5d-0cd0-36dd-d98ccdc1020a@case.edu>
	<CANCp2gYc1wv44GJCh8Mrm5Lye56yYtoqhoh+8RzBPTDG0z=hqg@mail.gmail.com>
From: Rocky Bernstein <rocky@gnu.org>
Date: Sat, 8 Apr 2017 21:14:06 -0400
X-Google-Sender-Auth: 4QXU4mHypRchRYEMGrzOJzUfNvo
Message-ID: <CANCp2gaYvUE1hhTVcm9XeEXhtQMfrJ8nWHVwFkqUtjunf7CLKg@mail.gmail.com>
Subject: Re: while loop with extdebug + debug trap always returning 1
To: Chet Ramey <chet.ramey@case.edu>
Cc: nesro <nesro@nesro.cz>, martijn@inlv.org, bug-bash@gnu.org
Content-Type: multipart/alternative; boundary=001a113d41ae41bf44054cb19388
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4003:c06::22b
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 09 Apr 2017 01:14:10 -0000

--001a113d41ae41bf44054cb19388
Content-Type: text/plain; charset=UTF-8

Bashdb skip help is now
https://sourceforge.net/p/bashdb/code/ci/master/tree/command/skip.sh#l30

If this is incorrect, deficient, or you have improvements, let me know.

Thanks.

On Sat, Apr 8, 2017 at 7:52 PM, Rocky Bernstein <rocky@gnu.org> wrote:

> Good point! Will make note of that too.
>
> On Sat, Apr 8, 2017 at 7:15 PM, Chet Ramey <chet.ramey@case.edu> wrote:
>
>> On 4/8/17 6:48 PM, Rocky Bernstein wrote:
>> > Thanks for giving me a heads up here. I have updated the bashdb
>> > documentation for the skip command make clear that $? is no changed in
>> > skipping an instruction.
>>
>> OK. I was more concerned with documenting that using "skip" on the while
>> command test will result in it succeeding and the while command body
>> executing.
>>
>> (And the state that the DEBUG trap saves is the same as any other trap
>> command: the only thing Posix says that gets saved and restored is $?.)
>>
>> Chet
>>
>> --
>> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>>                  ``Ars longa, vita brevis'' - Hippocrates
>> Chet Ramey, UTech, CWRU    chet@case.edu
>> http://cnswww.cns.cwru.edu/~chet/
>>
>
>

--001a113d41ae41bf44054cb19388
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Bashdb skip help is now <a href=3D"https://sourceforge.net=
/p/bashdb/code/ci/master/tree/command/skip.sh#l30">https://sourceforge.net/=
p/bashdb/code/ci/master/tree/command/skip.sh#l30</a>=C2=A0<br><div><br></di=
v><div>If this is incorrect, deficient, or you have improvements, let me kn=
ow.</div><div><br></div><div>Thanks.</div></div><div class=3D"gmail_extra">=
<br><div class=3D"gmail_quote">On Sat, Apr 8, 2017 at 7:52 PM, Rocky Bernst=
ein <span dir=3D"ltr">&lt;<a href=3D"mailto:rocky@gnu.org" target=3D"_blank=
">rocky@gnu.org</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><di=
v dir=3D"ltr">Good point! Will make note of that too. <br></div><div class=
=3D"HOEnZb"><div class=3D"h5"><div class=3D"gmail_extra"><br><div class=3D"=
gmail_quote">On Sat, Apr 8, 2017 at 7:15 PM, Chet Ramey <span dir=3D"ltr">&=
lt;<a href=3D"mailto:chet.ramey@case.edu" target=3D"_blank">chet.ramey@case=
.edu</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 4/8/1=
7 6:48 PM, Rocky Bernstein wrote:<br>
&gt; Thanks for giving me a heads up here. I have updated the bashdb<br>
&gt; documentation for the skip command make clear that $? is no changed in=
<br>
&gt; skipping an instruction.<br>
<br>
</span>OK. I was more concerned with documenting that using &quot;skip&quot=
; on the while<br>
command test will result in it succeeding and the while command body<br>
executing.<br>
<br>
(And the state that the DEBUG trap saves is the same as any other trap<br>
command: the only thing Posix says that gets saved and restored is $?.)<br>
<span class=3D"m_-1987438966006973007HOEnZb"><font color=3D"#888888"><br>
Chet<br>
</font></span><div class=3D"m_-1987438966006973007HOEnZb"><div class=3D"m_-=
1987438966006973007h5"><br>
--<br>
``The lyf so short, the craft so long to lerne.&#39;&#39; - Chaucer<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0``Ars longa, =
vita brevis&#39;&#39; - Hippocrates<br>
Chet Ramey, UTech, CWRU=C2=A0 =C2=A0 <a href=3D"mailto:chet@case.edu" targe=
t=3D"_blank">chet@case.edu</a>=C2=A0 =C2=A0 <a href=3D"http://cnswww.cns.cw=
ru.edu/~chet/" rel=3D"noreferrer" target=3D"_blank">http://cnswww.cns.cwru.=
edu/~ch<wbr>et/</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>

--001a113d41ae41bf44054cb19388--


From MAILER-DAEMON Sat Apr 08 23:27:05 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cx3VJ-0007qt-AT
	for mharc-bug-bash@gnu.org; Sat, 08 Apr 2017 23:27:05 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:44996)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cx3VG-0007qO-EP
	for bug-bash@gnu.org; Sat, 08 Apr 2017 23:27:03 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cx3VF-0000Fu-MZ
	for bug-bash@gnu.org; Sat, 08 Apr 2017 23:27:02 -0400
Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:36283)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <grishalevit@gmail.com>)
	id 1cx3VF-0000Fa-H0
	for bug-bash@gnu.org; Sat, 08 Apr 2017 23:27:01 -0400
Received: by mail-oi0-x236.google.com with SMTP id r203so119642568oib.3
	for <bug-bash@gnu.org>; Sat, 08 Apr 2017 20:27:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=FOZI3oyzy0gwEChw5kttsMLhPYCI30C+NnueT0CIRSU=;
	b=c/R7usMvC4tMMnTmkizPiofxq+2FE1DJh+wObJBGZ0h2FDcPdhwr0xoYlKGegYQep+
	7okYumnV8sN42ltvgI7QAB47jzKSHG5QttrCmBZlPfK8NPD1nTr/K8+CXHeSs/0J14Mg
	xPu6hECvQsH0CxyJ/NMZF/JpEv7Oo02cxr+hRAuaGKEWwoJ41PvWYhCE2TWS6Pfv5XGH
	ceQg3EQdlEEEra5M+Gd0aOhvjL6umMUCnlp3jcX6eHTJQ2z5Z9ACCygyrvmhAA5apNxu
	ACycpAHC3GXo6NKdDbvASJ3x7bwVPEvMBZN08/wqyB6H45/lwCL5mxpEcWV73VWN6Xqt
	J4iA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=FOZI3oyzy0gwEChw5kttsMLhPYCI30C+NnueT0CIRSU=;
	b=dCQ4cCZf8LaIXPXSr5rvSyuySzwvR4Se3dG6LdpGitIVHC0TN/lWKNaqs6r61/CZBy
	T8Ry9LNqh9zXvXGlDczDmbOSa9iFmwHM3Ee8W9S8NtdoDqcPaxDkiFLb19nQqK9JAObo
	CiAkI0pR7kD67yil91MK23C879zbxx4ea11EDb2DHm5NrPb8tb23UjrW52G0rVfU2YD8
	1d1yBv8L7iwrCdlhJs/UR9egB9e6MY42JPhLnuDCr7F8qJXWzDm7Wt/YKXa/qWdgrqpZ
	VsTJaeWL42HeUxSfqgezWoF3KvNCYaqhkSFGNAi8cQHAPlyJ8zQ+N+vWk+N8pazWUX5j
	LbIA==
X-Gm-Message-State: AFeK/H030mKa4EQJLc2f/hnShv2AlY5It2KxqtmW0wQ467b09tNYv3AX6tisSiFf06rQI86pN5AfV5EgGMioJA==
X-Received: by 10.157.28.142 with SMTP id l14mr22871797ota.199.1491708420216; 
	Sat, 08 Apr 2017 20:27:00 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.6.133 with HTTP; Sat, 8 Apr 2017 20:26:39 -0700 (PDT)
From: Grisha Levit <grishalevit@gmail.com>
Date: Sat, 8 Apr 2017 23:26:39 -0400
Message-ID: <CAMu=Brq+OJkVvTGw9LN6jgG_6LhFGopVnTk+rj=6xEiomsYDXQ@mail.gmail.com>
Subject: CTLESC and CTLNUL not dequoted in ${var@E}
To: bug-bash <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4003:c06::236
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 09 Apr 2017 03:27:04 -0000

$ x='\001\177'; printf %q ${x@E}
$'\001\001\001\177'

Probably just needs:

--- a/subst.c
+++ b/subst.c
@@ -7253,7 +7253,7 @@ string_transform (xc, v, s)
        break;
       /* Transformations that modify the variable's value */
       case 'E':
-       ret = ansiexpand (s, 0, strlen (s), (int *)0);
+       ret = dequote_escapes(ansiexpand (s, 0, strlen (s), (int *)0));
        break;
       case 'P':
        ret = decode_prompt_string (s);


From MAILER-DAEMON Sun Apr 09 00:16:25 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cx4H3-0002SB-SZ
	for mharc-bug-bash@gnu.org; Sun, 09 Apr 2017 00:16:25 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49071)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cx4H0-0002RS-FK
	for bug-bash@gnu.org; Sun, 09 Apr 2017 00:16:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cx4Gz-0005Cn-NG
	for bug-bash@gnu.org; Sun, 09 Apr 2017 00:16:22 -0400
Received: from mail-oi0-x234.google.com ([2607:f8b0:4003:c06::234]:32945)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <grishalevit@gmail.com>)
	id 1cx4Gz-0005Ce-H8
	for bug-bash@gnu.org; Sun, 09 Apr 2017 00:16:21 -0400
Received: by mail-oi0-x234.google.com with SMTP id b187so120293694oif.0
	for <bug-bash@gnu.org>; Sat, 08 Apr 2017 21:16:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=8wEVP06dZK+hj+Q7tzF4U/XQF3D+4LXhXP/9gy0r8/o=;
	b=O9fuk/zG4SQYOjok/t+Nw3aXM1qXOLK+r4v1xkYz074R0c7l3vRsS31TlfjhChZV2F
	1fxRcpR+BnQEz/UbeVi4ZXrY55lZDQo/iW+/l2ywKMnUKBviA93ofkthjSSr5jw7NX1a
	zxgcMnXPXvtXXN0eIhKMz12LsBL29LROGE041lhKi1M4vTUNTYzNi0GTiJcnkSd6mBh6
	d6AC7BHQMniqz0ZCs2VzcdclUTnj0Cip9FAS2PjXfWpKFCnXFDlvPUPe+ewDOCDo304q
	MXEZlxDCcw3BrLaW64CAhwO8t7Sh/8bsxPEf4iqwBRyy/i6QERgk68DOgn2aU2JuRaDt
	zaXw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=8wEVP06dZK+hj+Q7tzF4U/XQF3D+4LXhXP/9gy0r8/o=;
	b=XccEBWEwmiH7FSX3NAk2wrsEtxpYkXI+nlGtzgcqB1w3zwmYEMQzJ7je5Qe6+QrqSR
	tKGVXGSKRNYUcMspsOohb3363kxZEeaOX7CmYNGk4NDnuFLnLp0HyUsa1W9ofxBjQI0S
	Sd1DItRO4EsyVaXJbZWt9gxpw7l88wDKe+mtV8wgzhynhRCzccxXzaCgoVowJdudtGvt
	5EF24Z4dcFXg5HfISHO5IJt6PeVPVVCs5IL7y3CA2epEDw85OEzg+rjq77aqYNHmUwx+
	fpmv9JTA/R0Qjo2u7hupMZx8Fati+BkASP3GEPmgSFcyU09l4eD9Mcc9HETUIgg+Q8eP
	vcVw==
X-Gm-Message-State: AN3rC/5uFiMnMCwjOyYrsCo9rtw8xIWBWFb/DzDIKcaZdbzerJr1hGgJMaHKM7TF/ezYw3hYd+DrMCBAcBoVnQ==
X-Received: by 10.202.3.11 with SMTP id 11mr3287794oid.189.1491711380614; Sat,
	08 Apr 2017 21:16:20 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.6.133 with HTTP; Sat, 8 Apr 2017 21:16:00 -0700 (PDT)
From: Grisha Levit <grishalevit@gmail.com>
Date: Sun, 9 Apr 2017 00:16:00 -0400
Message-ID: <CAMu=BrpmCbZr6e52g=KqSu68+=rp_5rraSY8UcCvCw4rqhzfCQ@mail.gmail.com>
Subject: CTLESC and CTLNUL not dequoted in exported function definitions
To: bug-bash <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4003:c06::234
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 09 Apr 2017 04:16:23 -0000

For example:

$ f() { $'\001'; }; export -f f; printenv BASH_FUNC_f%% | xxd
00000000: 2829 207b 2020 2701 0127 0a7d 0a         () {  '..'.}.

I think the following should fix it:

diff --git a/variables.c b/variables.c
index 87203dac..acac867e 100644
--- a/variables.c
+++ b/variables.c
@@ -4309,7 +4309,7 @@ mk_env_string (name, value, isfunc)
      int isfunc;
 {
   size_t name_len, value_len;
-  char *p, *q;
+  char *p, *q, *t;

   name_len = strlen (name);
   value_len = STRLEN (value);
@@ -4336,7 +4336,17 @@ mk_env_string (name, value, isfunc)

   q[0] = '=';
   if (value && *value)
-    memcpy (q + 1, value, value_len + 1);
+    if (isfunc)
+      {
+       t = (char *)xmalloc (value_len + 1);
+       strcpy (t, value);
+       remove_quoted_escapes (t);
+       value_len = STRLEN(t);
+       memcpy (q + 1, t, value_len + 1);
+       free (t);
+      }
+    else
+      memcpy (q + 1, value, value_len + 1);
   else
     q[1] = '\0';


From MAILER-DAEMON Sun Apr 09 17:43:53 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxKcj-0001uF-G5
	for mharc-bug-bash@gnu.org; Sun, 09 Apr 2017 17:43:53 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57093)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxKch-0001u6-9w
	for bug-bash@gnu.org; Sun, 09 Apr 2017 17:43:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxKce-0004bg-7y
	for bug-bash@gnu.org; Sun, 09 Apr 2017 17:43:51 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:24068
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cxKce-0004b9-4f
	for bug-bash@gnu.org; Sun, 09 Apr 2017 17:43:48 -0400
Received: from mpv8-2015.CWRU.Edu (EHLO mpv8-2015.case.edu) ([129.22.103.210])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMP10384; Sun, 09 Apr 2017 17:43:46 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv8-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GWQ72554 (AUTH cpr);
	Sun, 09 Apr 2017 17:43:45 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: CTLESC and CTLNUL not dequoted in ${var@E}
To: Grisha Levit <grishalevit@gmail.com>, bug-bash <bug-bash@gnu.org>
References: <CAMu=Brq+OJkVvTGw9LN6jgG_6LhFGopVnTk+rj=6xEiomsYDXQ@mail.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <66b95821-9739-8b29-bc2d-f54f2e0c47c3@case.edu>
Date: Sun, 9 Apr 2017 17:43:43 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <CAMu=Brq+OJkVvTGw9LN6jgG_6LhFGopVnTk+rj=6xEiomsYDXQ@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 09 Apr 2017 21:43:52 -0000

On 4/8/17 11:26 PM, Grisha Levit wrote:
> $ x='\001\177'; printf %q ${x@E}
> $'\001\001\001\177'
> 
> Probably just needs:
> 
> --- a/subst.c
> +++ b/subst.c
> @@ -7253,7 +7253,7 @@ string_transform (xc, v, s)
>         break;
>        /* Transformations that modify the variable's value */
>        case 'E':
> -       ret = ansiexpand (s, 0, strlen (s), (int *)0);
> +       ret = dequote_escapes(ansiexpand (s, 0, strlen (s), (int *)0));
>         break;
>        case 'P':
>         ret = decode_prompt_string (s);

Thanks for the report.  The patch is just about right, but introduces a
memory leak.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sun Apr 09 17:56:52 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxKpH-0002uH-To
	for mharc-bug-bash@gnu.org; Sun, 09 Apr 2017 17:56:51 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59258)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxKpF-0002u8-OG
	for bug-bash@gnu.org; Sun, 09 Apr 2017 17:56:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxKpC-0008OY-NG
	for bug-bash@gnu.org; Sun, 09 Apr 2017 17:56:49 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:24764
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cxKpC-0008ON-HJ
	for bug-bash@gnu.org; Sun, 09 Apr 2017 17:56:46 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMJ91537; Sun, 09 Apr 2017 17:56:45 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GWF90797 (AUTH cpr);
	Sun, 09 Apr 2017 17:56:44 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: CTLESC and CTLNUL not dequoted in exported function definitions
To: Grisha Levit <grishalevit@gmail.com>, bug-bash <bug-bash@gnu.org>
References: <CAMu=BrpmCbZr6e52g=KqSu68+=rp_5rraSY8UcCvCw4rqhzfCQ@mail.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <263a2c8c-2ebf-7d82-aa72-017456cc6ead@case.edu>
Date: Sun, 9 Apr 2017 17:56:47 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <CAMu=BrpmCbZr6e52g=KqSu68+=rp_5rraSY8UcCvCw4rqhzfCQ@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.9.210317:17:7.944, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_400_499,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS,
	__SINGLE_URI_TEXT, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 09 Apr 2017 21:56:50 -0000

On 4/9/17 12:16 AM, Grisha Levit wrote:
> f() { $'\001'; }; export -f f; printenv BASH_FUNC_f%%

Thanks for the report and fix.  This is the patch where you could have used
dequote_escapes() ;-) .

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sun Apr 09 18:13:17 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxL5B-0004e8-9E
	for mharc-bug-bash@gnu.org; Sun, 09 Apr 2017 18:13:17 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33950)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cxL59-0004e1-88
	for bug-bash@gnu.org; Sun, 09 Apr 2017 18:13:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cxL58-0005K7-Ce
	for bug-bash@gnu.org; Sun, 09 Apr 2017 18:13:15 -0400
Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:35397)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <grishalevit@gmail.com>)
	id 1cxL58-0005K2-7a
	for bug-bash@gnu.org; Sun, 09 Apr 2017 18:13:14 -0400
Received: by mail-oi0-x233.google.com with SMTP id f22so306260oib.2
	for <bug-bash@gnu.org>; Sun, 09 Apr 2017 15:13:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=N43vfbxQqkrWfiWcP1GVEKPuYGy55H/QsoR4pQ4e9pw=;
	b=PwTmxX1sLURFJT7X6GQpjhq3TPoLs6c/p48fX47Rnibj/Jj54j8rYNw+x/JLol3VqI
	T0CL2v5ZIv1Dzs08ClF3g0R5sIT3oOfxMPQ3gE21ZsZkiOSsS2KKYPC9ASTKZcCbmA4m
	n6Glov0UD3zy1MzwwhPoETmFwElf8+gCRJgLzMkIsspJuosA2d9J+JqUuWozM9feI9GT
	I8TjwykV1tAbv+hS/XQNK7p6PNLShoPFGiWSUIiWlKA18Q71LOwiZk27R80JT4L54jFs
	KAjRjHhEpZdnIO0ucwlEr0yax8h9c7/YBGVXGzDv1fhTD1c7c/eVCS2kOTHs+BddHaR6
	922Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=N43vfbxQqkrWfiWcP1GVEKPuYGy55H/QsoR4pQ4e9pw=;
	b=rOj/u5pI2+YkXCSUhFJmQiDZPVy8MYz3KWsAeskfZZuTk5UhUYsheP+AJ6cwSVeWud
	PfYsadQAbfj1hkJqIXF5oDPs2Uu4C04tIskw+y83NS+fA+Bt95zoUv3wLhYKPaY0as0J
	gSuPZqWYConB+lHfUGlf5EsVO5NT/9uyKUseYXspCmJUNZJdK+cyqUzhBAktmkGgepO9
	MNNWcWqpF3U2UOws9ItHPEn4J1W3EDfpLt7n6SG8k+MfujJ3hcOqYFsz+sbZCKGDuKCI
	Wgq+4wZg1Kr7s4/CMs8F1vsKMUeZiCPlSl1n2OHUJfJ7GLSYGtZzprTUPLwXF8E7gcJ6
	IiUA==
X-Gm-Message-State: AFeK/H3MKekfQvCtyLjqqrk3MaCdGoNYE1Xj4Egqg73j5TJfbIfrSnuP+Ce5MAy6UTRE4sTsswKQAtgLmJeb6w==
X-Received: by 10.157.30.200 with SMTP id n66mr17662688otn.143.1491775993528; 
	Sun, 09 Apr 2017 15:13:13 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.6.133 with HTTP; Sun, 9 Apr 2017 15:12:53 -0700 (PDT)
In-Reply-To: <263a2c8c-2ebf-7d82-aa72-017456cc6ead@case.edu>
References: <CAMu=BrpmCbZr6e52g=KqSu68+=rp_5rraSY8UcCvCw4rqhzfCQ@mail.gmail.com>
	<263a2c8c-2ebf-7d82-aa72-017456cc6ead@case.edu>
From: Grisha Levit <grishalevit@gmail.com>
Date: Sun, 9 Apr 2017 18:12:53 -0400
Message-ID: <CAMu=BroRoxGrY=yKawME3-BqrcgjHuUiv3cmiQiT921eL7dLvQ@mail.gmail.com>
Subject: Re: CTLESC and CTLNUL not dequoted in exported function definitions
To: Chester Ramey <chet.ramey@case.edu>
Cc: bug-bash <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4003:c06::233
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 09 Apr 2017 22:13:16 -0000

On Sun, Apr 9, 2017 at 5:56 PM, Chet Ramey <chet.ramey@case.edu> wrote:
> Thanks for the report and fix.  This is the patch where you could have used
> dequote_escapes() ;-) .

Yup, I realized I'd done the previous one incorrectly shortly after writing
this one, sorry about that.

But I'm not sure about dequoting the function name, so I wanted to dequote
just the value, not the whole sting pointed to by q.  In retrospect, maybe
I should have clarified that issue first:

$ eval $'\001() { :; }'
$ declare -F | xxd
00000000: 6465 636c 6172 6520 2d66 2001 010a       declare -f ...
                                     ^^ ^^

The actual function that's created actually *is* $'\001\001':

$ type -t $'\001'
$ type -t $'\001\001'
function

So I was assuming the error is with not dequoting the function name *before*
the function is created and that when mk_env_string is called `name' would
already be dequoted and `value' would not be.


From MAILER-DAEMON Sun Apr 09 19:35:42 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxMMw-0004Kg-HG
	for mharc-bug-bash@gnu.org; Sun, 09 Apr 2017 19:35:42 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46332)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cxMMu-0004K3-EF
	for bug-bash@gnu.org; Sun, 09 Apr 2017 19:35:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <grishalevit@gmail.com>) id 1cxMMt-0006Ze-93
	for bug-bash@gnu.org; Sun, 09 Apr 2017 19:35:40 -0400
Received: from mail-oi0-x234.google.com ([2607:f8b0:4003:c06::234]:32773)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <grishalevit@gmail.com>)
	id 1cxMMt-0006Yy-3s
	for bug-bash@gnu.org; Sun, 09 Apr 2017 19:35:39 -0400
Received: by mail-oi0-x234.google.com with SMTP id b187so131441962oif.0
	for <bug-bash@gnu.org>; Sun, 09 Apr 2017 16:35:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=X+wQNegFzbiqndZOsuTFQfPTAhMvF0NdS6IeQ3x/kl8=;
	b=b4AtnuZUmGuJq0x9Kb/q1Ts4noiwQwm+t7xnV3zYHFEKoq1LFU/1UakA3UXQ3ezRJ1
	Bn5GxX2EgRfiaM+akG0Vg03xZZ4GAGSsmh/rvJsgFk/wMq/U/cc+l2/5qZLQBHruH8U5
	NAzgtqjzH8KHKMrh1BUxgdAbSwtmOERoYFBSb10PD0gUOi/NgnHl1PXJhmh2GL+bx4PS
	sF6y/0pyz4l++iQ+fej/sj0pNDwqPQlvkxAYq7vSE41jOXmz9xPsl9p8I8ATIt1XlKys
	59Z3SNRh0SwTp5FTyo7eunnw9UClDtRJarFDRXux1YLcS96D0Aui5oHhNSu+28D+YFjp
	wI3g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=X+wQNegFzbiqndZOsuTFQfPTAhMvF0NdS6IeQ3x/kl8=;
	b=WXY66+Rr8mdXJG7QCcqXcyhT80MTe4eraTKW5u+EBddw7yjDErhDYQywgrTHEh/SSb
	sNEDdJK/kXzY8PUDMdbAVIFvSIaZOO0BeN1ttz6iTXc30/11Ntd2Ii2SbQOYKGqoapyH
	6CjGqRF/fQ58IciQafOmSVfBap6PdOMJswkODSmB67qaNnNngJOTcjDDiz2YCHeOpsby
	5kqsXzjIWS5+G2arU0biSj20KGNo5P1H73+feZGbXBzkGoWlYGAq3BK+Vti2oV9s9+TG
	GCfVV4+zO6QyyHxei07sBP8Ihh5oI6iS9wNGiqrZAkSdUxddxJ0IbneGr437Sb9S0f8l
	/vqg==
X-Gm-Message-State: AFeK/H3/L0FnYB881hgES6fD/o0ArOA9u08pPnAxeCEkoN0HS+R/HlduNoivTN717x8wsRf87Ctq1RRmkxzLbA==
X-Received: by 10.157.30.200 with SMTP id n66mr17755116otn.143.1491780938062; 
	Sun, 09 Apr 2017 16:35:38 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.6.133 with HTTP; Sun, 9 Apr 2017 16:35:17 -0700 (PDT)
From: Grisha Levit <grishalevit@gmail.com>
Date: Sun, 9 Apr 2017 19:35:17 -0400
Message-ID: <CAMu=BroF1r7=Edmqj8KqCT5naWq6K2SR2A=O+QSgwk+TYMqBoA@mail.gmail.com>
Subject: extra field in $* expansion when non-whitespace character in IFS
To: bug-bash <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4003:c06::234
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 09 Apr 2017 23:35:41 -0000

In most cases, removing a non-whitespace IFS character "delimits" a field
in the sense that it terminates it, so the presence of such a character at
the end of a field does not change its expansion:

  $ IFS=X
  $ set -- Y; printf '<%s>' $*
  <Y>
  $ set -- YX; IFS=X; printf '<%s>' $*
  <Y>

However, when a positional parameter ends with a non-whitespace IFS character
and is followed by another positional parameter, the removal of the IFS
character seems to create an additional field:

  $ set -- YX Y; printf '<%s>' $*
  <Y><><Y>

Is this intentional? It sort of makes sense since $* is expanded as if it
were $1c$2 (where c is the first character of IFS), i.e. the expansion above
matches what is produced by

  set -- YX Y; v=$*; printf '<%s>' $v

but that doesn't seem to respect the prescribed behavior of first producing
a field for each positional parameter, and then subjecting each field to
field splitting.

Array behavior matches positional parameter behavior here.

FWIW, this differs from the ksh behavior:

  $ set -- YX Y; printf '<%s>' $*
  <Y><Y>


From MAILER-DAEMON Sun Apr 09 20:07:59 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxMsB-00081c-OU
	for mharc-bug-bash@gnu.org; Sun, 09 Apr 2017 20:07:59 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51761)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxMs9-00081V-D7
	for bug-bash@gnu.org; Sun, 09 Apr 2017 20:07:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxMs6-0001Ei-9R
	for bug-bash@gnu.org; Sun, 09 Apr 2017 20:07:57 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:35372
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cxMs6-0001EK-3O
	for bug-bash@gnu.org; Sun, 09 Apr 2017 20:07:54 -0400
Received: from mpv8-2015.CWRU.Edu (EHLO mpv8-2015.case.edu) ([129.22.103.210])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMP12874; Sun, 09 Apr 2017 20:07:52 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv8-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GWR23876 (AUTH cpr);
	Sun, 09 Apr 2017 20:07:51 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu, bug-bash <bug-bash@gnu.org>
Subject: Re: CTLESC and CTLNUL not dequoted in exported function definitions
To: Grisha Levit <grishalevit@gmail.com>
References: <CAMu=BrpmCbZr6e52g=KqSu68+=rp_5rraSY8UcCvCw4rqhzfCQ@mail.gmail.com>
	<263a2c8c-2ebf-7d82-aa72-017456cc6ead@case.edu>
	<CAMu=BroRoxGrY=yKawME3-BqrcgjHuUiv3cmiQiT921eL7dLvQ@mail.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <6b864e8b-eca0-8860-f695-d85e9a126d34@case.edu>
Date: Sun, 9 Apr 2017 20:07:55 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <CAMu=BroRoxGrY=yKawME3-BqrcgjHuUiv3cmiQiT921eL7dLvQ@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 10 Apr 2017 00:07:58 -0000

On 4/9/17 6:12 PM, Grisha Levit wrote:
> On Sun, Apr 9, 2017 at 5:56 PM, Chet Ramey <chet.ramey@case.edu> wrote:
>> Thanks for the report and fix.  This is the patch where you could have used
>> dequote_escapes() ;-) .
> 
> Yup, I realized I'd done the previous one incorrectly shortly after writing
> this one, sorry about that.
> 
> But I'm not sure about dequoting the function name, so I wanted to dequote
> just the value, not the whole sting pointed to by q.  In retrospect, maybe
> I should have clarified that issue first:
> 
> $ eval $'\001() { :; }'
> $ declare -F | xxd
> 00000000: 6465 636c 6172 6520 2d66 2001 010a       declare -f ...
>                                      ^^ ^^
> 
> The actual function that's created actually *is* $'\001\001':

No, that's true, and it should be fixed.  At some point, though, you have
to ask yourself what someone would be doing creating a function named ^A.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Mon Apr 10 01:08:32 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxRZ2-0005Lg-7J
	for mharc-bug-bash@gnu.org; Mon, 10 Apr 2017 01:08:32 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38407)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <emlyn.jose@wipro.com>) id 1cxRYu-0005HW-Ky
	for bug-bash@gnu.org; Mon, 10 Apr 2017 01:08:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <emlyn.jose@wipro.com>) id 1cxRYo-0001Ji-CE
	for bug-bash@gnu.org; Mon, 10 Apr 2017 01:08:24 -0400
Received: from mail-pu1apc01on0064.outbound.protection.outlook.com
	([104.47.126.64]:5120
	helo=APC01-PU1-obe.outbound.protection.outlook.com)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <emlyn.jose@wipro.com>)
	id 1cxRYn-0001Hb-C4
	for bug-bash@gnu.org; Mon, 10 Apr 2017 01:08:18 -0400
Received: from HKNPR03MB2308.apcprd03.prod.outlook.com (10.141.36.156) by
	HKNPR03MB2305.apcprd03.prod.outlook.com (10.141.36.153) with Microsoft
	SMTP Server (version=TLS1_2,
	cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id
	15.1.1019.8; Mon, 10 Apr 2017 05:08:10 +0000
Received: from HKNPR03MB2308.apcprd03.prod.outlook.com
	([fe80::e96d:4bf9:f1a8:d59a]) by
	HKNPR03MB2308.apcprd03.prod.outlook.com
	([fe80::e96d:4bf9:f1a8:d59a%15]) with mapi id 15.01.1019.024;
	Mon, 10 Apr 2017 05:08:10 +0000
From: "emlyn.jose@wipro.com" <emlyn.jose@wipro.com>
To: Greg Wooledge <wooledg@eeg.ccf.org>, Chet Ramey <chet.ramey@case.edu>
CC: "bug-bash@gnu.org" <bug-bash@gnu.org>
Subject: RE: bash 4.4 null byte warning!!
Thread-Topic: bash 4.4 null byte warning!!
Thread-Index: AdKuqgsprHS+cCb0SAaOroTOd0ADogAOmEkAALNz0IA=
Date: Mon, 10 Apr 2017 05:08:10 +0000
Message-ID: <HKNPR03MB230852B61B38C92CE8E50BFE88010@HKNPR03MB2308.apcprd03.prod.outlook.com>
References: <HKNPR03MB230809726ED57A0E4D87015C880D0@HKNPR03MB2308.apcprd03.prod.outlook.com>
	<20170406144523.GO17132@eeg.ccf.org>
In-Reply-To: <20170406144523.GO17132@eeg.ccf.org>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: eeg.ccf.org; dkim=none (message not signed)
	header.d=none; eeg.ccf.org; dmarc=none action=none header.from=wipro.com;
x-originating-ip: [194.157.154.68]
x-microsoft-exchange-diagnostics: 1; HKNPR03MB2305;
	7:7WhjMbpeQIAeREGCMbULjABkLdJUgizUBgT+sexsmfDusr51sxyE6Yuf7CWXw/GBLxraQPtR8ytxkkEoQeOXJ7BLeeOIYvo5ZCJrfzHI5Jv0+iKuNsVRzb02yi3oEfFB0vy1GkemCUQDlvDO8zcTpcN2maj5BKqDLIjiwPL04ADi0uLwCdynncVZP+d55+TAQ/T9USkeeakyS6irSP6FTxihjLPaI19TTnvMdBIkNPSzjnSiYGVGqM5Wc7Ym1ZY9ZHucmc6/3pBjZmQ5R/fneSsAwHHd9oa26yEhxxUOjUaujCy0N5T2xDCF+0l8nhrdB+FEnDmiU2zjmfIX9VAZ/A==
x-ms-office365-filtering-correlation-id: 169ccfd2-bd77-4d3a-335b-08d47fcf9532
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: UriScan:; BCL:0; PCL:0;
	RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);
	SRVR:HKNPR03MB2305; 
x-microsoft-antispam-prvs: <HKNPR03MB230567B6491D085AFF537F6E88010@HKNPR03MB2305.apcprd03.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(267259832677123)(20558992708506)(22074186197030)(62627912741753)(21748063052155)(17755550239193);
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0;
	RULEID:(61425038)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123562025)(20161123555025)(20161123560025)(6072148);
	SRVR:HKNPR03MB2305; BCL:0; PCL:0; RULEID:; SRVR:HKNPR03MB2305; 
x-forefront-prvs: 027367F73D
x-forefront-antispam-report: SFV:NSPM;
	SFS:(10009020)(6009001)(39860400002)(39840400002)(39450400003)(39850400002)(39400400002)(39410400002)(24454002)(377454003)(3280700002)(7696004)(6116002)(189998001)(102836003)(2950100002)(81166006)(3660700001)(2900100001)(5660300001)(2906002)(66066001)(229853002)(8936002)(76176999)(50986999)(54356999)(226693001)(33656002)(5890100001)(6246003)(99286003)(9686003)(55016002)(2171002)(966004)(6306002)(53546009)(53936002)(4326008)(7736002)(5250100002)(38730400002)(86362001)(8676002)(3846002)(25786009)(305945005)(74316002)(6506006)(6436002)(225543005);
	DIR:OUT; SFP:1101; SCL:1; SRVR:HKNPR03MB2305;
	H:HKNPR03MB2308.apcprd03.prod.outlook.com; FPR:; SPF:None;
	MLV:sfv; LANG:en; 
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/alternative;
	boundary="_000_HKNPR03MB230852B61B38C92CE8E50BFE88010HKNPR03MB2308apcp_"
MIME-Version: 1.0
X-OriginatorOrg: wipro.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Apr 2017 05:08:10.2444 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 258ac4e4-146a-411e-9dc8-79a9e12fd6da
X-MS-Exchange-Transport-CrossTenantHeadersStamped: HKNPR03MB2305
X-MS-Exchange-CrossPremises-AuthAs: Internal
X-MS-Exchange-CrossPremises-AuthMechanism: 03
X-MS-Exchange-CrossPremises-AuthSource: HKNPR03MB2308.apcprd03.prod.outlook.com
X-MS-Exchange-CrossPremises-SCL: 1
X-MS-Exchange-CrossPremises-messagesource: StoreDriver
X-MS-Exchange-CrossPremises-BCC: 
X-MS-Exchange-CrossPremises-originalclientipaddress: 194.157.154.68
X-MS-Exchange-CrossPremises-avstamp-service: 1.0
X-MS-Exchange-CrossPremises-disclaimer-hash: ef6ed6a830673538406bd527e716551fd2daba1e446b50e7f1f30c79ce70f874
X-MS-Exchange-CrossPremises-antispam-scancontext: DIR:Originating; SFV:NSPM;
	SKIP:0; 
X-MS-Exchange-CrossPremises-processed-by-journaling: Journal Agent
X-OrganizationHeadersPreserved: HKNPR03MB2305.apcprd03.prod.outlook.com
X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy]
X-Received-From: 104.47.126.64
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 10 Apr 2017 05:08:30 -0000

--_000_HKNPR03MB230852B61B38C92CE8E50BFE88010HKNPR03MB2308apcp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi Greg/Chet Ramey,

Thank  you so much for the response! It gave me an idea on what has to be d=
one next.

We have been using the same script all these years and had no issues of bro=
ken commands when used with the lower versions of bash which is why I have =
been thinking whether to rewrite the script for the new bash(4.4) or edit t=
he bash source.

The reason behind using -print0 is to use the resultant output to find a bi=
nary

Below are the lines of code followed by the find command:

 FIND_RPM=3D"$(find $linIdx -type d -name "${2}" -print0 2>/dev/null)"
        [ -n "$FIND_RPM" ] && \
            [ -s "${FIND_RPM}/bin" ] && \
            bdt_msg 4 "[D] Found %s in %s component area." "$2" "$linIdx" &=
& \
                ...
                ...

>> If you want to suppress the warning, you'll have to edit the source and =
rebuild.
Do you have a guide on how to do this?

Or else I have been planning to add tr to remove the nuls as suggested by G=
reg.

Regards,
Emlyn Jose.

---------------------------------------------------------------------------=
------------------------------
-----Original Message------------------------------------------------------=
-------------------------
From: Chet Ramey [mailto:chet.ramey@case.edu]
Sent: Saturday, April 8, 2017 7:48 AM
To: Emlyn Jose (GIS); bug-bash@gnu.org
Cc: chet.ramey@case.edu
Subject: Re: bash 4.4 null byte warning!!

On 4/6/17 3:47 AM, emlyn.jose@wipro.com wrote:
> Hi,
>
>
>
> We are trying to use the bash 4.4 downloaded from
> http://ftp.gnu.org/gnu/bash/ on our RHEL 6.2 machine.
>
> But while using a script that has this command :
>
> FIND_RPM=3D`find /opt/RPM/components -type d -name enum-1.1.6-print0`
>
> It throws a warning as below:
>
> bash:warning:command substitution:ignored null byte ininput

Yes.  It drops the null bytes because C strings can't handle them.  I recei=
ved bug reports asking why bash silently transforms the command substitutio=
n output and added the warning while not changing the behavior.

If you want to suppress the warning, you'll have to edit the source and reb=
uild.

This does beg the question of why you're using -print0 without something on=
 the receiving end to handle the null bytes.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~che=
t/


---------------------------------------------------------------------------=
-----------------------------------------------------
-----Original Message------------------------------------------------------=
------------------------------------------------
From: Greg Wooledge [mailto:wooledg@eeg.ccf.org]
Sent: Thursday, April 6, 2017 8:15 PM
To: Emlyn Jose (GIS)
Cc: bug-bash@gnu.org
Subject: Re: bash 4.4 null byte warning!!

On Thu, Apr 06, 2017 at 07:47:35AM +0000, emlyn.jose@wipro.com<mailto:emlyn=
.jose@wipro.com> wrote:
> FIND_RPM=3D`find /opt/RPM/components -type d -name enum-1.1.6 -print0`
> It throws a warning as below:
>
> bash: warning: command substitution: ignored null byte in input

Your command is broken, and bash is warning you of this.  Why do you want t=
o silence the warning instead of fixing the command?

If your find returns a single result, you get a filename followed by NUL, a=
nd the NUL is discarded, leaving you a filename inside the command substitu=
tion (and therefore the variable).  You could achieve the EXACT same result=
 by dropping the -print0.  Then, if you get a single result from find, you =
get the filename followed by newline, and the command substitution discards=
 the trailing newline, leaving you just the filename in the command substit=
ution and therefore the variable.

On the other hand, if your find command returns MULTIPLE results, then you =
have file1\000file2\000 and the command substitution drops the NUL bytes, l=
eaving you with file1file2 in your variable.  At least if you dropped the -=
print0 you would have file1\nfile2 in your variable, which is still wrong, =
but not as wrong as file1file2.

> Is there any patch available for this or is there any way to make bash si=
lently drop this warning(which has been the behavior on the lower versions =
of bash)??

If you REALLY want to continue to run a broken command, you can explicitly =
use tr to remove the NULs before the command substitution ever sees them.

var=3D$(find ... -print0 | tr -d '\0')

That will prevent the warning and allow you to continue running a broken sc=
ript without letting your coworkers catch on to the bugs (or whatever your =
issue with the warning is).

If you actually want to FIX the script, the results of find should be read =
into an array, since there can be more than one.  Every place you use your =
variable currently, you'd have to rewrite that to handle an array with pote=
ntially multiple elements.

The information contained in this electronic message and any attachments to=
 this message are intended for the exclusive use of the addressee(s) and ma=
y contain proprietary, confidential or privileged information. If you are n=
ot the intended recipient, you should not disseminate, distribute or copy t=
his e-mail. Please notify the sender immediately and destroy all copies of =
this message and any attachments. WARNING: Computer viruses can be transmit=
ted via email. The recipient should check this email and any attachments fo=
r the presence of viruses. The company accepts no liability for any damage =
caused by any virus transmitted by this email. www.wipro.com

--_000_HKNPR03MB230852B61B38C92CE8E50BFE88010HKNPR03MB2308apcp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left:=
 #800000 2px solid; } --></style>
</head>
<body>
<font face=3D"Calibri" size=3D"2"><span style=3D"font-size:11pt;">
<div><font color=3D"#1F3864">Hi Greg/Chet Ramey,</font></div>
<div><font color=3D"#1F3864">&nbsp;</font></div>
<div><font color=3D"#1F3864">Thank&nbsp; you so much for the response! It g=
ave me an idea on what has to be done next.</font></div>
<div><font color=3D"#1F3864">&nbsp;</font></div>
<div><font color=3D"#1F3864">We have been using the same script all these y=
ears and had no issues of broken commands when used with the lower versions=
 of bash which is why I have been thinking whether to rewrite the script fo=
r the new bash(4.4) or edit the bash
source.</font></div>
<div><font color=3D"#1F3864">&nbsp;</font></div>
<div><font color=3D"#1F3864">The reason behind using <font face=3D"Courier =
New">&#8211;print0</font> is to use the resultant output to find a binary <=
/font></div>
<div><font color=3D"#1F3864">&nbsp;</font></div>
<div><font size=3D"2" color=3D"#1F3864"><span style=3D"font-size:10.5pt;">B=
elow are the lines of code followed by the&nbsp;find&nbsp;command:</span></=
font></div>
<div><font color=3D"#1F3864">&nbsp;</font></div>
<div style=3D"background-color:whitesmoke;"><font face=3D"Courier New" size=
=3D"2" color=3D"#333333"><span style=3D"font-size:10pt;background-color:whi=
tesmoke;"><span style=3D"background-color:white;"> FIND_</span><span style=
=3D"background-color:white;">RPM</span><span style=3D"background-color:whit=
e;">=3D</span><font color=3D"#009100"><span style=3D"background-color:white=
;">&quot;$(find
$linIdx -type d -name &quot;</span></font><span style=3D"background-color:w=
hite;">${2}</span><font color=3D"#009100"><span style=3D"background-color:w=
hite;">&quot; -print0 2&gt;/dev/null)&quot;</span></font></span></font></di=
v>
<div style=3D"background-color:whitesmoke;"><font face=3D"Courier New" size=
=3D"2" color=3D"#333333"><span style=3D"font-size:10pt;background-color:whi=
tesmoke;"><span style=3D"background-color:white;">&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp; [ -n </span><font color=3D"#009100"><span style=3D"backgr=
ound-color:white;">&quot;$FIND_</span></font><font color=3D"#009100"><span =
style=3D"background-color:white;">RP</span></font><font color=3D"#009100"><=
span style=3D"background-color:white;">M</span></font><font color=3D"#00910=
0"><span style=3D"background-color:white;">&quot;</span></font><span style=
=3D"background-color:white;">
] &amp;&amp; \</span></span></font></div>
<div style=3D"background-color:whitesmoke;"><font face=3D"Courier New" size=
=3D"2" color=3D"#333333"><span style=3D"font-size:10pt;background-color:whi=
tesmoke;"><span style=3D"background-color:white;">&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ -s </span><font color=3D"#00910=
0"><span style=3D"background-color:yellow;">&quot;${FIND_</span></font><fon=
t color=3D"#009100"><span style=3D"background-color:yellow;">RPM</span></fo=
nt><font color=3D"#009100"><span style=3D"background-color:yellow;">}/</spa=
n></font><font color=3D"#009100"><span style=3D"background-color:yellow;">b=
in</span></font><font color=3D"#009100"><span style=3D"background-color:yel=
low;">&quot;</span></font><span style=3D"background-color:white;">
] &amp;&amp; \</span></span></font></div>
<div style=3D"background-color:whitesmoke;"><font face=3D"Courier New" size=
=3D"2" color=3D"#333333"><span style=3D"font-size:10pt;background-color:whi=
tesmoke;"><span style=3D"background-color:white;">&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bdt_msg 4 </span><font color=3D"#=
009100"><span style=3D"background-color:white;">&quot;[D]
Found %s in %s </span></font><font color=3D"#009100"><span style=3D"backgro=
und-color:white;">component</span></font><font color=3D"#009100"><span styl=
e=3D"background-color:white;"> area.&quot;</span></font><span style=3D"back=
ground-color:white;"> </span><font color=3D"#009100"><span style=3D"backgro=
und-color:white;">&quot;$2&quot;</span></font><span style=3D"background-col=
or:white;">
</span><font color=3D"#009100"><span style=3D"background-color:white;">&quo=
t;$linIdx&quot;</span></font><span style=3D"background-color:white;"> &amp;=
&amp; \</span></span></font></div>
<div style=3D"background-color:whitesmoke;"><font color=3D"#333333"><span s=
tyle=3D"background-color:whitesmoke;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face=3D"Courier=
 New" size=3D"2"><span style=3D"font-size:10pt;background-color:white;">&#8=
230;</span></font></span></font></div>
<div style=3D"background-color:whitesmoke;"><font face=3D"Courier New" size=
=3D"2" color=3D"#333333"><span style=3D"font-size:10pt;background-color:whi=
tesmoke;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp; <span style=3D"background-color:white;">&#8230;</=
span></span></font></div>
<div><font color=3D"#1F3864">&nbsp;</font></div>
<div><font color=3D"#1F3864">&gt;&gt;<font color=3D"black"> If you want to =
suppress the warning, you'll have to edit the source and rebuild.</font></f=
ont></div>
<div><font color=3D"#1F3864">Do you have a guide on how to do this? </font>=
</div>
<div><font color=3D"#1F3864">&nbsp;</font></div>
<div><font color=3D"#1F3864">Or else I have been planning to add <font face=
=3D"Courier New">tr</font> to remove the nuls as suggested by Greg.</font><=
/div>
<div><font color=3D"#1F3864">&nbsp;</font></div>
<div><font color=3D"#1F3864">Regards,</font></div>
<div><font color=3D"#1F3864">Emlyn Jose.</font></div>
<div><font color=3D"#1F3864">&nbsp;</font></div>
<div>----------------------------------------------------------------------=
-----------------------------------</div>
<div>-----Original Message-------------------------------------------------=
------------------------------<br>

From: Chet Ramey [<a href=3D"mailto:chet.ramey@case.edu">mailto:chet.ramey@=
case.edu</a>]
<br>

Sent: Saturday, April 8, 2017 7:48 AM<br>

To: Emlyn Jose (GIS); bug-bash@gnu.org<br>

Cc: chet.ramey@case.edu<br>

Subject: Re: bash 4.4 null byte warning!!</div>
<div>&nbsp;</div>
<div>On 4/6/17 3:47 AM, emlyn.jose@wipro.com wrote:</div>
<div>&gt; Hi,</div>
<div>&gt;</div>
<div>&gt;</div>
<div>&gt;</div>
<div>&gt; We are trying to use the bash 4.4 downloaded from </div>
<div>&gt; <a href=3D"http://ftp.gnu.org/gnu/bash/">http://ftp.gnu.org/gnu/b=
ash/</a> on our RHEL 6.2 machine.</div>
<div>&gt;</div>
<div>&gt; But while using a script that has this command :</div>
<div>&gt;</div>
<div>&gt; FIND_RPM=3D`find /opt/RPM/components -type d -name enum-1.1.6-pri=
nt0`</div>
<div>&gt;</div>
<div>&gt; It throws a warning as below:</div>
<div>&gt;</div>
<div>&gt; bash:warning:command substitution:ignored null byte ininput</div>
<div>&nbsp;</div>
<div>Yes.&nbsp; It drops the null bytes because C strings can't handle them=
.&nbsp; I received bug reports asking why bash silently transforms the comm=
and substitution output and added the warning while not changing the behavi=
or.</div>
<div>&nbsp;</div>
<div>If you want to suppress the warning, you'll have to edit the source an=
d rebuild.</div>
<div>&nbsp;</div>
<div>This does beg the question of why you're using -print0 without somethi=
ng on the receiving end to handle the null bytes.</div>
<div>&nbsp;</div>
<div>--</div>
<div>``The lyf so short, the craft so long to lerne.'' - Chaucer</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp; ``Ars longa, vita brevis'' - Hippocrates</div>
<div>Chet Ramey, UTech, CWRU&nbsp;&nbsp;&nbsp; chet@case.edu&nbsp;&nbsp;&nb=
sp; <a href=3D"http://cnswww.cns.cwru.edu/~chet/"><font color=3D"#0563C1"><=
u>http://cnswww.cns.cwru.edu/~chet/</u></font></a></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>----------------------------------------------------------------------=
----------------------------------------------------------</div>
<div>-----Original Message-------------------------------------------------=
-----------------------------------------------------<br>

From: Greg Wooledge [<a href=3D"mailto:wooledg@eeg.ccf.org">mailto:wooledg@=
eeg.ccf.org</a>]
<br>

Sent: Thursday, April 6, 2017 8:15 PM<br>

To: Emlyn Jose (GIS)<br>

Cc: bug-bash@gnu.org<br>

Subject: Re: bash 4.4 null byte warning!!</div>
<div>&nbsp;</div>
<div>On Thu, Apr 06, 2017 at 07:47:35AM &#43;0000, <a href=3D"mailto:emlyn.=
jose@wipro.com">emlyn.jose@wipro.com</a> wrote:</div>
<div>&gt; FIND_RPM=3D`find /opt/RPM/components -type d -name enum-1.1.6 -pr=
int0` </div>
<div>&gt; It throws a warning as below:</div>
<div>&gt;</div>
<div>&gt; bash: warning: command substitution: ignored null byte in input</=
div>
<div>&nbsp;</div>
<div>Your command is broken, and bash is warning you of this.&nbsp; Why do =
you want to silence the warning instead of fixing the command?</div>
<div>&nbsp;</div>
<div>If your find returns a single result, you get a filename followed by N=
UL, and the NUL is discarded, leaving you a filename inside the command sub=
stitution (and therefore the variable).&nbsp; You could achieve the EXACT s=
ame result by dropping the -print0.&nbsp;
Then, if you get a single result from find, you get the filename followed b=
y newline, and the command substitution discards the trailing newline, leav=
ing you just the filename in the command substitution and therefore the var=
iable.</div>
<div>&nbsp;</div>
<div>On the other hand, if your find command returns MULTIPLE results, then=
 you have file1\000file2\000 and the command substitution drops the NUL byt=
es, leaving you with file1file2 in your variable.&nbsp; At least if you dro=
pped the -print0 you would have file1\nfile2
in your variable, which is still wrong, but not as wrong as file1file2.</di=
v>
<div>&nbsp;</div>
<div>&gt; Is there any patch available for this or is there any way to make=
 bash silently drop this warning(which has been the behavior on the lower v=
ersions of bash)??</div>
<div>&nbsp;</div>
<div>If you REALLY want to continue to run a broken command, you can explic=
itly use tr to remove the NULs before the command substitution ever sees th=
em.</div>
<div>&nbsp;</div>
<div>var=3D$(find ... -print0 | tr -d '\0')</div>
<div>&nbsp;</div>
<div>That will prevent the warning and allow you to continue running a brok=
en script without letting your coworkers catch on to the bugs (or whatever =
your issue with the warning is).</div>
<div>&nbsp;</div>
<div>If you actually want to FIX the script, the results of find should be =
read into an array, since there can be more than one.&nbsp; Every place you=
 use your variable currently, you'd have to rewrite that to handle an array=
 with potentially multiple elements.</div>
<div>&nbsp;</div>
<div><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size:12p=
t;">The information contained in this electronic message and any attachment=
s to this message are intended for the exclusive use of the addressee(s) an=
d may contain proprietary, confidential
or privileged information. If you are not the intended recipient, you shoul=
d not disseminate, distribute or copy this e-mail. Please notify the sender=
 immediately and destroy all copies of this message and any attachments. WA=
RNING: Computer viruses can be transmitted
via email. The recipient should check this email and any attachments for th=
e presence of viruses. The company accepts no liability for any damage caus=
ed by any virus transmitted by this email.
<a href=3D"http://www.wipro.com">www.wipro.com</a> </span></font></div>
</span></font>
</body>
</html>

--_000_HKNPR03MB230852B61B38C92CE8E50BFE88010HKNPR03MB2308apcp_--


From MAILER-DAEMON Mon Apr 10 02:24:18 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxSkM-0001ek-B5
	for mharc-bug-bash@gnu.org; Mon, 10 Apr 2017 02:24:18 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51328)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tgi@home.tgi.org>) id 1cxPmR-0004h5-KJ
	for bug-bash@gnu.org; Sun, 09 Apr 2017 23:14:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <tgi@home.tgi.org>) id 1cxPmO-0001FH-GN
	for bug-bash@gnu.org; Sun, 09 Apr 2017 23:14:15 -0400
Received: from pb-smtp2.pobox.com ([64.147.108.71]:60357
	helo=sasl.smtp.pobox.com)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <tgi@home.tgi.org>) id 1cxPmO-000154-9V
	for bug-bash@gnu.org; Sun, 09 Apr 2017 23:14:12 -0400
Received: from sasl.smtp.pobox.com (unknown [127.0.0.1])
	by pb-smtp2.pobox.com (Postfix) with ESMTP id 3D9F078740;
	Sun,  9 Apr 2017 22:38:55 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to
	:subject:message-id:date; s=sasl; bh=REhuPx/Qrr34XhFEGTKlavXJ+w8
	=; b=PzUgnfhvJA7pRznWpkcwhecYGdPIztqPMhjHNYxmJ6p6maFZVV8y1/ea003
	pyztwhfqahq6qtQzyE8y7Zd+zwVxkXUJ6SAMGGsibu6PZNuyTo6T6xUlbUZ/fHtn
	npiSbwP8pJ5zVFBHg46VwFqAUqFGnvOrODhL4wx6jsEbgc5Q=
Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1])
	by pb-smtp2.pobox.com (Postfix) with ESMTP id 3539A7873F;
	Sun,  9 Apr 2017 22:38:55 -0400 (EDT)
Received: from server-7 (unknown [170.250.54.65])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 86B5C7873E;
	Sun,  9 Apr 2017 22:38:54 -0400 (EDT)
Received: from tgi by server-7 with local (Exim 4.84_2)
	(envelope-from <tgi@home.tgi.org>)
	id 1cxPED-0002RF-4s; Sun, 09 Apr 2017 22:38:53 -0400
From: Craig Strickland <tgi@tgi.org>
To: bug-bash@gnu.org,bash@packages.debian.org
Subject: GLOBIGNORE variable does not function when imported from environment,
	until it's modified
Message-Id: <E1cxPED-0002RF-4s@server-7>
Date: Sun, 09 Apr 2017 22:38:53 -0400
X-Pobox-Relay-ID: D6E3E1EE-1D96-11E7-A4FE-C260AE2156B6-63378906!pb-smtp2.pobox.com
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 64.147.108.71
X-Mailman-Approved-At: Mon, 10 Apr 2017 02:24:17 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 10 Apr 2017 03:14:16 -0000

Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall
uname output: Linux server-7 3.16.0-4-686-pae #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) i686 GNU/Linux
Machine Type: i586-pc-linux-gnu

Bash Version: 4.3
Patch Level: 30
Release Status: release

Description:
	The GLOBIGNORE variable, when not explicitly set, but only imported from the environment, does not function correctly.
	Once any change is made to the GLOBIGNORE variable, even setting it to its current value, then it works.
	This was reproduced with bash 4.3.30(1) on Debian 8.7 "jessie" as well as bash 4.3.39(1) on NetBSD 7.0.1.

Repeat-By:
	$ PS1='$ ' bash --norc
	$ bash --version
	GNU bash, version 4.3.39(1)-release (x86_64--netbsd)
	$ echo $BASH_VERSION
	4.3.39(1)-release
	$ uname -a
	NetBSD sdf 7.0.1_PATCH NetBSD 7.0.1_PATCH (GENERIC.201607220540Z) amd64
	$ ls -la
	total 16
	drwx------   2 tgi  arpa   512 Apr  9 22:12 .
	drwx-----x  10 tgi  arpa  1024 Apr  9 22:11 ..
	-rw-r--r--   1 tgi  arpa     0 Apr  9 22:12 test
	-rw-r--r--   1 tgi  arpa     0 Apr  9 22:12 test2
	-rw-r--r--   1 tgi  arpa     0 Apr  9 22:12 test3
	$ GLOBIGNORE=test
	$ export GLOBIGNORE
	$ echo *
	test2 test3
	$ PS1='\$\$ ' bash --norc
	$$ echo "GLOBIGNORE=[$GLOBIGNORE]"
	GLOBIGNORE=[test]
	$$ echo *
	test test2 test3
	$$ GLOBIGNORE=$GLOBIGNORE
	$$ echo "GLOBIGNORE=[$GLOBIGNORE]"
	GLOBIGNORE=[test]
	$$ echo *
	test2 test3
	$$ ^D
	$ ^D


From MAILER-DAEMON Mon Apr 10 07:30:55 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxXX5-0006WI-Rw
	for mharc-bug-bash@gnu.org; Mon, 10 Apr 2017 07:30:55 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34862)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <reuti@staff.uni-marburg.de>) id 1cxXX2-0006W3-CP
	for bug-bash@gnu.org; Mon, 10 Apr 2017 07:30:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <reuti@staff.uni-marburg.de>) id 1cxXWz-00088u-80
	for bug-bash@gnu.org; Mon, 10 Apr 2017 07:30:52 -0400
Received: from vhrz24.hrz.uni-marburg.de ([137.248.1.34]:35271)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <reuti@staff.uni-marburg.de>)
	id 1cxXWy-00087G-SL
	for bug-bash@gnu.org; Mon, 10 Apr 2017 07:30:49 -0400
Received: from ma15106.chemie.uni-marburg.de (ma15106.Chemie.Uni-Marburg.DE
	[137.248.150.142]) (authenticated bits=0)
	by vhrz24.HRZ.Uni-Marburg.DE (8.14.4/8.14.4/Debian-8+deb8u1) with ESMTP
	id v3ABUSOo040647
	(version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); 
	Mon, 10 Apr 2017 13:30:29 +0200
Subject: Re: bash 4.4 null byte warning!!
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
Content-Type: multipart/signed;
	boundary="Apple-Mail=_8E789822-1F92-4575-B2D4-E43664BD44D1";
	protocol="application/pgp-signature"; micalg=pgp-sha1
X-Pgp-Agent: GPGMail
From: Reuti <reuti@staff.uni-marburg.de>
In-Reply-To: <HKNPR03MB230852B61B38C92CE8E50BFE88010@HKNPR03MB2308.apcprd03.prod.outlook.com>
Date: Mon, 10 Apr 2017 13:30:28 +0200
Cc: Greg Wooledge <wooledg@eeg.ccf.org>, Chet Ramey <chet.ramey@case.edu>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
Message-Id: <9BAE165C-5C36-4745-8932-F7F01E648258@staff.uni-marburg.de>
References: <HKNPR03MB230809726ED57A0E4D87015C880D0@HKNPR03MB2308.apcprd03.prod.outlook.com>
	<20170406144523.GO17132@eeg.ccf.org>
	<HKNPR03MB230852B61B38C92CE8E50BFE88010@HKNPR03MB2308.apcprd03.prod.outlook.com>
To: emlyn.jose@wipro.com
X-Mailer: Apple Mail (2.2104)
X-Null-Tag: 47692b0ea028aa28a8c61e789c465b70
X-UniMR-MailScanner-Information: see
	http://www.uni-marburg.de/hrz/internet/mail/spam/
X-UniMR-MailScanner-ID: v3ABUSOo040647
X-UniMR-MailScanner: Found to be clean
X-UniMR-MailScanner-From: reuti@staff.uni-marburg.de
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 137.248.1.34
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 10 Apr 2017 11:30:54 -0000


--Apple-Mail=_8E789822-1F92-4575-B2D4-E43664BD44D1
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8


> Am 10.04.2017 um 07:08 schrieb emlyn.jose@wipro.com:
>=20
> Hi Greg/Chet Ramey,
>=20
> Thank  you so much for the response! It gave me an idea on what has to =
be done next.
>=20
> We have been using the same script all these years and had no issues =
of broken commands when used with the lower versions of bash which is =
why I have been thinking whether to rewrite the script for the new =
bash(4.4) or edit the bash source.
>=20
> The reason behind using =E2=80=93print0 is to use the resultant output =
to find a binary
>=20
> Below are the lines of code followed by the find command:
>=20
> FIND_RPM=3D"$(find $linIdx -type d -name "${2}" -print0 2>/dev/null)"

Why using -print0 here? You can fill the $FIND_RPM variable also without =
it, the \n is not part of the variable afterwards but you get one long =
line if more than one entry is found (and this couldn't be used below by =
appending /bin).

FIND_RPM=3D"$(find $linIdx -type d -name "${2}" -print -quit)"

if you want only the first one found. And why not searching directly for =
"${2}/bin".

-- Reuti


>         [ -n "$FIND_RPM" ] && \
>             [ -s "${FIND_RPM}/bin" ] && \
>             bdt_msg 4 "[D] Found %s in %s component area." "$2" =
"$linIdx" && \
>                 =E2=80=A6
>                 =E2=80=A6
>=20
> >> If you want to suppress the warning, you'll have to edit the source =
and rebuild.
> Do you have a guide on how to do this?
>=20
> Or else I have been planning to add tr to remove the nuls as suggested =
by Greg.
>=20
> Regards,
> Emlyn Jose.
>=20
> =
--------------------------------------------------------------------------=
-------------------------------
> -----Original =
Message-------------------------------------------------------------------=
------------
> From: Chet Ramey [mailto:chet.ramey@case.edu]
> Sent: Saturday, April 8, 2017 7:48 AM
> To: Emlyn Jose (GIS); bug-bash@gnu.org
> Cc: chet.ramey@case.edu
> Subject: Re: bash 4.4 null byte warning!!
>=20
> On 4/6/17 3:47 AM, emlyn.jose@wipro.com wrote:
> > Hi,
> >
> >
> >
> > We are trying to use the bash 4.4 downloaded from
> > http://ftp.gnu.org/gnu/bash/ on our RHEL 6.2 machine.
> >
> > But while using a script that has this command :
> >
> > FIND_RPM=3D`find /opt/RPM/components -type d -name =
enum-1.1.6-print0`
> >
> > It throws a warning as below:
> >
> > bash:warning:command substitution:ignored null byte ininput
>=20
> Yes.  It drops the null bytes because C strings can't handle them.  I =
received bug reports asking why bash silently transforms the command =
substitution output and added the warning while not changing the =
behavior.
>=20
> If you want to suppress the warning, you'll have to edit the source =
and rebuild.
>=20
> This does beg the question of why you're using -print0 without =
something on the receiving end to handle the null bytes.
>=20
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    =
http://cnswww.cns.cwru.edu/~chet/
>=20
>=20
> =
--------------------------------------------------------------------------=
------------------------------------------------------
> -----Original =
Message-------------------------------------------------------------------=
-----------------------------------
> From: Greg Wooledge [mailto:wooledg@eeg.ccf.org]
> Sent: Thursday, April 6, 2017 8:15 PM
> To: Emlyn Jose (GIS)
> Cc: bug-bash@gnu.org
> Subject: Re: bash 4.4 null byte warning!!
>=20
> On Thu, Apr 06, 2017 at 07:47:35AM +0000, emlyn.jose@wipro.com wrote:
> > FIND_RPM=3D`find /opt/RPM/components -type d -name enum-1.1.6 =
-print0`
> > It throws a warning as below:
> >
> > bash: warning: command substitution: ignored null byte in input
>=20
> Your command is broken, and bash is warning you of this.  Why do you =
want to silence the warning instead of fixing the command?
>=20
> If your find returns a single result, you get a filename followed by =
NUL, and the NUL is discarded, leaving you a filename inside the command =
substitution (and therefore the variable).  You could achieve the EXACT =
same result by dropping the -print0.  Then, if you get a single result =
from find, you get the filename followed by newline, and the command =
substitution discards the trailing newline, leaving you just the =
filename in the command substitution and therefore the variable.
>=20
> On the other hand, if your find command returns MULTIPLE results, then =
you have file1\000file2\000 and the command substitution drops the NUL =
bytes, leaving you with file1file2 in your variable.  At least if you =
dropped the -print0 you would have file1\nfile2 in your variable, which =
is still wrong, but not as wrong as file1file2.
>=20
> > Is there any patch available for this or is there any way to make =
bash silently drop this warning(which has been the behavior on the lower =
versions of bash)??
>=20
> If you REALLY want to continue to run a broken command, you can =
explicitly use tr to remove the NULs before the command substitution =
ever sees them.
>=20
> var=3D$(find ... -print0 | tr -d '\0')
>=20
> That will prevent the warning and allow you to continue running a =
broken script without letting your coworkers catch on to the bugs (or =
whatever your issue with the warning is).
>=20
> If you actually want to FIX the script, the results of find should be =
read into an array, since there can be more than one.  Every place you =
use your variable currently, you'd have to rewrite that to handle an =
array with potentially multiple elements.
>=20
> The information contained in this electronic message and any =
attachments to this message are intended for the exclusive use of the =
addressee(s) and may contain proprietary, confidential or privileged =
information. If you are not the intended recipient, you should not =
disseminate, distribute or copy this e-mail. Please notify the sender =
immediately and destroy all copies of this message and any attachments. =
WARNING: Computer viruses can be transmitted via email. The recipient =
should check this email and any attachments for the presence of viruses. =
The company accepts no liability for any damage caused by any virus =
transmitted by this email.www.wipro.com


--Apple-Mail=_8E789822-1F92-4575-B2D4-E43664BD44D1
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAljrbNQACgkQo/GbGkBRnRqRqgCfa5wFnCSeCEvCYfDNcqA+EkQp
QycAoNRtZde7oYhHiiagHECFsZKfIehY
=nOQx
-----END PGP SIGNATURE-----

--Apple-Mail=_8E789822-1F92-4575-B2D4-E43664BD44D1--


From MAILER-DAEMON Mon Apr 10 09:16:47 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxZBX-0003Ai-BS
	for mharc-bug-bash@gnu.org; Mon, 10 Apr 2017 09:16:47 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58804)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1cxZBW-0003AX-27
	for bug-bash@gnu.org; Mon, 10 Apr 2017 09:16:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1cxZBS-0003R2-3u
	for bug-bash@gnu.org; Mon, 10 Apr 2017 09:16:46 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:40334 helo=svr4.eeg.ccf.org)
	by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1cxZBR-000351-TS
	for bug-bash@gnu.org; Mon, 10 Apr 2017 09:16:42 -0400
Received: (qmail 7023 invoked from network); 10 Apr 2017 13:16:12 -0000
Received: from imadev.eeg.ccf.org (qmailr@10.76.173.78)
	by gateway.eeg.ccf.org with SMTP; Mon, 10 Apr 2017 09:16:12 -0400
Received: (qmail 12478 invoked by uid 563); 10 Apr 2017 13:16:12 -0000
Date: Mon, 10 Apr 2017 09:16:12 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: "emlyn.jose@wipro.com" <emlyn.jose@wipro.com>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Subject: Re: bash 4.4 null byte warning!!
Message-ID: <20170410131611.GP17132@eeg.ccf.org>
References: <HKNPR03MB230809726ED57A0E4D87015C880D0@HKNPR03MB2308.apcprd03.prod.outlook.com>
	<20170406144523.GO17132@eeg.ccf.org>
	<HKNPR03MB230852B61B38C92CE8E50BFE88010@HKNPR03MB2308.apcprd03.prod.outlook.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <HKNPR03MB230852B61B38C92CE8E50BFE88010@HKNPR03MB2308.apcprd03.prod.outlook.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 139.137.100.1
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 10 Apr 2017 13:16:47 -0000

On Mon, Apr 10, 2017 at 05:08:10AM +0000, emlyn.jose@wipro.com wrote:
>  FIND_RPM="$(find $linIdx -type d -name "${2}" -print0 2>/dev/null)"
>         [ -n "$FIND_RPM" ] && \
>             [ -s "${FIND_RPM}/bin" ] && \
>             bdt_msg 4 "[D] Found %s in %s component area." "$2" "$linIdx" && \

"$FIND_RPM/bin" indicates that your code assumes find will only return
a single directory name.  If find returned two things, you would end up
constructing a path like /thing/one/thing/two/bin.

-print0 makes find print a NUL byte after each filename found.  It's used
to safely serialize filenames into an output stream, since filenames may
contain spaces, tabs, newlines, and so on.  In your case, it's not actually
helping you.  If find returns two or more things, your script is already
broken, and the NUL delimiter between filenames won't save you.

The whole time you have been using this script in the past, find has been
adding a NUL byte (because of -print0) and then bash's command substitution
has been silently removing it.  The only thing that changed in 4.4 is now,
when bash removes the NUL, it issues a warning message.  That's all.


From MAILER-DAEMON Mon Apr 10 18:59:19 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxiHH-00061M-QZ
	for mharc-bug-bash@gnu.org; Mon, 10 Apr 2017 18:59:19 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53561)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxiHF-00061G-T8
	for bug-bash@gnu.org; Mon, 10 Apr 2017 18:59:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxiHC-0001Q8-2R
	for bug-bash@gnu.org; Mon, 10 Apr 2017 18:59:18 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:50097
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cxiHB-0001Q4-U0
	for bug-bash@gnu.org; Mon, 10 Apr 2017 18:59:13 -0400
Received: from mpv8-2015.CWRU.Edu (EHLO mpv8-2015.case.edu) ([129.22.103.210])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMP57954; Mon, 10 Apr 2017 18:59:06 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv8-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GWZ13226 (AUTH cpr);
	Mon, 10 Apr 2017 18:59:05 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu, "bug-bash@gnu.org" <bug-bash@gnu.org>
Subject: Re: bash 4.4 null byte warning!!
To: "emlyn.jose@wipro.com" <emlyn.jose@wipro.com>,
	Greg Wooledge <wooledg@eeg.ccf.org>
References: <HKNPR03MB230809726ED57A0E4D87015C880D0@HKNPR03MB2308.apcprd03.prod.outlook.com>
	<20170406144523.GO17132@eeg.ccf.org>
	<HKNPR03MB230852B61B38C92CE8E50BFE88010@HKNPR03MB2308.apcprd03.prod.outlook.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <a8dbc09a-a588-42c5-faab-c2b0d1fa5c91@case.edu>
Date: Mon, 10 Apr 2017 18:59:04 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <HKNPR03MB230852B61B38C92CE8E50BFE88010@HKNPR03MB2308.apcprd03.prod.outlook.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 10 Apr 2017 22:59:19 -0000

On 4/10/17 1:08 AM, emlyn.jose@wipro.com wrote:

>>>If you want to suppress the warning, you'll have to edit the source and
> rebuild.
> Do you have a guide on how to do this?

Change the #if 1 on line 5966 of subst.c to #if 0.  Then follow the
directions in INSTALL, which basically consist of the usual
`configure ; make ; make install' idiom common to GNU software.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Mon Apr 10 20:53:49 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxk45-0001WQ-K7
	for mharc-bug-bash@gnu.org; Mon, 10 Apr 2017 20:53:49 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40007)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxk42-0001WJ-Aw
	for bug-bash@gnu.org; Mon, 10 Apr 2017 20:53:47 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxk3x-0005Yc-GK
	for bug-bash@gnu.org; Mon, 10 Apr 2017 20:53:46 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:58815
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cxk3x-0005Xg-AX
	for bug-bash@gnu.org; Mon, 10 Apr 2017 20:53:41 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMP60484; Mon, 10 Apr 2017 20:53:35 -0400 (EDT)
Received: from h122.68.21.98.dynamic.ip.windstream.net (EHLO _192.168.254.13_)
	([98.21.68.122]) by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id GWO69039 (AUTH cpr);
	Mon, 10 Apr 2017 20:53:34 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: extra field in $* expansion when non-whitespace character in IFS
To: Grisha Levit <grishalevit@gmail.com>, bug-bash <bug-bash@gnu.org>
References: <CAMu=BroF1r7=Edmqj8KqCT5naWq6K2SR2A=O+QSgwk+TYMqBoA@mail.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <f2701c58-1eaa-34e2-cf23-27ae48707fa4@case.edu>
Date: Mon, 10 Apr 2017 20:53:34 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0
MIME-Version: 1.0
In-Reply-To: <CAMu=BroF1r7=Edmqj8KqCT5naWq6K2SR2A=O+QSgwk+TYMqBoA@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 11 Apr 2017 00:53:47 -0000

On 4/9/17 7:35 PM, Grisha Levit wrote:
> In most cases, removing a non-whitespace IFS character "delimits" a field
> in the sense that it terminates it, so the presence of such a character at
> the end of a field does not change its expansion:
> 
>   $ IFS=X
>   $ set -- Y; printf '<%s>' $*
>   <Y>
>   $ set -- YX; IFS=X; printf '<%s>' $*
>   <Y>
> 
> However, when a positional parameter ends with a non-whitespace IFS character
> and is followed by another positional parameter, the removal of the IFS
> character seems to create an additional field:
> 
>   $ set -- YX Y; printf '<%s>' $*
>   <Y><><Y>
> 
> Is this intentional? It sort of makes sense since $* is expanded as if it
> were $1c$2 (where c is the first character of IFS), i.e. the expansion above
> matches what is produced by
> 
>   set -- YX Y; v=$*; printf '<%s>' $v
> 
> but that doesn't seem to respect the prescribed behavior of first producing
> a field for each positional parameter, and then subjecting each field to
> field splitting.

I seem to recall this being part of a discussion on the austin group list
years ago. It had to do with the behavior of IFS as a field terminator
and non-whitespace characters in IFS creating null fields (conveniently).

The bash behavior agrees with the latest versions of dash and mksh, and
ksh93 had plenty of issues in this area (plus it doesn't seem to be under
active development, so it would not have changed as a result of any of
these discussions).  I'm going to leave things as they are.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Tue Apr 11 09:21:34 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cxvji-0003zR-4b
	for mharc-bug-bash@gnu.org; Tue, 11 Apr 2017 09:21:34 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52021)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxvjf-0003wo-4o
	for bug-bash@gnu.org; Tue, 11 Apr 2017 09:21:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cxvjc-000897-0u
	for bug-bash@gnu.org; Tue, 11 Apr 2017 09:21:31 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:44217
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cxvjb-00088o-So
	for bug-bash@gnu.org; Tue, 11 Apr 2017 09:21:27 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMP75138; Tue, 11 Apr 2017 09:21:25 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCM65952 (AUTH cpr);
	Tue, 11 Apr 2017 09:21:24 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: GLOBIGNORE variable does not function when imported from
	environment, until it's modified
References: <E1cxPED-0002RF-4s@server-7>
To: Craig Strickland <tgi@tgi.org>, bug-bash@gnu.org, bash@packages.debian.org
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <7a7fb02c-54dc-0ce3-86f1-0f5cfe03a790@case.edu>
Date: Tue, 11 Apr 2017 09:21:23 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <E1cxPED-0002RF-4s@server-7>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 11 Apr 2017 13:21:32 -0000

On 4/9/17 10:38 PM, Craig Strickland wrote:

> Bash Version: 4.3
> Patch Level: 30
> Release Status: release
> 
> Description:
> 	The GLOBIGNORE variable, when not explicitly set, but only imported from the environment, does not function correctly.
> 	Once any change is made to the GLOBIGNORE variable, even setting it to its current value, then it works.
> 	This was reproduced with bash 4.3.30(1) on Debian 8.7 "jessie" as well as bash 4.3.39(1) on NetBSD 7.0.1.

Yes, GLOBIGNORE doesn't have any effect when it appears in the environment.
It makes shell scripts fail in erratic and unpredictable ways.  If you
want to use GLOBIGNORE, you have to do something affirmative.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Wed Apr 12 08:27:19 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyHMl-0007TA-6S
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 08:27:19 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43708)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chrlis@sbrella.com>) id 1cyCh3-0008Ra-LX
	for bug-bash@gnu.org; Wed, 12 Apr 2017 03:27:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chrlis@sbrella.com>) id 1cyCh0-0001UN-Gf
	for bug-bash@gnu.org; Wed, 12 Apr 2017 03:27:57 -0400
Received: from smtpbguseast2.qq.com ([54.204.34.130]:42290)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <chrlis@sbrella.com>) id 1cyCh0-0001Tu-BS
	for bug-bash@gnu.org; Wed, 12 Apr 2017 03:27:54 -0400
X-QQ-GoodBg: 0
X-QQ-SSF: 00100000000000F0
X-QQ-FEAT: 9NFkmNiL4heHOxWQ1nUt7LecLJ5M401FahMnwdLg/IvI+WlwVNy1E+XpIJ+7z
	YOz0umnfPTQbqZsp5ZaUaxLncgwDFfLwhks3wJOiXFLGi3CaATOAuTLYejwDqWSmHxFtD1T
	4sJNdRLdiAAOI66dqRRxJiINScpReu4Ix0DaxQr91oWOIEeJQpXXqRVN7LkHeHxDTgKgfVb
	Xbcx1O9SCcYyvagTlOLqEaU7LwLkxFCo1d5poDajFC01o4yqXN+sY+XfmKCYJBFZoJ3Nr8m
	oKPw==
X-QQ-BUSINESS-ORIGIN: 2
X-Originating-IP: 183.16.162.191
X-QQ-STYLE: 
X-QQ-mid: bizmailfree75t1491982063t8874
From: "=?utf-8?B?Y2hybGlz?=" <chrlis@sbrella.com>
To: "=?utf-8?B?YnVnLWJhc2g=?=" <bug-bash@gnu.org>
Subject: The clean opt can not delete all objs(like *.o)
Mime-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_58EDD6EF_0B187270_17A54F24"
Content-Transfer-Encoding: 8Bit
Date: Wed, 12 Apr 2017 15:27:43 +0800
X-Priority: 3
Message-ID: <tencent_6AB7B3457385A9BC22BD2D92@qq.com>
X-QQ-MIME: TCMime 1.0 by Tencent
X-Mailer: QQMail 2.x
X-QQ-Mailer: QQMail 2.x
X-QQ-SENDSIZE: 520
X-QQ-Bgrelay: 1
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 54.204.34.130
X-Mailman-Approved-At: Wed, 12 Apr 2017 08:27:17 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 07:27:58 -0000

This is a multi-part message in MIME format.

------=_NextPart_58EDD6EF_0B187270_17A54F24
Content-Type: text/plain;
	charset="utf-8"
Content-Transfer-Encoding: base64

SSBmaW5kIGEgc3BlY2lhbCBjYXNlOg0KLT5jZCBiYXNoLTQuNA0KLT5ta2RpciBidWlsZCAN
Ci0+Y2QgYnVpbGQNCi0+Li4uDQotPm1ha2UgY2xlYW4NCg0KV2hlbiBJIG1ha2UgY2xlYW4g
Y3VycmVudCBidWlsZGluZyBkaXJlY3RvcnksIGl0IG5ldmVyIHJlbW92ZSB0aGUgb2JqZWN0
ICdtYW4yaHRtbC5vJyBpbiB0aGUgcGF0aCAvcGF0aC90by9idWlsZC9zdXBwb3J0Lg0KSXMg
dGhpcyBhIHByb2JsZW0gPyANCg0KVGhlIHJlbGVhc2VkIGJhc2ggc291cmNlIGNvZGUgdmVy
c2lvbiBpczogaHR0cHM6Ly9mdHAuZ251Lm9yZy9nbnUvYmFzaC9iYXNoLTQuNC50YXIuZ3o=

------=_NextPart_58EDD6EF_0B187270_17A54F24
Content-Type: text/html;
	charset="utf-8"
Content-Transfer-Encoding: base64

PHNwYW4gc3R5bGU9ImZvbnQtZmFtaWx5OiDlrovkvZM7Ij48Zm9udCBzaXplPSI0Ij5JIGZp
bmQgYSBzcGVjaWFsIGNhc2U6PGJyPi0mZ3Q7Y2QgPC9mb250Pjwvc3Bhbj48c3BhbiBzdHls
ZT0iZm9udC1mYW1pbHk6IOWui+S9kzsiPjxmb250IHNpemU9IjQiPjxzcGFuIHN0eWxlPSJj
b2xvcjogcmdiKDE0NCwgMTQ0LCAxNDQpOyI+PHNwYW4gc3R5bGU9ImZvbnQtZmFtaWx5OiBB
cmlhbCBOYXJyb3c7Ij48c3BhbiBzdHlsZT0iY29sb3I6IHJnYigwLCAwLCAwKTsiPjxzcGFu
IHN0eWxlPSJmb250LWZhbWlseTog5a6L5L2TOyI+PGZvbnQgc2l6ZT0iNCI+YmFzaC00LjQ8
YnI+LSZndDtta2RpciBidWlsZCA8YnI+LSZndDtjZCBidWlsZDxicj4tJmd0Oy4uLjxicj4t
Jmd0O21ha2UgY2xlYW48YnI+PGJyPjwvZm9udD48L3NwYW4+PC9zcGFuPjwvc3Bhbj48L3Nw
YW4+V2hlbiBJIG1ha2UgY2xlYW4gY3VycmVudCBidWlsZGluZyBkaXJlY3RvcnksIGl0IG5l
dmVyIHJlbW92ZSB0aGUgb2JqZWN0ICdtYW4yaHRtbC5vJyBpbiB0aGUgcGF0aCAvcGF0aC90
by9idWlsZC9zdXBwb3J0Ljxicj5JcyB0aGlzIGEgcHJvYmxlbSA/IDxicj48L2ZvbnQ+PC9z
cGFuPjxzcGFuIHN0eWxlPSJjb2xvcjogcmdiKDE0NCwgMTQ0LCAxNDQpOyI+PHNwYW4gc3R5
bGU9ImZvbnQtZmFtaWx5OiBBcmlhbCBOYXJyb3c7Ij48c3BhbiBzdHlsZT0iY29sb3I6IHJn
YigwLCAwLCAwKTsiPjxzcGFuIHN0eWxlPSJmb250LWZhbWlseTog5a6L5L2TOyI+PGZvbnQg
c2l6ZT0iNCI+PGJyPlRoZSByZWxlYXNlZCBiYXNoIHNvdXJjZSBjb2RlIHZlcnNpb24gaXM6
IGh0dHBzOi8vZnRwLmdudS5vcmcvZ251L2Jhc2gvYmFzaC00LjQudGFyLmd6PC9mb250Pjwv
c3Bhbj48L3NwYW4+PGJyPjxicj48L3NwYW4+PC9zcGFuPjxkaXY+PGluY2x1ZGV0YWlsPjwh
LS08IVtlbmRpZl0tLT48L2luY2x1ZGV0YWlsPjwvZGl2Pg==

------=_NextPart_58EDD6EF_0B187270_17A54F24--





From MAILER-DAEMON Wed Apr 12 08:57:42 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyHq9-0006lM-VQ
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 08:57:41 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:44448)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyHq7-0006kq-W0
	for bug-bash@gnu.org; Wed, 12 Apr 2017 08:57:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyHq7-0001uO-4q
	for bug-bash@gnu.org; Wed, 12 Apr 2017 08:57:40 -0400
Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:33963)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cyHq7-0001uK-1B
	for bug-bash@gnu.org; Wed, 12 Apr 2017 08:57:39 -0400
Received: by mail-qk0-x22c.google.com with SMTP id p68so22123882qke.1
	for <bug-bash@gnu.org>; Wed, 12 Apr 2017 05:57:38 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:from:date:message-id:subject:to;
	bh=iBN9iuzT4H1gaxTw6z9gYi6hzDSqi+epK1UgvSEW8HA=;
	b=KstpXc4suBVCvHM1b5uvgdQkzSTkb77yAN8oRbLso/HiPGDBC3/6i4iHKziZ1AvrRz
	stVskXYs8mNYePTfDcGjau66gqY091jriZeSoIl+TQlhr+kMcJtR1AThvm+J9Dkf2OMQ
	RfWYQwiv2R3/kSxbOBVZ/ygaLg0u+g8ufs5Fs=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=iBN9iuzT4H1gaxTw6z9gYi6hzDSqi+epK1UgvSEW8HA=;
	b=HPML8v/XKbijlD8ZMGeWS/aMTSg5buMqILXVgiP4Jl+vxR+7eaIRjvFMeZEroxuaWc
	0Xh/PdeOt3m63Zr9i3XixwLApWCzB50eji2y3NAp43CHhEHF6p1Vf0tM8aFQUJcyNzKV
	1pNyiySszqFMNnv09EL+ATfLSdr7vJYS8W+ksvrI0pwkRxVJIb03T4vHQPwJdcO8ZqUk
	Zfa8qac0AR/mbBW5uO6hKWwcZmVr5vACb5Vrt1vr7381Q3Uf66V4A1mXNnyBrqZr6pSc
	VvAKn95OyYeiT22fJs8uB+t02wJavp/DTj12LS/5QL/WSWxEBr2WTB6IUNbvNCstZqZv
	ku8w==
X-Gm-Message-State: AN3rC/5VbX4pYdJDEhlH6dG5uW5aEDNIis0KkxkbgFloOZV4zbVvSBYziW8omEdqaU3wTgCHV2PaoNoz106wHW/I
X-Received: by 10.55.160.143 with SMTP id j137mr32866688qke.119.1492001858185; 
	Wed, 12 Apr 2017 05:57:38 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Wed, 12 Apr 2017 05:57:37 -0700 (PDT)
From: Reuben Thomas <rrt@sc3d.org>
Date: Wed, 12 Apr 2017 13:57:37 +0100
Message-ID: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
Subject: Running bash under valgrind gives "invalid free()"
To: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a114fc824c35220054cf7c064
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::22c
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 12:57:41 -0000

--001a114fc824c35220054cf7c064
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D849517

=E2=80=8BI can reproduce this also in bash 4.3 as supplied with Ubuntu 16.0=
4, and
in a build of 4.4 from source on my Ubuntu system.

=E2=80=8BAs stated in the bug report, the bug causes problems beyond bash, =
as it
causes build systems to think that valgrind is not working, and hence run
tests without it.

I searched the bug-bash archives and couldn't find a previous report of
this particular problem (I found mentions of other valgrind diagnostics).

--=20
http://rrt.sc3d.org

--001a114fc824c35220054cf7c064
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-size:small">See=
 <a href=3D"https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D849517">htt=
ps://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D849517</a><br></div><br><d=
iv style=3D"font-size:small" class=3D"gmail_default">=E2=80=8BI can reprodu=
ce this also in bash 4.3 as supplied with Ubuntu 16.04, and in a build of 4=
.4 from source on my Ubuntu system.<br><br></div><div style=3D"font-size:sm=
all" class=3D"gmail_default">=E2=80=8BAs stated in the bug report, the bug =
causes problems beyond bash, as it causes build systems to think that valgr=
ind is not working, and hence run tests without it.<br><br></div><div style=
=3D"font-size:small" class=3D"gmail_default">I searched the bug-bash archiv=
es and couldn&#39;t find a previous report of this particular problem (I fo=
und mentions of other valgrind diagnostics).<br></div><br>-- <br><div class=
=3D"gmail_signature"><a href=3D"http://rrt.sc3d.org" target=3D"_blank">http=
://rrt.sc3d.org</a></div>
</div>

--001a114fc824c35220054cf7c064--


From MAILER-DAEMON Wed Apr 12 09:13:20 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyI5I-0003bo-2M
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 09:13:20 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49758)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyI5F-0003bc-5q
	for bug-bash@gnu.org; Wed, 12 Apr 2017 09:13:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyI5A-0007TG-7k
	for bug-bash@gnu.org; Wed, 12 Apr 2017 09:13:17 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:4331
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cyI5A-0007Sz-3Y
	for bug-bash@gnu.org; Wed, 12 Apr 2017 09:13:12 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALG28040; Wed, 12 Apr 2017 09:13:05 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCZ29734 (AUTH cpr);
	Wed, 12 Apr 2017 09:13:05 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: The clean opt can not delete all objs(like *.o)
References: <tencent_6AB7B3457385A9BC22BD2D92@qq.com>
To: chrlis <chrlis@sbrella.com>, bug-bash <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <ae9c0b72-4fd7-b58a-6ac7-6d79c8202252@case.edu>
Date: Wed, 12 Apr 2017 09:13:01 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <tencent_6AB7B3457385A9BC22BD2D92@qq.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv4-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 13:13:18 -0000

On 4/12/17 3:27 AM, chrlis wrote:
> I find a special case:
> ->cd bash-4.4
> ->mkdir build
> ->cd build
> ->...
> ->make clean
> 
> When I make clean current building directory, it never remove the object
> 'man2html.o' in the path /path/to/build/support.
> Is this a problem ?

Thanks for the report.  I'll take a look.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Wed Apr 12 09:50:57 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyIfh-0006Jg-8e
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 09:50:57 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59883)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyIfb-0006GT-DI
	for bug-bash@gnu.org; Wed, 12 Apr 2017 09:50:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyIfY-0003jM-Ap
	for bug-bash@gnu.org; Wed, 12 Apr 2017 09:50:51 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:36669
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cyIfY-0003j3-4w
	for bug-bash@gnu.org; Wed, 12 Apr 2017 09:50:48 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AML08592; Wed, 12 Apr 2017 09:50:46 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCZ39576 (AUTH cpr);
	Wed, 12 Apr 2017 09:50:46 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>, Bash - Bug <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
Date: Wed, 12 Apr 2017 09:50:45 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 13:50:55 -0000

On 4/12/17 8:57 AM, Reuben Thomas wrote:
> See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=849517
> 
> â€‹I can reproduce this also in bash 4.3 as supplied with Ubuntu 16.04, and
> in a build of 4.4 from source on my Ubuntu system.
> 
> â€‹As stated in the bug report, the bug causes problems beyond bash, as it
> causes build systems to think that valgrind is not working, and hence run
> tests without it.

Look at it this way: if the "bug" can't be reproduced on another OS, or
can't be reproduced using a debugging malloc library other than valgrind,
that points the finger at valgrind or Debian.

For instance, here's what happens when you run valgrind on bash-4.4.12
under RHEL6:

$ valgrind --leak-check=full ./bash -c ''
==12098== Memcheck, a memory error detector
==12098== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==12098== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==12098== Command: ./bash -c
==12098==
==12098==
==12098== HEAP SUMMARY:
==12098==     in use at exit: 0 bytes in 0 blocks
==12098==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==12098==
==12098== All heap blocks were freed -- no leaks are possible
==12098==
==12098== For counts of detected and suppressed errors, rerun with: -v
==12098== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)

Running the same command using bash's builtin malloc library, which catches
things like invalid frees, or the MacOS X debugging malloc, doesn't produce
that error.

I'll take another look, but it would help if there were some more detail
in the report besides `???'.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Wed Apr 12 09:59:32 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyIo0-0001Q9-0s
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 09:59:32 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33414)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyInx-0001Q1-Fd
	for bug-bash@gnu.org; Wed, 12 Apr 2017 09:59:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyInw-0006mA-6N
	for bug-bash@gnu.org; Wed, 12 Apr 2017 09:59:29 -0400
Received: from mail-qk0-x231.google.com ([2607:f8b0:400d:c09::231]:33361)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cyInw-0006lv-04
	for bug-bash@gnu.org; Wed, 12 Apr 2017 09:59:28 -0400
Received: by mail-qk0-x231.google.com with SMTP id h67so23815120qke.0
	for <bug-bash@gnu.org>; Wed, 12 Apr 2017 06:59:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=yDGvVAkRbOP3RAr1BHO+erx0e7uCHUysZpJdVvwEW+4=;
	b=h0eYJA3HMVYq/awenk6YP2eW/Kb9Edlvc2ad9epESVLTwtxb9OeV++2hG2T0iMYSwQ
	ZAzQwfNSnLqbUMXtBb6TSutewD7GEVhiRtxefdR6I5xPZtJEusKQrqBiIwUolS80VOXr
	LgyNG6a10ua147hItGLc2Ml95mDSMOmrji1xA=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=yDGvVAkRbOP3RAr1BHO+erx0e7uCHUysZpJdVvwEW+4=;
	b=jO+NZS3IGh/kxT1E7P6epaZM6X6x040Kjy1g+MXVzpoV16EtiFFLB7kz7K8LR+ESJE
	ITkUAMR33neWqrzyithQoe5d8xJPS/vvRBaXY22TOtUn9DBwGwNjuctIBTSZy8AGqaYv
	JgHdYcI8MrXWt7ZgTW3y7/q4xRY5FOuqX/UVykNeIJVxSmyWShlcdE1OVsEQw26z0C5+
	rWh+W0qJotQCWG4+x859lKOed29oJvVRnmQW8Fwv84SHuZ9drvQvI3evLzeGCJq+e+Xg
	ETddLl0WqLVqlK532JcoPhF7rD9tMYDsygaICQiff1XgK2gi1DblaA35JCwZeMuGpwBN
	ggwA==
X-Gm-Message-State: AFeK/H2UuTI8cRtumiHvs43u/zSOEoWweAIJWp89SlM63zAqkUhcxAHc3zfvhQMnmqHQj3f5MeNKJmRGwhQYCbMp
X-Received: by 10.55.147.131 with SMTP id v125mr57770475qkd.39.1492005567091; 
	Wed, 12 Apr 2017 06:59:27 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Wed, 12 Apr 2017 06:59:26 -0700 (PDT)
In-Reply-To: <91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
From: Reuben Thomas <rrt@sc3d.org>
Date: Wed, 12 Apr 2017 14:59:26 +0100
Message-ID: <CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=94eb2c08bb92d47026054cf89ddb
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::231
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 13:59:30 -0000

--94eb2c08bb92d47026054cf89ddb
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

=E2=80=8BO=E2=80=8B
n 12 April 2017 at 14:50, Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/12/17 8:57 AM, Reuben Thomas wrote:
> > See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D849517
> >
> > =E2=80=8BI can reproduce this also in bash 4.3 as supplied with Ubuntu =
16.04, and
> > in a build of 4.4 from source on my Ubuntu system.
> >
> > =E2=80=8BAs stated in the bug report, the bug causes problems beyond ba=
sh, as it
> > causes build systems to think that valgrind is not working, and hence r=
un
> > tests without it.
>
> Look at it this way: if the "bug" can't be reproduced on another OS, or
> can't be reproduced using a debugging malloc library other than valgrind,
> that points the finger at valgrind or Debian.
>

=E2=80=8BApologies, I didn't think of reproducibility on other OSes. (Thoug=
h the
point about valgrind is not a strong one: =E2=80=8B
=E2=80=8B
=E2=80=8Bfrequently, it's the only tool that shows up bugs of this sort, as=
 it's
rather more powerful than a debugging malloc library.)

Apologies also for not noticing that the backtrace was lacking. I've
installed debugging symbols here and obtained:

=3D=3D19358=3D=3D Invalid free() / delete / delete[] / realloc()
=3D=3D19358=3D=3D    at 0x4C2ED5B: free (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
=3D=3D19358=3D=3D    by 0x45E1D0: unwind_frame_run_internal.constprop.3
(unwind_prot.c:301)
=3D=3D19358=3D=3D    by 0x45E37F: without_interrupts (unwind_prot.c:107)
=3D=3D19358=3D=3D    by 0x45E37F: run_unwind_frame (unwind_prot.c:135)
=3D=3D19358=3D=3D    by 0x47B664: parse_and_execute (evalstring.c:421)
=3D=3D19358=3D=3D    by 0x4209D6: run_one_command (shell.c:1348)
=3D=3D19358=3D=3D    by 0x41F893: main (shell.c:695)
=3D=3D19358=3D=3D  Address 0x423b6e8 is in the brk data segment 0x4228000-0=
x423bfff
=E2=80=8B
Do let me know if there's anything else useful I can do.

--94eb2c08bb92d47026054cf89ddb
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div=
 style=3D"font-size:small;display:inline" class=3D"gmail_default">=E2=80=8B=
O=E2=80=8B</div>n 12 April 2017 at 14:50, Chet Ramey <span dir=3D"ltr">&lt;=
<a href=3D"mailto:chet.ramey@case.edu" target=3D"_blank">chet.ramey@case.ed=
u</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex=
"><span class=3D"gmail-">On 4/12/17 8:57 AM, Reuben Thomas wrote:<br>
&gt; See <a href=3D"https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D849=
517" rel=3D"noreferrer" target=3D"_blank">https://bugs.debian.org/cgi-<wbr>=
bin/bugreport.cgi?bug=3D849517</a><br>
&gt;<br>
&gt; =E2=80=8BI can reproduce this also in bash 4.3 as supplied with Ubuntu=
 16.04, and<br>
&gt; in a build of 4.4 from source on my Ubuntu system.<br>
&gt;<br>
&gt; =E2=80=8BAs stated in the bug report, the bug causes problems beyond b=
ash, as it<br>
&gt; causes build systems to think that valgrind is not working, and hence =
run<br>
&gt; tests without it.<br>
<br>
</span>Look at it this way: if the &quot;bug&quot; can&#39;t be reproduced =
on another OS, or<br>
can&#39;t be reproduced using a debugging malloc library other than valgrin=
d,<br>
that points the finger at valgrind or Debian.<br></blockquote><div><br><div=
 style=3D"font-size:small;display:inline" class=3D"gmail_default">=E2=80=8B=
Apologies, I didn&#39;t think of reproducibility on other OSes. (Though the=
 point about valgrind is not a strong one: =E2=80=8B</div>=E2=80=8B<div sty=
le=3D"font-size:small;display:inline" class=3D"gmail_default">=E2=80=8Bfreq=
uently, it&#39;s the only tool that shows up bugs of this sort, as it&#39;s=
 rather more powerful than a debugging malloc library.)<br><br></div><div s=
tyle=3D"font-size:small;display:inline" class=3D"gmail_default">Apologies a=
lso for not noticing that the backtrace was lacking. I&#39;ve installed deb=
ugging symbols here and obtained:<br><br>=3D=3D19358=3D=3D Invalid free() /=
 delete / delete[] / realloc()<br>=3D=3D19358=3D=3D=C2=A0=C2=A0=C2=A0 at 0x=
4C2ED5B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)<br>=
=3D=3D19358=3D=3D=C2=A0=C2=A0=C2=A0 by 0x45E1D0: unwind_frame_run_internal.=
constprop.3 (unwind_prot.c:301)<br>=3D=3D19358=3D=3D=C2=A0=C2=A0=C2=A0 by 0=
x45E37F: without_interrupts (unwind_prot.c:107)<br>=3D=3D19358=3D=3D=C2=A0=
=C2=A0=C2=A0 by 0x45E37F: run_unwind_frame (unwind_prot.c:135)<br>=3D=3D193=
58=3D=3D=C2=A0=C2=A0=C2=A0 by 0x47B664: parse_and_execute (evalstring.c:421=
)<br>=3D=3D19358=3D=3D=C2=A0=C2=A0=C2=A0 by 0x4209D6: run_one_command (shel=
l.c:1348)<br>=3D=3D19358=3D=3D=C2=A0=C2=A0=C2=A0 by 0x41F893: main (shell.c=
:695)<br>=3D=3D19358=3D=3D=C2=A0 Address 0x423b6e8 is in the brk data segme=
nt 0x4228000-0x423bfff<br>=E2=80=8B<br></div><div style=3D"font-size:small;=
display:inline" class=3D"gmail_default">Do let me know if there&#39;s anyth=
ing else useful I can do.<br></div></div></div></div></div>

--94eb2c08bb92d47026054cf89ddb--


From MAILER-DAEMON Wed Apr 12 10:49:41 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyJaX-0000fx-L8
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 10:49:41 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49262)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyJaV-0000fr-C3
	for bug-bash@gnu.org; Wed, 12 Apr 2017 10:49:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyJaR-00088X-EI
	for bug-bash@gnu.org; Wed, 12 Apr 2017 10:49:39 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:46669
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cyJaR-00088L-8b
	for bug-bash@gnu.org; Wed, 12 Apr 2017 10:49:35 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMQ32913; Wed, 12 Apr 2017 10:49:33 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCO70129 (AUTH cpr);
	Wed, 12 Apr 2017 10:49:33 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <908939d3-54e7-1991-1b83-b0970196c140@case.edu>
Date: Wed, 12 Apr 2017 10:49:33 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 14:49:40 -0000

On 4/12/17 9:59 AM, Reuben Thomas wrote:
> â€‹Oâ€‹
> n 12 April 2017 at 14:50, Chet Ramey <chet.ramey@case.edu
> <mailto:chet.ramey@case.edu>> wrote:
> 
>     On 4/12/17 8:57 AM, Reuben Thomas wrote:
>     > See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=849517
>     <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=849517>
>     >
>     > â€‹I can reproduce this also in bash 4.3 as supplied with Ubuntu 16.04, and
>     > in a build of 4.4 from source on my Ubuntu system.
>     >
>     > â€‹As stated in the bug report, the bug causes problems beyond bash, as it
>     > causes build systems to think that valgrind is not working, and hence run
>     > tests without it.
> 
>     Look at it this way: if the "bug" can't be reproduced on another OS, or
>     can't be reproduced using a debugging malloc library other than valgrind,
>     that points the finger at valgrind or Debian.
> 
> 
> â€‹Apologies, I didn't think of reproducibility on other OSes. (Though the
> point about valgrind is not a strong one: â€‹

It's a false positive, or a bug in valgrind. I took a quick look.  There's
one place in this code path where free() gets called.  Here's the trace:

1. the -c option causes run_one_command() to call parse_and_execute() with
   a dynamically-allocated string. Let's say its address is 0x7bd218

2. parse_and_execute calls parse_prologue with that string as the "string"
   argument. The value of "string" is still 0x7bd218.

3. parse_prologue assigns the value of string to "orig_string". orig_string
   still has the value 0x7bd218.

4. parse_prologue calls add_unwind_protect to arrange for that memory to be
   freed.  The unwind-protect structure that gets created has (simplified)
	uwp->cleanup = xfree
	uwp->argument = orig_string (still with the value 0x7bd218)

5. parse_and_execute runs the command, and calls run_unwind_frame. That
   calls each cleanup function in turn. xfree() gets called with a pointer
   whose value is 0x7bd218, frees it, and returns.

Before you ask, the string in step 1 is allocated by savestring(), which is
defined as

define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))

There's no place where that value is part of a data segment.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Wed Apr 12 10:59:31 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyJk3-0002U3-QM
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 10:59:31 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51483)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyJk0-0002TQ-TQ
	for bug-bash@gnu.org; Wed, 12 Apr 2017 10:59:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyJk0-0002N3-5Z
	for bug-bash@gnu.org; Wed, 12 Apr 2017 10:59:28 -0400
Received: from mail-qk0-x22a.google.com ([2607:f8b0:400d:c09::22a]:33798)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cyJjz-0002Mf-U3
	for bug-bash@gnu.org; Wed, 12 Apr 2017 10:59:28 -0400
Received: by mail-qk0-x22a.google.com with SMTP id p68so25432298qke.1
	for <bug-bash@gnu.org>; Wed, 12 Apr 2017 07:59:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=MGTTClg4tdWBIZeEMhg+o1W2FXATcyV/Y2eCE9ZIYzA=;
	b=icMCt50YoBxmLejo0crW+6K74kAytIjgU71m9nNVx0taOW1kYNHyHfPkAKKK7iErPB
	Gkjgndy/ZwayTU7jE98BPyMw60CDwKPCwyf754dEmCdJHC+EMRC2xikFeZt/2xlLXjaO
	+HBZV9k4AzDNmIflC0KuwCGSms9RoJaURi9Tc=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=MGTTClg4tdWBIZeEMhg+o1W2FXATcyV/Y2eCE9ZIYzA=;
	b=kbqEFJHyrgoxhfx8oiRDP0s79VgOgPqbYf0Cnh/e80+MTblIy3YuberqkCznQH7sPH
	XMlgqBpO++4lGvRDeF13Cwga09bjiiIQqlEiG0VgJZmUTRUcFmAvyc9vkQfSy4tPqYPW
	fE9Dd8bAu+rI+Uosv20WriHOeNVXi6TCFl6nv3Wj3THI05YdsUL185VFFAzFHQbVZyZ5
	K4jWexNSdAPkXO4+8EK8ND6pSaSwgnsIOYXW4LXn8G5gThiSdIAMpAghR4yBC0jCMP4y
	/Qv3ym2dRcJexdOXzFmdFGNPY5Z2ZfgGy2ONbEeFPOFawr02bqDx4f0S8Ym1LkGke6SD
	dHRw==
X-Gm-Message-State: AN3rC/4CNdOZdLTpNyV27YamO/i6oyyCdQORm/Zc8A6XpQxcpCBMk1xC5/TLs0EZ0JYcu5zp+VnWzWWETQWF5cR1
X-Received: by 10.55.160.143 with SMTP id j137mr33422246qke.119.1492009166847; 
	Wed, 12 Apr 2017 07:59:26 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Wed, 12 Apr 2017 07:59:26 -0700 (PDT)
In-Reply-To: <908939d3-54e7-1991-1b83-b0970196c140@case.edu>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
From: Reuben Thomas <rrt@sc3d.org>
Date: Wed, 12 Apr 2017 15:59:26 +0100
Message-ID: <CAOnWdohnaXLMjkQ4TZRTZTdH-tXstyr84X4crhpWzkKR0xNSQw@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a114fc824645c98054cf974d9
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::22a
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 14:59:30 -0000

--001a114fc824645c98054cf974d9
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

=E2=80=8BO=E2=80=8B
n 12 April 2017 at 15:49, Chet Ramey <chet.ramey@case.edu> wrote:

>
> It's a false positive, or a bug in valgrind. I took a quick look.  There'=
s
> one place in this code path where free() gets called.  Here's the trace:
>

=E2=80=8B[analysis snipped]

Thanks very much, looks like it's time for me to file a Valgrind bug report=
.

--001a114fc824645c98054cf974d9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div=
 style=3D"font-size:small;display:inline" class=3D"gmail_default">=E2=80=8B=
O=E2=80=8B</div>n 12 April 2017 at 15:49, Chet Ramey <span dir=3D"ltr">&lt;=
<a href=3D"mailto:chet.ramey@case.edu" target=3D"_blank">chet.ramey@case.ed=
u</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">=
<br>
</span>It&#39;s a false positive, or a bug in valgrind. I took a quick look=
.=C2=A0 There&#39;s<br>
one place in this code path where free() gets called.=C2=A0 Here&#39;s the =
trace:<br></blockquote><div><br><div style=3D"font-size:small" class=3D"gma=
il_default">=E2=80=8B[analysis snipped]<br><br></div><div style=3D"font-siz=
e:small" class=3D"gmail_default">Thanks very much, looks like it&#39;s time=
 for me to file a Valgrind bug report.</div></div></div></div></div>

--001a114fc824645c98054cf974d9--


From MAILER-DAEMON Wed Apr 12 11:57:03 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyKdj-0005ry-EJ
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 11:57:03 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:41789)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyKdh-0005ro-0A
	for bug-bash@gnu.org; Wed, 12 Apr 2017 11:57:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyKdd-0000BR-Vx
	for bug-bash@gnu.org; Wed, 12 Apr 2017 11:57:01 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:42053
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cyKdd-0000BB-R9
	for bug-bash@gnu.org; Wed, 12 Apr 2017 11:56:57 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALG41162; Wed, 12 Apr 2017 11:56:56 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCO87901 (AUTH cpr);
	Wed, 12 Apr 2017 11:56:55 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdohnaXLMjkQ4TZRTZTdH-tXstyr84X4crhpWzkKR0xNSQw@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <575a4862-a045-7755-26b6-7f32f09455a2@case.edu>
Date: Wed, 12 Apr 2017 11:56:55 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdohnaXLMjkQ4TZRTZTdH-tXstyr84X4crhpWzkKR0xNSQw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv4-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 15:57:02 -0000

On 4/12/17 10:59 AM, Reuben Thomas wrote:
> â€‹Oâ€‹
> n 12 April 2017 at 15:49, Chet Ramey <chet.ramey@case.edu
> <mailto:chet.ramey@case.edu>> wrote:
> 
> 
>     It's a false positive, or a bug in valgrind. I took a quick look.  There's
>     one place in this code path where free() gets called.  Here's the trace:
> 
> 
> â€‹[analysis snipped]
> 
> Thanks very much, looks like it's time for me to file a Valgrind bug report.

Maybe update the Debian bug report you cited as well.  There's still stuff
there from 2005.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Wed Apr 12 12:55:19 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyLY7-0004BP-Tr
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 12:55:19 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57588)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyLY6-0004BC-46
	for bug-bash@gnu.org; Wed, 12 Apr 2017 12:55:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyLY5-0004tE-4N
	for bug-bash@gnu.org; Wed, 12 Apr 2017 12:55:18 -0400
Received: from mail-qk0-x231.google.com ([2607:f8b0:400d:c09::231]:34892)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cyLY4-0004su-T4
	for bug-bash@gnu.org; Wed, 12 Apr 2017 12:55:17 -0400
Received: by mail-qk0-x231.google.com with SMTP id f133so28361603qke.2
	for <bug-bash@gnu.org>; Wed, 12 Apr 2017 09:55:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=u9OwGeZSroZbkDnVIiC6SCz3XhJM0MDniZj2mRGV/jI=;
	b=wSdfJY6s+gwsz/94RJxt3CC6GrCGiczS0P3/kJsZgoifPGk2w9vKxlkIeAKsieNxlw
	C6MmrqBJOOXV1dvaH9EAOKtChs/m9Yy7ZhySUVJvPLLLdmOrX8/L2Bb+MJe/yu0UP4vL
	12KsTlyuy+Z6QbYEMDnsaIZTidjmul3sl0fxk=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=u9OwGeZSroZbkDnVIiC6SCz3XhJM0MDniZj2mRGV/jI=;
	b=UcsP6zeAqc+4kZNp57vNuauBgLMsAMDTp2+4YgqRvkcNidfmS4c0jF3sNxDYUPMEjn
	J5DI/fhCUYFYh+d4EAVz1guay4gHjjwsuf88SuV6MI87sFnwGUW5l4v9h+Qx/9jAd1yi
	JJoQy7G45phujpH84SnJQw3ck4NFZr/5WnJLEP6Xz+jAzG3dUD1OAIIPcAbQNXMiGNqO
	98QiN8ukLmIqwtKFs0fJOVmk1sym+4dE5FIgA67LROyZpa8ykV9/l+2vplM3MgueBz/p
	jDI9lj2pTfStEl+7lFodmvJ4mRcpGf5rEgnYyuiIqKPxtq3xJdRY6AhMVb68PCnWmkzM
	D5mA==
X-Gm-Message-State: AFeK/H1aMg1Iscw6zfWIr/xp4/7sRascL1oRRxeLzwtOK0njrg9e19PTJvpTPihlNCWV7CVwwDGPqEfcLRH99wL2
X-Received: by 10.55.201.202 with SMTP id m71mr52302559qkl.31.1492016115679;
	Wed, 12 Apr 2017 09:55:15 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Wed, 12 Apr 2017 09:55:15 -0700 (PDT)
Received: by 10.140.85.170 with HTTP; Wed, 12 Apr 2017 09:55:15 -0700 (PDT)
In-Reply-To: <575a4862-a045-7755-26b6-7f32f09455a2@case.edu>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdohnaXLMjkQ4TZRTZTdH-tXstyr84X4crhpWzkKR0xNSQw@mail.gmail.com>
	<575a4862-a045-7755-26b6-7f32f09455a2@case.edu>
From: Reuben Thomas <rrt@sc3d.org>
Date: Wed, 12 Apr 2017 17:55:15 +0100
Message-ID: <CAOnWdohE1hwXuvice4h2EhizkOq2kFyjVvv1pA82AYcnpvH=Zg@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a1149af4e9321ae054cfb1246
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::231
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 16:55:19 -0000

--001a1149af4e9321ae054cfb1246
Content-Type: text/plain; charset=UTF-8

On Apr 12, 2017 4:56 PM, "Chet Ramey" <chet.ramey@case.edu> wrote:

[snip]

> Maybe update the Debian bug report you cited as well.  There's still stuff
> there from 2005.

The report is from December 2016. I can't find "2005" in the page.

I'll certainly send an update to point to the upstream bug I file.

--001a1149af4e9321ae054cfb1246
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">On Apr 12, 2017 4:56 PM, &quot;Chet Ramey&quot; &lt;<a href=
=3D"mailto:chet.ramey@case.edu">chet.ramey@case.edu</a>&gt; wrote:</p>
<p dir=3D"ltr">[snip]</p>
<p dir=3D"ltr">&gt; Maybe update the Debian bug report you cited as well.=
=C2=A0 There&#39;s still stuff<br>
&gt; there from 2005.</p>
<p dir=3D"ltr">The report is from December 2016. I can&#39;t find &quot;200=
5&quot; in the page.</p>
<p dir=3D"ltr">I&#39;ll certainly send an update to point to the upstream b=
ug I file.<br>
</p>

--001a1149af4e9321ae054cfb1246--


From MAILER-DAEMON Wed Apr 12 12:58:53 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyLbZ-0004iz-J9
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 12:58:53 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58621)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <hanno@hboeck.de>) id 1cyLbX-0004ip-GM
	for bug-bash@gnu.org; Wed, 12 Apr 2017 12:58:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <hanno@hboeck.de>) id 1cyLbT-0006UY-6G
	for bug-bash@gnu.org; Wed, 12 Apr 2017 12:58:51 -0400
Received: from zucker.schokokeks.org ([178.63.68.96]:53333)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <hanno@hboeck.de>) id 1cyLbS-0006U0-Vo
	for bug-bash@gnu.org; Wed, 12 Apr 2017 12:58:47 -0400
Received: from pc1 ([2a02:2190:f000:cf0f:aac8:9b7a:fdfd:c8a2])
	(AUTH: LOGIN hanno-default@schokokeks.org, TLS: TLSv1/SSLv3, 256bits,
	ECDHE-RSA-AES256-GCM-SHA384)
	by zucker.schokokeks.org with ESMTPSA; Wed, 12 Apr 2017 18:58:45 +0200
	id 0000000000000031.0000000058EE5CC5.00006EAE
Date: Wed, 12 Apr 2017 18:58:43 +0200
From: Hanno =?UTF-8?B?QsO2Y2s=?= <hanno@hboeck.de>
To: Reuben Thomas <rrt@sc3d.org>
Cc: Chester Ramey <chet.ramey@case.edu>,
  Bash - Bug <bug-bash@gnu.org>
Subject: Re: Running bash under valgrind gives "invalid free()"
Message-ID: <20170412185843.09116640@pc1>
In-Reply-To: <CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 178.63.68.96
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 16:58:52 -0000

On Wed, 12 Apr 2017 14:59:26 +0100
Reuben Thomas <rrt@sc3d.org> wrote:

> =E2=80=8Bfrequently, it's the only tool that shows up bugs of this sort, =
as
> it's rather more powerful than a debugging malloc library.)

Try address sanitizer, it's pretty reliable and finds even more bug
classes compared to valgrind. Just add -fsanitize=3Daddress to the CFLAGS.

If you can't reproduce the bug with asan I'd bet on a valgrind bug.

--=20
Hanno B=C3=B6ck
https://hboeck.de/

mail/jabber: hanno@hboeck.de
GPG: FE73757FA60E4E21B937579FA5880072BBB51E42


From MAILER-DAEMON Wed Apr 12 14:07:40 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyMg8-0004ko-1w
	for mharc-bug-bash@gnu.org; Wed, 12 Apr 2017 14:07:40 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50896)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyMg5-0004ii-Mt
	for bug-bash@gnu.org; Wed, 12 Apr 2017 14:07:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyMg0-00057L-OC
	for bug-bash@gnu.org; Wed, 12 Apr 2017 14:07:37 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:23645
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cyMg0-000571-JT
	for bug-bash@gnu.org; Wed, 12 Apr 2017 14:07:32 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AML25959; Wed, 12 Apr 2017 14:07:25 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCP19283 (AUTH cpr);
	Wed, 12 Apr 2017 14:07:24 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<20170412185843.09116640@pc1>
To: =?UTF-8?Q?Hanno_B=c3=b6ck?= <hanno@hboeck.de>, Reuben Thomas <rrt@sc3d.org>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <c70e573f-4e69-4c1b-b1ec-8315580c13ad@case.edu>
Date: Wed, 12 Apr 2017 14:07:24 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <20170412185843.09116640@pc1>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1-2015.case.edu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 12 Apr 2017 18:07:39 -0000

On 4/12/17 12:58 PM, Hanno BÃ¶ck wrote:
> On Wed, 12 Apr 2017 14:59:26 +0100
> Reuben Thomas <rrt@sc3d.org> wrote:
> 
>> â€‹frequently, it's the only tool that shows up bugs of this sort, as
>> it's rather more powerful than a debugging malloc library.)
> 
> Try address sanitizer, it's pretty reliable and finds even more bug
> classes compared to valgrind. Just add -fsanitize=address to the CFLAGS.

It's a valgrind false positive. I run the entire bash test suite through
a version built with address sanitizer.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 13 04:16:00 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyZv6-0006tV-FZ
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 04:16:00 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48203)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyZv4-0006tO-Am
	for bug-bash@gnu.org; Thu, 13 Apr 2017 04:15:59 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyZv3-0002vw-2W
	for bug-bash@gnu.org; Thu, 13 Apr 2017 04:15:58 -0400
Received: from mail-qt0-x235.google.com ([2607:f8b0:400d:c0d::235]:34863)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cyZv2-0002vj-T0
	for bug-bash@gnu.org; Thu, 13 Apr 2017 04:15:56 -0400
Received: by mail-qt0-x235.google.com with SMTP id n46so40341900qta.2
	for <bug-bash@gnu.org>; Thu, 13 Apr 2017 01:15:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=z+Hl0lSsjR1/RBHds96TeYIdADCoygAaggUtuABeECc=;
	b=Xe2FQrGpd+2plQnnCHhgUzIVdSCRFuRUkhFLtRmO0vCCRS83smjxivqGTuXykOP9uC
	h4YJT4Wmac4qjUda85pmngl5TlWCkK4IQ4ZiJn+THUCSobAdDyR3KS/Jzm7rtxnd3T1x
	v0Aaydypy1Jo/xrbNRmn2YTiMjogLN1KEEF9Q=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=z+Hl0lSsjR1/RBHds96TeYIdADCoygAaggUtuABeECc=;
	b=cYTaxlIlu1WhUQL/SYM/l4LXqdb+2XifUDm3BkJVXnkvqyqOE7cxqC5dsDYkPIWBOO
	MliAQ3eclm8WWVy21MMqzsfpxABjMl7qBWE9fmIqqKPQ1tR8nwmlv8Nr/7Mj/RIrCXtt
	/3GXDDO47rtiYlesUsIoTC5pe3mo3u72Ztx0tTo/8O2SxTLnU6WsOWFDT23BpZWPnoIq
	L4GdkcKvsG0Z8BPmE1YUK5inx2eMA+yPfEmNhTH4XE7vOd+dDRVLYx/vULPQSW6fU5EP
	XkYjldUUJx96O9qL2RvSwDnl5QCaKsSWtnBYI22MG01tG9n3sz1xpzMRiK0rc1WEhEQo
	a1Xg==
X-Gm-Message-State: AN3rC/6XWXEP566MUksnIECXcdXJ0Q/SBWw2XjH+LvtQngTAIiqgrHyM
	AvTW4NSCgH+m+SHx3TmF/n0NcIFpwoaS
X-Received: by 10.237.37.146 with SMTP id x18mr1655388qtc.156.1492071356111;
	Thu, 13 Apr 2017 01:15:56 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Thu, 13 Apr 2017 01:15:55 -0700 (PDT)
In-Reply-To: <20170412185843.09116640@pc1>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<20170412185843.09116640@pc1>
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 13 Apr 2017 09:15:55 +0100
Message-ID: <CAOnWdoh=DkY_rUEdk8LxzXmZf4FBc21re8Hut--_iDRs2JD9vg@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: =?UTF-8?Q?Hanno_B=C3=B6ck?= <hanno@hboeck.de>
Cc: Chester Ramey <chet.ramey@case.edu>, Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a114063b42935fd054d07ef4a
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c0d::235
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 08:15:59 -0000

--001a114063b42935fd054d07ef4a
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 12 April 2017 at 17:58, Hanno B=C3=B6ck <hanno@hboeck.de> wrote:

> On Wed, 12 Apr 2017 14:59:26 +0100
> Reuben Thomas <rrt@sc3d.org> wrote:
>
> > =E2=80=8Bfrequently, it's the only tool that shows up bugs of this sort=
, as
> > it's rather more powerful than a debugging malloc library.)
>
> Try address sanitizer, it's pretty reliable and finds even more bug
> classes compared to valgrind. Just add -fsanitize=3Daddress to the CFLAGS=
.
>
> If you can't reproduce the bug with asan I'd bet on a valgrind bug.


=E2=80=8BThanks very much for the recommendation (and to Chet); I'd not hea=
rd of
it. Once I've fixed all the bugs I'm finding with valgrind, I'll go back
and see what asan finds, and also see if it finds anything else, so I can
see whether to run it as well or instead of valgrind.

Having confirmed Chet's analysis with a few printfs added to bash (i.e.
just to check the address being allocated and the one complained about were
the same) I've filed a bug report against valgrind:
https://bugs.kde.org/show_bug.cgi?id=3D378732

--=20
http://rrt.sc3d.org

--001a114063b42935fd054d07ef4a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1=
2 April 2017 at 17:58, Hanno B=C3=B6ck <span dir=3D"ltr">&lt;<a href=3D"mai=
lto:hanno@hboeck.de" target=3D"_blank">hanno@hboeck.de</a>&gt;</span> wrote=
:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On Wed, 12 Apr=
 2017 14:59:26 +0100<br>
Reuben Thomas &lt;<a href=3D"mailto:rrt@sc3d.org" target=3D"_blank">rrt@sc3=
d.org</a>&gt; wrote:<br>
<br>
&gt; =E2=80=8Bfrequently, it&#39;s the only tool that shows up bugs of this=
 sort, as<br>
&gt; it&#39;s rather more powerful than a debugging malloc library.)<br>
<br>
</span>Try address sanitizer, it&#39;s pretty reliable and finds even more =
bug<br>
classes compared to valgrind. Just add -fsanitize=3Daddress to the CFLAGS.<=
br>
<br>
If you can&#39;t reproduce the bug with asan I&#39;d bet on a valgrind bug.=
</blockquote><div><br><div style=3D"font-size:small;display:inline" class=
=3D"gmail_default">=E2=80=8BThanks very much for the recommendation (and to=
 Chet); I&#39;d not heard of it. Once I&#39;ve fixed all the bugs I&#39;m f=
inding with valgrind, I&#39;ll go back and see what asan finds, and also se=
e if it finds anything else, so I can see whether to run it as well or inst=
ead of valgrind.<br><br></div><div style=3D"font-size:small;display:inline"=
 class=3D"gmail_default">Having confirmed Chet&#39;s analysis with a few pr=
intfs added to bash (i.e. just to check the address being allocated and the=
 one complained about were the same) I&#39;ve filed a bug report against va=
lgrind: <a href=3D"https://bugs.kde.org/show_bug.cgi?id=3D378732">https://b=
ugs.kde.org/show_bug.cgi?id=3D378732</a><br clear=3D"all"></div></div></div=
><br>-- <br><div class=3D"gmail-m_8149126403702932057gmail_signature"><a hr=
ef=3D"http://rrt.sc3d.org" target=3D"_blank">http://rrt.sc3d.org</a></div>
</div></div>

--001a114063b42935fd054d07ef4a--


From MAILER-DAEMON Thu Apr 13 06:32:50 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyc3W-0007IV-LJ
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 06:32:50 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51197)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyc3T-0007H3-WC
	for bug-bash@gnu.org; Thu, 13 Apr 2017 06:32:48 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyc3S-0006cP-S7
	for bug-bash@gnu.org; Thu, 13 Apr 2017 06:32:48 -0400
Received: from mail-qk0-x236.google.com ([2607:f8b0:400d:c09::236]:35938)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cyc3S-0006cF-KR
	for bug-bash@gnu.org; Thu, 13 Apr 2017 06:32:46 -0400
Received: by mail-qk0-x236.google.com with SMTP id d131so44298701qkc.3
	for <bug-bash@gnu.org>; Thu, 13 Apr 2017 03:32:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=mSxEH1imepq24ZIKgk9ljYt60RAosWQfAmLWIGBYbtA=;
	b=nSi4PGkA8S5t9xpElnMG7oFYZi1TjyUM32jZwuwziE8bgivt74U8aHrvuoYV3BaWHE
	CZv/TYoLSXchIR76b1sJnFMl73Km4hWapiNscEDhXYfhaiv3JRJAcZV0Mumkeii6vTZH
	xtkdi45fK6bDzHSBWSlmzApk5/iGjlAJpdBhY=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=mSxEH1imepq24ZIKgk9ljYt60RAosWQfAmLWIGBYbtA=;
	b=D4UZmXExirp/Q+iNqPaYFtpa1NI6Dn7O31hBRuAPonPpq1HCdKUewvHDXXLgKANqOe
	Ipiwf7vni/3QA83jKD1gMnYWmi52XWHcvz0te778sqcLOg4wM0GWFD8jnO1bF24Vtg1a
	uG8Fi43liTCpF76XvBJs2dL0uKzFTYVyWF0JiAJTs+y4dAF3txl+On8Ix2DKSMGiG2bn
	PBNr0pFKI1jOAjrshfe6ZLfU88bZvkFPkN2fasFo1fH7u5e5huPuxVmleSPGHbLfVCAy
	ZV/5LTo3bwvqJ5q4tOHW3M7WvjHUV5HOyVOS3jyK69pW8+NivPdsTCiBH3LgPjaUOa6M
	wP8A==
X-Gm-Message-State: AN3rC/61uRYAclLrVIgkmSWCcZIoefCT4ErUNHsImav3K+A3AJEPxpW6
	K59l2GZURWeAGT87+H2tx8JgLuqlI9fI
X-Received: by 10.55.160.143 with SMTP id j137mr1757402qke.119.1492079565805; 
	Thu, 13 Apr 2017 03:32:45 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Thu, 13 Apr 2017 03:32:45 -0700 (PDT)
In-Reply-To: <CAOnWdoh=DkY_rUEdk8LxzXmZf4FBc21re8Hut--_iDRs2JD9vg@mail.gmail.com>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<20170412185843.09116640@pc1>
	<CAOnWdoh=DkY_rUEdk8LxzXmZf4FBc21re8Hut--_iDRs2JD9vg@mail.gmail.com>
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 13 Apr 2017 11:32:45 +0100
Message-ID: <CAOnWdog7atZg3bacNxfJUBqO7dr4HfWTjnx_+C9NMfMgVP-0gA@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: =?UTF-8?Q?Hanno_B=C3=B6ck?= <hanno@hboeck.de>
Cc: Chester Ramey <chet.ramey@case.edu>, Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a114fc8247f3501054d09d82d
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::236
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 10:32:49 -0000

--001a114fc8247f3501054d09d82d
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 13 April 2017 at 09:15, Reuben Thomas <rrt@sc3d.org> wrote:

>
> Having confirmed Chet's analysis with a few printfs added to bash (i.e.
> just to check the address being allocated and the one complained about we=
re
> the same) I've filed a bug report against valgrind:
> https://bugs.kde.org/show_bug.cgi?id=3D378732
>

=E2=80=8BJulian Seward (valgrind author) correctly=E2=80=8B

=E2=80=8Bguessed that it is a problem with malloc/free interception: when b=
ash uses
its own malloc (as by default on my GNU/Linux system), the malloc is not
intercepted by valgrind, but the free is.

Obviously a bug in valgrind, but I am interested: why does bash not use the
glibc malloc by default on GNU/Linux systems?

--=20
http://rrt.sc3d.org

--001a114fc8247f3501054d09d82d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1=
3 April 2017 at 09:15, Reuben Thomas <span dir=3D"ltr">&lt;<a href=3D"mailt=
o:rrt@sc3d.org" target=3D"_blank">rrt@sc3d.org</a>&gt;</span> wrote:<br><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #=
ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div class=3D"gmail_extra"=
><div class=3D"gmail_quote"><span class=3D""></span><div>Having confirmed C=
het&#39;s analysis with a few printfs added to bash (i.e. just to check the=
 address being allocated and the one complained about were the same) I&#39;=
ve filed a bug report against valgrind: <a href=3D"https://bugs.kde.org/sho=
w_bug.cgi?id=3D378732" target=3D"_blank">https://bugs.kde.org/show_bug.<wbr=
>cgi?id=3D378732</a><span class=3D"HOEnZb"><font color=3D"#888888"><br clea=
r=3D"all"></font></span></div></div></div></div></blockquote><div><br><div =
style=3D"font-size:small;display:inline" class=3D"gmail_default">=E2=80=8BJ=
ulian Seward (valgrind author) correctly=E2=80=8B</div>=C2=A0<div style=3D"=
font-size:small;display:inline" class=3D"gmail_default">=E2=80=8Bguessed th=
at it is a problem with malloc/free interception: when bash uses its own ma=
lloc (as by default on my GNU/Linux system), the malloc is not intercepted =
by valgrind, but the free is.<br><br></div><div style=3D"font-size:small;di=
splay:inline" class=3D"gmail_default">Obviously a bug in valgrind, but I am=
 interested: why does bash not use the glibc malloc by default on GNU/Linux=
 systems?<br></div></div></div><br>-- <br><div class=3D"gmail_signature" da=
ta-smartmail=3D"gmail_signature"><a href=3D"http://rrt.sc3d.org" target=3D"=
_blank">http://rrt.sc3d.org</a></div>
</div></div>

--001a114fc8247f3501054d09d82d--


From MAILER-DAEMON Thu Apr 13 10:11:51 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyfTT-00080H-7E
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 10:11:51 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57081)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyfTQ-0007yx-S8
	for bug-bash@gnu.org; Thu, 13 Apr 2017 10:11:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyfTM-0001o0-Tr
	for bug-bash@gnu.org; Thu, 13 Apr 2017 10:11:48 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:6075
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cyfTM-0001nH-Oc
	for bug-bash@gnu.org; Thu, 13 Apr 2017 10:11:44 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AML59632; Thu, 13 Apr 2017 10:11:39 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCQ41907 (AUTH cpr);
	Thu, 13 Apr 2017 10:11:38 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<20170412185843.09116640@pc1>
	<CAOnWdoh=DkY_rUEdk8LxzXmZf4FBc21re8Hut--_iDRs2JD9vg@mail.gmail.com>
	<CAOnWdog7atZg3bacNxfJUBqO7dr4HfWTjnx_+C9NMfMgVP-0gA@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>, =?UTF-8?Q?Hanno_B=c3=b6ck?= <hanno@hboeck.de>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <03aa6af4-8223-7525-c89a-cbc6f6550b30@case.edu>
Date: Thu, 13 Apr 2017 10:11:19 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdog7atZg3bacNxfJUBqO7dr4HfWTjnx_+C9NMfMgVP-0gA@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.13.130617:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_500_599,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES, __CC_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 14:11:50 -0000

On 4/13/17 6:32 AM, Reuben Thomas wrote:

> Obviously a bug in valgrind, but I am interested: why does bash not use the
> glibc malloc by default on GNU/Linux systems?

The bash malloc is faster; better tuned for bash; is more signal safe
without the twisty maze of locks that the glibc malloc uses; and includes
things like bounds checking and duplicate free detection by default.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 13 10:33:11 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyfo7-0004GJ-Dh
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 10:33:11 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35439)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyfo4-0004Ej-CI
	for bug-bash@gnu.org; Thu, 13 Apr 2017 10:33:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyfo3-0005Rv-B6
	for bug-bash@gnu.org; Thu, 13 Apr 2017 10:33:08 -0400
Received: from mail-qt0-x235.google.com ([2607:f8b0:400d:c0d::235]:36032)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cyfo3-0005OY-4G
	for bug-bash@gnu.org; Thu, 13 Apr 2017 10:33:07 -0400
Received: by mail-qt0-x235.google.com with SMTP id v3so47106435qtd.3
	for <bug-bash@gnu.org>; Thu, 13 Apr 2017 07:33:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=A4Ng7Jzk2i6PqsSKFZCSkityVnU+gGVVCCLn3aTl3PQ=;
	b=xh/Ah8C4AToSFvdHjxjlZ7WMbWckq6S7l98BzXN+pY0CMUiURloI+K1Mfasq/iLhn/
	0kEvbCxtcoBwBotTADyxbOmGjPCqM4yyrusWsG341qfoJoBWSbMWsIkQIV73+3qalOzE
	Uxp45S7aj65jDUAh1jjZJCPHgWEt3YAt9mhhc=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=A4Ng7Jzk2i6PqsSKFZCSkityVnU+gGVVCCLn3aTl3PQ=;
	b=WHKwVQSczpDeVRP1tGfc0CqSWjC7iIObo02dBmroilJs0rzmQj9MfojctNcB214DeZ
	ju9CUADN30H9RznV64C/rArED+j4PMIveXHyfurp/SJGtypASmEXh7oZ7Lbl7PSRMYOS
	YT0HYM31xijGstWwMDd+g0UVzIgl1wC9tonpMFt46aO9sc4LJ1Fbf7lcPKssgS4oUtOq
	qu8ciuovgtVl8h4o/oqSjFNspmNgwTQSE944vCZQsI0RbJmAdGMzlOkYdpvrMQioF+90
	ifkafinumOWnVAo0ZGTCZSt6TBJPk2HhOZtL46gaP2PmGlucyMTFWLzcXSabf/lDeo62
	nbbA==
X-Gm-Message-State: AN3rC/6wINNuLYZxljkawlcqh/07Sv+fUbRtf7GRJbJ4uCTtIKaQmXV9
	FfClDqUi9iWQLIK6xUtpv1m97kdIAt1q
X-Received: by 10.200.36.2 with SMTP id c2mr2782745qtc.271.1492093986180; Thu,
	13 Apr 2017 07:33:06 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Thu, 13 Apr 2017 07:33:05 -0700 (PDT)
In-Reply-To: <908939d3-54e7-1991-1b83-b0970196c140@case.edu>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 13 Apr 2017 15:33:05 +0100
Message-ID: <CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a113a748204a067054d0d34cb
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c0d::235
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 14:33:09 -0000

--001a113a748204a067054d0d34cb
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 12 April 2017 at 15:49, Chet Ramey <chet.ramey@case.edu> wrote:

>
> It's a false positive, or a bug in valgrind. I took a quick look.  There'=
s
> one place in this code path where free() gets called.


=E2=80=8BJulian Seward (valgrind author) pointed out:=E2=80=8B

"
=E2=80=8B=E2=80=A6=E2=80=8B
what you report is symptomatic of bash
=E2=80=8B =E2=80=8B
using its own malloc to allocate a block but the system free to release
=E2=80=8B =E2=80=8B
it.  Could that be the case?
=E2=80=8B"

I had a look. Certainly at xmalloc.c:148 where free is called by xfree from
the cleanup function called at unwind_prot.c:333, gdb reports:

p free
$7 =3D {void (void *)} 0x7ffff7df0d80 <free>

This is glibc free.

If I put a breakpoint on xmalloc and rerun, it is not hit.

If I put a breakpoint on shell.c:1399, and trace into savestring, I find it
is running sh_xmalloc.

So it seems that the malloc and free calls are mismatched.

--001a113a748204a067054d0d34cb
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1=
2 April 2017 at 15:49, Chet Ramey <span dir=3D"ltr">&lt;<a href=3D"mailto:c=
het.ramey@case.edu" target=3D"_blank">chet.ramey@case.edu</a>&gt;</span> wr=
ote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=3D"gm=
ail-"><br>
</span>It&#39;s a false positive, or a bug in valgrind. I took a quick look=
.=C2=A0 There&#39;s<br>
one place in this code path where free() gets called.</blockquote><div><br>=
<div style=3D"font-size:small" class=3D"gmail_default">=E2=80=8BJulian Sewa=
rd (valgrind author) pointed out:=E2=80=8B</div><br>&quot;<div style=3D"fon=
t-size:small;display:inline" class=3D"gmail_default">=E2=80=8B=E2=80=A6=E2=
=80=8B</div>what you report is symptomatic of bash<div style=3D"font-size:s=
mall;display:inline" class=3D"gmail_default">=E2=80=8B =E2=80=8B</div>using=
 its own malloc to allocate a block but the system free to release<div styl=
e=3D"font-size:small;display:inline" class=3D"gmail_default">=E2=80=8B =E2=
=80=8B</div>it.=C2=A0 Could that be the case?<div style=3D"font-size:small;=
display:inline" class=3D"gmail_default">=E2=80=8B&quot;<br><br></div><div s=
tyle=3D"font-size:small;display:inline" class=3D"gmail_default">I had a loo=
k. Certainly at xmalloc.c:148 where free is called by xfree from the cleanu=
p function called at unwind_prot.c:333, gdb reports:<br><br>p free<br>$7 =
=3D {void (void *)} 0x7ffff7df0d80 &lt;free&gt;<br><br></div><div style=3D"=
font-size:small;display:inline" class=3D"gmail_default">This is glibc free.=
<br><br></div><div style=3D"font-size:small;display:inline" class=3D"gmail_=
default">If I put a breakpoint on xmalloc and rerun, it is not hit.<br><br>=
</div><div style=3D"font-size:small;display:inline" class=3D"gmail_default"=
>If I put a breakpoint on shell.c:1399, and trace into savestring, I find i=
t is running sh_xmalloc.<br><br></div><div style=3D"font-size:small;display=
:inline" class=3D"gmail_default">So it seems that the malloc and free calls=
 are mismatched.<br></div><div style=3D"font-size:small;display:inline" cla=
ss=3D"gmail_default"><br></div></div></div></div></div>

--001a113a748204a067054d0d34cb--


From MAILER-DAEMON Thu Apr 13 10:55:34 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyg9m-0003z4-LH
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 10:55:34 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42275)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyg9h-0003wM-Ev
	for bug-bash@gnu.org; Thu, 13 Apr 2017 10:55:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyg9g-0008LF-8n
	for bug-bash@gnu.org; Thu, 13 Apr 2017 10:55:29 -0400
Received: from mail-qt0-x22d.google.com ([2607:f8b0:400d:c0d::22d]:33215)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cyg9g-0008LB-1M
	for bug-bash@gnu.org; Thu, 13 Apr 2017 10:55:28 -0400
Received: by mail-qt0-x22d.google.com with SMTP id m36so47724148qtb.0
	for <bug-bash@gnu.org>; Thu, 13 Apr 2017 07:55:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=RL57ANmwByqKE98gMdHDNJLavROOPfIiTHEZUFiIbLI=;
	b=ug1ImB487J8dVRuhU5150IGCP2RfM8fWSExNGqT9+Am4lE9EtUgPUpMKOhqtLvGsNT
	GFxtVtDVaD9TAglj5GP7ni6AzuJQ2hTFaeH1X8690uuIQn7dFMrdG4HjAxb9OcUtCFQ1
	yz94zzWJNR5pIxrTzeKBH13ayzbJVONxRCh5I=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=RL57ANmwByqKE98gMdHDNJLavROOPfIiTHEZUFiIbLI=;
	b=e1dak8xEbndYRYfa7Lb33NXoJzAX90/diwGLWvQQQcm177ROfgi6gJK4FsX6v8f1H+
	uFJMLDLobGSaQM6yNQCdbakJuz8NPnvbRvPJL0Oc7PG+TpSFAEP9xCI9arwk4aTA8zm0
	fBD3SKnamxtb7GMyS0+VN7vXjoJZuAE/OSfpAiCs9JG5I070kiF7jjV1gPle74l4q9n9
	nRjYHo9JR09o1baY+9rYsVxwkI59UFOFs2M0xOZedJJOQ6bqxJIaHzgwUACn/5yzwKTh
	Sm0qxWNhNYka7KeI8QnjzEyUitYjaAQPL5liNvQgyV8XNKGyeTI5AnIAkVq9cRK3M9Rz
	G8xw==
X-Gm-Message-State: AN3rC/704V/ZMRCrc4TM4oQGTZYg7nXM8Es/dhvpHiJ1qvuyjMTiWaNC
	bYi5KXwIz1vz6vG/cxD63NBM9gUeuJmg
X-Received: by 10.200.40.72 with SMTP id 8mr2882052qtr.204.1492095327290; Thu,
	13 Apr 2017 07:55:27 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Thu, 13 Apr 2017 07:55:26 -0700 (PDT)
In-Reply-To: <CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 13 Apr 2017 15:55:26 +0100
Message-ID: <CAOnWdoijmCE+VFf7UxuBfDutz+sZLL21pVochr-HA=6UTQqjTA@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a11410c64f4e9db054d0d834d
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c0d::22d
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 14:55:33 -0000

--001a11410c64f4e9db054d0d834d
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

=E2=80=8BO=E2=80=8B
n 13 April 2017 at 15:33, Reuben Thomas <rrt@sc3d.org> wrote:

> On 12 April 2017 at 15:49, Chet Ramey <chet.ramey@case.edu> wrote:
>
>>
>> It's a false positive, or a bug in valgrind. I took a quick look.  There=
's
>> one place in this code path where free() gets called.
>
>
> =E2=80=8BJulian Seward (valgrind author) pointed out:=E2=80=8B
>
> "
> =E2=80=8B=E2=80=A6=E2=80=8B
> what you report is symptomatic of bash
> =E2=80=8B =E2=80=8B
> using its own malloc to allocate a block but the system free to release
> =E2=80=8B =E2=80=8B
> it.  Could that be the case?
> =E2=80=8B"
>
> I had a look. Certainly at xmalloc.c:148 where free is called by xfree
> from the cleanup function called at unwind_prot.c:333, gdb reports:
>
> p free
> $7 =3D {void (void *)} 0x7ffff7df0d80 <free>
>
> This is glibc free.
>
> If I put a breakpoint on xmalloc and rerun, it is not hit.
>
> If I put a breakpoint on shell.c:1399, and trace into savestring, I find
> it is running sh_xmalloc.
>
> So it seems that the malloc and free calls are mismatched.
>

=E2=80=8BTrying to understand this at a source level, if I capture the comp=
ilation
command for evalstring.c=E2=80=8B and replace -c with -E to preprocess it, =
I see
that the relevant line has become:

add_unwind_protect (xfree, orig_string)

where xfree is now the function name (in xmalloc.c).

So this still looks wrong (it should be sh_xfree, surely?).

--=20
http://rrt.sc3d.org

--001a11410c64f4e9db054d0d834d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div=
 style=3D"font-size:small;display:inline" class=3D"gmail_default">=E2=80=8B=
O=E2=80=8B</div>n 13 April 2017 at 15:33, Reuben Thomas <span dir=3D"ltr">&=
lt;<a href=3D"mailto:rrt@sc3d.org" target=3D"_blank">rrt@sc3d.org</a>&gt;</=
span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=
=3D"gmail_extra"><div class=3D"gmail_quote"><span class=3D"">On 12 April 20=
17 at 15:49, Chet Ramey <span dir=3D"ltr">&lt;<a href=3D"mailto:chet.ramey@=
case.edu" target=3D"_blank">chet.ramey@case.edu</a>&gt;</span> wrote:<br><b=
lockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-le=
ft:1px solid rgb(204,204,204);padding-left:1ex"><span class=3D"m_-302436019=
9623127057gmail-"><br>
</span>It&#39;s a false positive, or a bug in valgrind. I took a quick look=
.=C2=A0 There&#39;s<br>
one place in this code path where free() gets called.</blockquote></span><d=
iv><br><div>=E2=80=8BJulian Seward (valgrind author) pointed out:=E2=80=8B<=
/div><br>&quot;<div>=E2=80=8B=E2=80=A6=E2=80=8B</div>what you report is sym=
ptomatic of bash<div>=E2=80=8B =E2=80=8B</div>using its own malloc to alloc=
ate a block but the system free to release<div>=E2=80=8B =E2=80=8B</div>it.=
=C2=A0 Could that be the case?<div>=E2=80=8B&quot;<br><br></div><div>I had =
a look. Certainly at xmalloc.c:148 where free is called by xfree from the c=
leanup function called at unwind_prot.c:333, gdb reports:<br><br>p free<br>=
$7 =3D {void (void *)} 0x7ffff7df0d80 &lt;free&gt;<br><br></div><div>This i=
s glibc free.<br><br></div><div>If I put a breakpoint on xmalloc and rerun,=
 it is not hit.<br><br></div><div>If I put a breakpoint on shell.c:1399, an=
d trace into savestring, I find it is running sh_xmalloc.<br><br></div><div=
>So it seems that the malloc and free calls are mismatched.<br></div></div>=
</div></div></div>
</blockquote></div><br><div style=3D"font-size:small" class=3D"gmail_defaul=
t">=E2=80=8BTrying to understand this at a source level, if I capture the c=
ompilation command for evalstring.c=E2=80=8B and replace -c with -E to prep=
rocess it, I see that the relevant line has become:<br><br></div><div style=
=3D"font-size:small" class=3D"gmail_default">add_unwind_protect (xfree, ori=
g_string)<br><br></div><div style=3D"font-size:small" class=3D"gmail_defaul=
t">where xfree is now the function name (in xmalloc.c).<br><br></div><div s=
tyle=3D"font-size:small" class=3D"gmail_default">So this still looks wrong =
(it should be sh_xfree, surely?).<br></div><br>-- <br><div class=3D"gmail_s=
ignature" data-smartmail=3D"gmail_signature"><a href=3D"http://rrt.sc3d.org=
" target=3D"_blank">http://rrt.sc3d.org</a></div>
</div></div>

--001a11410c64f4e9db054d0d834d--


From MAILER-DAEMON Thu Apr 13 11:12:01 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cygPh-0000Za-Du
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 11:12:01 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47568)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cygPf-0000Xz-2X
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:12:00 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cygPb-0003uX-P7
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:11:59 -0400
Received: from mpv3-2015.cwru.edu ([129.22.103.194]:18388
	helo=mpv3-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cygPb-0003tr-JH
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:11:55 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv3-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALL85525; Thu, 13 Apr 2017 11:11:53 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDB34407 (AUTH cpr);
	Thu, 13 Apr 2017 11:11:53 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
Date: Thu, 13 Apr 2017 11:11:53 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Status: score=8/60, host=mpv3-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.13.144516:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __HIGHBITS,
	__STOCK_PHRASE_7, __OEM_PRICE,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.194
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 15:12:00 -0000

On 4/13/17 10:33 AM, Reuben Thomas wrote:
> On 12 April 2017 at 15:49, Chet Ramey <chet.ramey@case.edu
> <mailto:chet.ramey@case.edu>> wrote:
> 
> 
>     It's a false positive, or a bug in valgrind. I took a quick look.  There's
>     one place in this code path where free() gets called.
> 
> 
> â€‹Julian Seward (valgrind author) pointed out:â€‹
> 
> "
> â€‹â€¦â€‹
> what you report is symptomatic of bash
> â€‹ â€‹
> using its own malloc to allocate a block but the system free to release
> â€‹ â€‹
> it.  Could that be the case?

I doubt it.

> â€‹"
> 
> I had a look. Certainly at xmalloc.c:148 where free is called by xfree from
> the cleanup function called at unwind_prot.c:333, gdb reports:
> 
> p free
> $7 = {void (void *)} 0x7ffff7df0d80 <free>
> 
> This is glibc free.
> 
> If I put a breakpoint on xmalloc and rerun, it is not hit.
> 
> If I put a breakpoint on shell.c:1399, and trace into savestring, I find it
> is running sh_xmalloc.

sh_xmalloc is just a wrapper that calls sh_malloc, in the same way that
xmalloc calls malloc.  sh_malloc is, in turn, a wrapper around bash's
internal malloc that adds file and line tracing information to the call.
The bash malloc() implementation simply calls this internal_malloc without
the file and line information.  You can freely mix calls to sh_malloc
and malloc without arena corruption.  It's easy to see what happens: the
bash calls get tracing, and malloc calls from libraries don't.  This is
exactly what you want.

Ths same thing happens with free: sh_xfree is a wrapper around sh_free
as xfree wraps free; sh_free is a wrapper that adds file and line
tracing to free.  The bash free() is a wrapper that calls internal_free
in the same fashion.

The normal bash allocation calls use these wrappers (defined in xmalloc.h)
so the tracing takes place and the trace information appears in error
messages, and can be optionally logged.

It doesn't make sense to do this in the unwind-protect calls because you're
calling through function pointers, so bash uses xfree. xfree calls free,
and doesn't require you to know whether free is a void or int function
(which used to matter more than it does now, but still matters on some
systems).  free is defined in the same file in the same (statically-
linked) library as the rest of the bash malloc functions.

I see no reason why, since all of these things are defined in the same
file and are statically linked, `free' would resolve to the glibc free
when malloc resolves to the bash malloc.

> So it seems that the malloc and free calls are mismatched.

Only in that they don't use the fixed names `malloc' and `free'.  If you
replace one set of names without the other, you'll produce false positives.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 13 11:14:51 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cygSR-0001iz-Jf
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 11:14:51 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48611)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cygSP-0001it-Ie
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:14:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cygSM-0005j5-93
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:14:49 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:63266
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cygSM-0005iI-0V
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:14:46 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALG87175; Thu, 13 Apr 2017 11:14:43 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCQ56543 (AUTH cpr);
	Thu, 13 Apr 2017 11:14:43 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<CAOnWdoijmCE+VFf7UxuBfDutz+sZLL21pVochr-HA=6UTQqjTA@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <fba47d51-4c14-0828-b932-1756b14af97f@case.edu>
Date: Thu, 13 Apr 2017 11:14:43 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdoijmCE+VFf7UxuBfDutz+sZLL21pVochr-HA=6UTQqjTA@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Status: score=8/60, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.13.142716:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_800_899, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, __CC_REAL_NAMES, MULTIPLE_REAL_RCPTS,
	[TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 15:14:50 -0000

On 4/13/17 10:55 AM, Reuben Thomas wrote:

> â€‹Trying to understand this at a source level, if I capture the compilation
> command for evalstring.câ€‹ and replace -c with -E to preprocess it, I see
> that the relevant line has become:
> 
> add_unwind_protect (xfree, orig_string)
> 
> where xfree is now the function name (in xmalloc.c).
> 
> So this still looks wrong (it should be sh_xfree, surely?).

No. See my previous message for how these functions fit together.  You
don't want tracing information from xfree, since it's misleading when
called via a function pointer from the unwind-protect code.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 13 11:18:17 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cygVl-0002KH-0W
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 11:18:17 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49452)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cygVi-0002Js-AS
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:18:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cygVh-0001Rq-DY
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:18:14 -0400
Received: from mail-qk0-x234.google.com ([2607:f8b0:400d:c09::234]:33666)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cygVh-0001QX-5z
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:18:13 -0400
Received: by mail-qk0-x234.google.com with SMTP id h67so50709577qke.0
	for <bug-bash@gnu.org>; Thu, 13 Apr 2017 08:18:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=AY7vt6qDyBO1D3pqza8FHm+t4u965s/pBJ8N13OJFow=;
	b=AQr7ZsiWecAKVf6P6DKuPBAXCxXag3qPCp+HuC/zcx6oL3mT7U3G55VTDjrCdXRJWn
	6cPi35QXROwTux/9ZJ4wQpcUdU5LQQpDv9x5loAz0gJcweMAqGOusKerU/bE1ew/B1hg
	pKANW83z/C6mwFHIxrwNgoPyJHEQzdwTN/9ME=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=AY7vt6qDyBO1D3pqza8FHm+t4u965s/pBJ8N13OJFow=;
	b=X2LCc8r+IfDaSyNp3WUkAtrS2hUVd113gwSqrpPVsEKq/b9edMDiJpyWfizajPZxKj
	q1dR9C1BCj8jYbStY2DqF1P9sB4IfPttef1dFGxMZ+P4lKaE6ilkPyYkXcL4/IQTr/P+
	A+tK00SBM7tzpmg3WUHPWpAbZzmHk7m4yQXh8ml72Qc/HhNz7E6HmKQTYJUawZOg58lh
	vSMN28FF9FRXi0tGIQ8+5F58tkdXfPBxZADxvMBQEhyzseM8DQqQfFIcEP6rtnXa0nkK
	hwsxDmkcA/XzMvC4voIhfj4aPAAVzR1nITVx0xNsGNfLHasnq4rY0Gl+Vhl2S4mBNMvT
	ht3Q==
X-Gm-Message-State: AN3rC/42IkYMIGreMuSfvr50BgXSJh0tI3KaIZEpooFcAdbicqXVD62o
	cauYx8TPExzN1Dq+kyWVt+wSQbPnlIJv
X-Received: by 10.55.209.27 with SMTP id s27mr2785164qki.186.1492096692309;
	Thu, 13 Apr 2017 08:18:12 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Thu, 13 Apr 2017 08:18:11 -0700 (PDT)
In-Reply-To: <64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 13 Apr 2017 16:18:11 +0100
Message-ID: <CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a114798ea50e759054d0dd555
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::234
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 15:18:15 -0000

--001a114798ea50e759054d0dd555
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 13 April 2017 at 16:11, Chet Ramey <chet.ramey@case.edu> wrote:

>
> I see no reason why, since all of these things are defined in the same
> file and are statically linked, `free' would resolve to the glibc free
> when malloc resolves to the bash malloc.


So this is the real problem?=E2=80=8B

=E2=80=8BDo you have any suggestions for how I might investigate this?=E2=
=80=8B

--=20
http://rrt.sc3d.org

--001a114798ea50e759054d0dd555
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1=
3 April 2017 at 16:11, Chet Ramey <span dir=3D"ltr">&lt;<a href=3D"mailto:c=
het.ramey@case.edu" target=3D"_blank">chet.ramey@case.edu</a>&gt;</span> wr=
ote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border=
-left:1px #ccc solid;padding-left:1ex"><br>
I see no reason why, since all of these things are defined in the same<br>
file and are statically linked, `free&#39; would resolve to the glibc free<=
br>
when malloc resolves to the bash malloc.</blockquote><div><br><div style=3D=
"font-size:small;display:inline" class=3D"gmail_default">So this is the rea=
l problem?=E2=80=8B</div>=C2=A0<div style=3D"font-size:small;display:inline=
" class=3D"gmail_default">=E2=80=8BDo you have any suggestions for how I mi=
ght investigate this?=E2=80=8B</div></div></div><br>-- <br><div class=3D"gm=
ail_signature" data-smartmail=3D"gmail_signature"><a href=3D"http://rrt.sc3=
d.org" target=3D"_blank">http://rrt.sc3d.org</a></div>
</div></div>

--001a114798ea50e759054d0dd555--


From MAILER-DAEMON Thu Apr 13 11:27:58 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cygf8-0003di-G6
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 11:27:58 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52254)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cygf5-0003dI-Jn
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:27:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cygf2-0000p6-St
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:27:55 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:21075
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cygf2-0000oJ-NM
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:27:52 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AML64709; Thu, 13 Apr 2017 11:27:48 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDB37839 (AUTH cpr);
	Thu, 13 Apr 2017 11:27:48 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
	<CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <84ba06f5-1585-01b0-4eb4-66c27351a5d4@case.edu>
Date: Thu, 13 Apr 2017 11:27:48 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Status: score=8/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.13.140617:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODY_SIZE_1300_1399,
	BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1,
	__MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10,
	BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES, __CC_REAL_NAMES,
	[TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 15:27:56 -0000

On 4/13/17 11:18 AM, Reuben Thomas wrote:
> On 13 April 2017 at 16:11, Chet Ramey <chet.ramey@case.edu
> <mailto:chet.ramey@case.edu>> wrote:
> 
> 
>     I see no reason why, since all of these things are defined in the same
>     file and are statically linked, `free' would resolve to the glibc free
>     when malloc resolves to the bash malloc.
> 
> 
> So this is the real problem?â€‹

If it is, it's a valgrind artifact.  Contrary to Julian's (?) assumption,
free() resolves to the bash free implementation when compiled normally. I
tested this on a Fedora 25 VM I was using for something else.  Putting a
breakpoint in xfree, running bash -c '', and stepping through it ends up
in the free() defined in lib/malloc/malloc.c.

>  
> â€‹Do you have any suggestions for how I might investigate this?â€‹

Personally, I think the problem is that valgrind makes invalid assumptions:
that interposing malloc/realloc/free is sufficient.  I showed it isn't.

You can try building without the bash malloc, but that's kind of a drastic
solution to just get rid of a valgrind false positive.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 13 11:41:07 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cygrr-0006Md-4V
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 11:41:07 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55994)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cygro-0006MO-Ed
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:41:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cygrn-0005Kj-FT
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:41:04 -0400
Received: from mail-qt0-x234.google.com ([2607:f8b0:400d:c0d::234]:36757)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cygrn-0005KZ-8I
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:41:03 -0400
Received: by mail-qt0-x234.google.com with SMTP id v3so48729159qtd.3
	for <bug-bash@gnu.org>; Thu, 13 Apr 2017 08:41:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=RM4gI1nb2g9+6pXXGelz0p/mIPFKcy/RsvhHrgRwkNU=;
	b=pjvKCPw7DGqw7iRBPQse3gVQeVTIHEabguBdZBsBoUUvf/N5M/zBHRC9xqBuqnMkzy
	AJyLGNPeYQIpAbzgUDHTE31UL1eoLc3/m7IhF98vj+RSnCPjd73O2cPcsus1aPOndUfR
	B4mYaBL5Ozvjd4Ff/AaFPFYmbvI1q1+ENcGSA=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=RM4gI1nb2g9+6pXXGelz0p/mIPFKcy/RsvhHrgRwkNU=;
	b=GuTmh0L1pjdeLjqWm/pFBkzwNWo1uzo1yI5/uPNqmNAw0hwaaNt6gwlfliFoYbwoPR
	POiMWhvttHTMldu8SLzuXAw1IisvA9wwwvaOGned0gEFbQ6039klfd18nHkzDMpSj8Co
	A/5yBZcx7xjyUha+eTq1btRswJD6DB28Ez7acxX7i40y8wAhPSsE955iyyZN9cEuKcaJ
	M/h7LtqmFhWVtXuDF3izttPJyu8zgGOE0rIbhBbXgfl+s7q9sh0IgcSZ+wmqnJoQqiUd
	2CEvBy2sTmfjNp3nE35tUIn0/nPfnHh5SwBZaaCjTAEIMh6VJc1oDQvxpOHSeoq95yFS
	tEWQ==
X-Gm-Message-State: AN3rC/7Moo8VqbNPNxHCRd01J5t2p6xXbrhWASkZw8Glqbb8t9zHllzJ
	DwPfMUKo1uKXitoEctBIaNiIit9Rn2/+
X-Received: by 10.237.37.146 with SMTP id x18mr3514919qtc.156.1492098062480;
	Thu, 13 Apr 2017 08:41:02 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Thu, 13 Apr 2017 08:41:01 -0700 (PDT)
In-Reply-To: <84ba06f5-1585-01b0-4eb4-66c27351a5d4@case.edu>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
	<CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
	<84ba06f5-1585-01b0-4eb4-66c27351a5d4@case.edu>
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 13 Apr 2017 16:41:01 +0100
Message-ID: <CAOnWdohJ3gDsPiga4pYXxOs1oXRAJ4btG3_MbuoSUyCWoiKfnQ@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a114063b4fc10f8054d0e26fe
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c0d::234
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 15:41:05 -0000

--001a114063b4fc10f8054d0e26fe
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

=E2=80=8BO=E2=80=8B
n 13 April 2017 at 16:27, Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/13/17 11:18 AM, Reuben Thomas wrote:
> > On 13 April 2017 at 16:11, Chet Ramey <chet.ramey@case.edu
> > <mailto:chet.ramey@case.edu>> wrote:
> >
> >
> >     I see no reason why, since all of these things are defined in the
> same
> >     file and are statically linked, `free' would resolve to the glibc
> free
> >     when malloc resolves to the bash malloc.
> >
> >
> > So this is the real problem?=E2=80=8B
>
> If it is, it's a valgrind artifact.  Contrary to Julian's (?) assumption,
> free() resolves to the bash free implementation when compiled normally. I
> tested this on a Fedora 25 VM I was using for something else.  Putting a
> breakpoint in xfree, running bash -c '', and stepping through it ends up
> in the free() defined in lib/malloc/malloc.c.
>

=E2=80=8BThis is not the result I obtained. I simply ran gdb on the bash bi=
nary,
valgrind was not involved.=E2=80=8B

=E2=80=8BIndeed, building --without-bash-malloc fixed it.=E2=80=8B

--001a114063b4fc10f8054d0e26fe
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div=
 style=3D"font-size:small;display:inline" class=3D"gmail_default">=E2=80=8B=
O=E2=80=8B</div>n 13 April 2017 at 16:27, Chet Ramey <span dir=3D"ltr">&lt;=
<a href=3D"mailto:chet.ramey@case.edu" target=3D"_blank">chet.ramey@case.ed=
u</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">=
On 4/13/17 11:18 AM, Reuben Thomas wrote:<br>
&gt; On 13 April 2017 at 16:11, Chet Ramey &lt;<a href=3D"mailto:chet.ramey=
@case.edu">chet.ramey@case.edu</a><br>
</span><span class=3D"">&gt; &lt;mailto:<a href=3D"mailto:chet.ramey@case.e=
du">chet.ramey@case.edu</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;=C2=A0 =C2=A0 =C2=A0I see no reason why, since all of these things are =
defined in the same<br>
&gt;=C2=A0 =C2=A0 =C2=A0file and are statically linked, `free&#39; would re=
solve to the glibc free<br>
&gt;=C2=A0 =C2=A0 =C2=A0when malloc resolves to the bash malloc.<br>
&gt;<br>
&gt;<br>
&gt; So this is the real problem?=E2=80=8B<br>
<br>
</span>If it is, it&#39;s a valgrind artifact.=C2=A0 Contrary to Julian&#39=
;s (?) assumption,<br>
free() resolves to the bash free implementation when compiled normally. I<b=
r>
tested this on a Fedora 25 VM I was using for something else.=C2=A0 Putting=
 a<br>
breakpoint in xfree, running bash -c &#39;&#39;, and stepping through it en=
ds up<br>
in the free() defined in lib/malloc/malloc.c.<br></blockquote><div><br><div=
 style=3D"font-size:small" class=3D"gmail_default">=E2=80=8BThis is not the=
 result I obtained. I simply ran gdb on the bash binary, valgrind was not i=
nvolved.=E2=80=8B</div><br><div style=3D"font-size:small" class=3D"gmail_de=
fault">=E2=80=8BIndeed, building --without-bash-malloc fixed it.=E2=80=8B</=
div><br></div></div></div></div>

--001a114063b4fc10f8054d0e26fe--


From MAILER-DAEMON Thu Apr 13 11:46:46 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cygxK-0007ut-Fw
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 11:46:46 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57354)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cygxI-0007uh-5l
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:46:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cygxE-00071p-2e
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:46:44 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:20645
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cygxD-00071b-Sl
	for bug-bash@gnu.org; Thu, 13 Apr 2017 11:46:39 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMQ85651; Thu, 13 Apr 2017 11:46:37 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDB43031 (AUTH cpr);
	Thu, 13 Apr 2017 11:46:37 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
	<CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
	<84ba06f5-1585-01b0-4eb4-66c27351a5d4@case.edu>
	<CAOnWdohJ3gDsPiga4pYXxOs1oXRAJ4btG3_MbuoSUyCWoiKfnQ@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <b52915a1-2e01-346b-7dd0-17bfb16a0088@case.edu>
Date: Thu, 13 Apr 2017 11:46:37 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdohJ3gDsPiga4pYXxOs1oXRAJ4btG3_MbuoSUyCWoiKfnQ@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Status: score=8/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.13.150616:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	URI_ENDS_IN_HTML, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__MULTIPLE_URI_TEXT, __URI_IN_BODY, __URI_NOT_IMG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_2000_2999, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY,
	BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 15:46:45 -0000

On 4/13/17 11:41 AM, Reuben Thomas wrote:

> â€‹This is not the result I obtained. I simply ran gdb on the bash binary,
> valgrind was not involved.â€‹

If you didn't build the binary yourself, you don't know what changes were
made to it.  Here's what I got on Fedora 25.

[chet@caleb-fedora25 bash-20170407]$ ./bash --version
GNU bash, version 4.4.12(1)-maint (x86_64-unknown-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[chet@caleb-fedora25 bash-20170407]$ gdb ./bash
GNU gdb (GDB) Fedora 7.12-24.fc25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bash...done.
(gdb) b xfree
Breakpoint 1 at 0x47e180: file /home/chet/src/bash-20170407/xmalloc.c, line
147.
(gdb) r -c ''
Starting program: /home/chet/build/bash-20170407/bash -c ''
Missing separate debuginfos, use: dnf debuginfo-install
glibc-2.24-3.fc25.x86_64

Breakpoint 1, xfree (string=0x7bd218)
    at /home/chet/src/bash-20170407/xmalloc.c:147
147	  if (string)
Missing separate debuginfos, use: dnf debuginfo-install
ncurses-libs-6.0-6.20160709.fc25.x86_64
(gdb) s
148	    free (string);
(gdb) s
free (mem=0x7bd218) at /home/chet/src/bash-20170407/lib/malloc/malloc.c:1338
1338	  internal_free (mem,  (char *)NULL, 0, 0);
(gdb) s
internal_free (mem=0x7bd218, file=0x0, line=0, flags=0)
    at /home/chet/src/bash-20170407/lib/malloc/malloc.c:868
868	  if ((ap = (char *)mem) == 0)
(gdb)


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 13 14:22:10 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyjNi-0008Ci-59
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 14:22:10 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50757)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyjNf-0008Cb-Cd
	for bug-bash@gnu.org; Thu, 13 Apr 2017 14:22:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cyjNa-0005wl-Cn
	for bug-bash@gnu.org; Thu, 13 Apr 2017 14:22:07 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:40429
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cyjNa-0005vY-5u
	for bug-bash@gnu.org; Thu, 13 Apr 2017 14:22:02 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALH00165; Thu, 13 Apr 2017 14:22:00 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCR05415 (AUTH cpr);
	Thu, 13 Apr 2017 14:22:00 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
	<CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
	<84ba06f5-1585-01b0-4eb4-66c27351a5d4@case.edu>
	<CAOnWdohJ3gDsPiga4pYXxOs1oXRAJ4btG3_MbuoSUyCWoiKfnQ@mail.gmail.com>
	<b52915a1-2e01-346b-7dd0-17bfb16a0088@case.edu>
To: Reuben Thomas <rrt@sc3d.org>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <722f0023-24a2-0e71-dae7-b9f27563e379@case.edu>
Date: Thu, 13 Apr 2017 14:21:59 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <b52915a1-2e01-346b-7dd0-17bfb16a0088@case.edu>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Status: score=8/60, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.13.173016:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	URI_ENDS_IN_HTML, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__MULTIPLE_URI_TEXT, __URI_IN_BODY, __URI_NOT_IMG,
	__FORWARDED_MSG, __NO_HTML_TAG_RAW, BODY_SIZE_3000_3999,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 18:22:08 -0000

On 4/13/17 11:46 AM, Chet Ramey wrote:
> On 4/13/17 11:41 AM, Reuben Thomas wrote:
> 
>> â€‹This is not the result I obtained. I simply ran gdb on the bash binary,
>> valgrind was not involved.â€‹
> 
> If you didn't build the binary yourself, you don't know what changes were
> made to it.  Here's what I got on Fedora 25.

And before anyone asks, here's what I got on Debian 8 with bash-4.4.12,
built from source.

chet@debian8-caleb:~/build/bash-4.4.12$ ./bash --version
GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
chet@debian8-caleb:~/build/bash-4.4.12$ gdb ./bash
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bash...done.
(gdb) b xfree
Breakpoint 1 at 0x4799b0: file /home/chet/src/bash-4.4.12/xmalloc.c, line 147.
(gdb) r -c ''
Starting program: /home/chet/build/bash-4.4.12/bash -c ''

Breakpoint 1, xfree (string=0x71d1c8)
    at /home/chet/src/bash-4.4.12/xmalloc.c:147
147	  if (string)
(gdb) where
#0  xfree (string=0x71d1c8) at /home/chet/src/bash-4.4.12/xmalloc.c:147
#1  0x000000000046194c in unwind_frame_run_internal (
    tag=0x4d67e9 "parse_and_execute top", ignore=0x0)
    at /home/chet/src/bash-4.4.12/unwind_prot.c:333
#2  0x0000000000461d60 in without_interrupts (arg2=<optimized out>,
    arg1=<optimized out>, function=<optimized out>)
    at /home/chet/src/bash-4.4.12/unwind_prot.c:123
#3  run_unwind_frame (tag=0x71d1c8 "",
    tag@entry=0x4d67e9 "parse_and_execute top")
    at /home/chet/src/bash-4.4.12/unwind_prot.c:151
#4  0x000000000047ff99 in parse_and_execute (string=<optimized out>,
    from_file=from_file@entry=0x4c0905 "-c", flags=flags@entry=4)
    at /home/chet/src/bash-4.4.12/builtins/evalstring.c:455
#5  0x000000000041f4ba in run_one_command (command=<optimized out>)
    at /home/chet/src/bash-4.4.12/shell.c:1399
#6  0x0000000000421122 in main (argc=3, argv=0x7fffffffe368,
    env=0x7fffffffe388) at /home/chet/src/bash-4.4.12/shell.c:724
(gdb) s
148	    free (string);
(gdb) s
free (mem=0x71d1c8) at /home/chet/src/bash-4.4.12/lib/malloc/malloc.c:1273
1273	  internal_free (mem,  (char *)NULL, 0, 0);
(gdb) s
internal_free (mem=0x71d1c8, file=0x0, line=0, flags=<optimized out>)
    at /home/chet/src/bash-4.4.12/lib/malloc/malloc.c:846
846	internal_free (mem, file, line, flags)
(gdb)



-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 13 15:57:12 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cykrg-0003Li-Io
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 15:57:12 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47237)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cykre-0003Jp-2A
	for bug-bash@gnu.org; Thu, 13 Apr 2017 15:57:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cykrc-0001mZ-DM
	for bug-bash@gnu.org; Thu, 13 Apr 2017 15:57:10 -0400
Received: from mail-qk0-x22b.google.com ([2607:f8b0:400d:c09::22b]:33897)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cykrc-0001lS-6n
	for bug-bash@gnu.org; Thu, 13 Apr 2017 15:57:08 -0400
Received: by mail-qk0-x22b.google.com with SMTP id p68so56525900qke.1
	for <bug-bash@gnu.org>; Thu, 13 Apr 2017 12:57:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=J6TDPNYPtsgfzwhoV8AuNYESQS+toEGA40w+PuVahG0=;
	b=k7lk7+OWAXitqfLUuU0+Fy/2w3XQ3l5SnteRHZZBfJ5CgJfSWQ7uvWoFg0w82W0MSC
	Wu+p9fgNqPjbwL+5NwAYpoFxI8agqjXM1LRaaKc/KAsduIf8876XAvSFDveupPCfiIs9
	FTSuLlC13rMaZHnMz8nMmU2/BwM0hq7mNDuPQ=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=J6TDPNYPtsgfzwhoV8AuNYESQS+toEGA40w+PuVahG0=;
	b=AGtIm8VgSVo9fgE8FmUWxskim7+U+m4trB41ylXHocpiGTzwEP6UjWk6Dte+82n2qj
	pilc3wHTjN7c7kkisdG0TYDz7XlVze+e5Ig1fC6gsYnYxY4/2qLNRETnAZNScK3Sbzi7
	tMsnbD2t/kr2RqK+thWyckY1jXLoGO0wW8NoLmOYOzkmAVhpIInjTcvPZYdIbxa2y0uL
	0Z4yLwvS12iBhfcuW6FbCKtHbUDc+OB26XkO6s5z0iVq1ouXGIps5KQm3XCVImy5rwWt
	naZaUP2Ay8VC//nvojSyn8cW9WyE73b24P1yxRFvxFshx0mi5KJtEG1KtiphErq0B23o
	xPbg==
X-Gm-Message-State: AN3rC/6jG5jEpW4kZy06HY4UFIkb3eDw564+K/ZLcbWe+tQyahy//g95
	9ZEzMeSieHmhAh8IePDDCz/OnPpGCGD3SJs=
X-Received: by 10.55.103.212 with SMTP id b203mr3956467qkc.264.1492113427301; 
	Thu, 13 Apr 2017 12:57:07 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Thu, 13 Apr 2017 12:57:06 -0700 (PDT)
In-Reply-To: <b52915a1-2e01-346b-7dd0-17bfb16a0088@case.edu>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
	<CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
	<84ba06f5-1585-01b0-4eb4-66c27351a5d4@case.edu>
	<CAOnWdohJ3gDsPiga4pYXxOs1oXRAJ4btG3_MbuoSUyCWoiKfnQ@mail.gmail.com>
	<b52915a1-2e01-346b-7dd0-17bfb16a0088@case.edu>
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 13 Apr 2017 20:57:06 +0100
Message-ID: <CAOnWdogMSHJpRFY-OdHcU1S4x9fwQcNW3QD=A5WV75FrODiZHw@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=94eb2c057126cca19b054d11ba78
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::22b
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 19:57:11 -0000

--94eb2c057126cca19b054d11ba78
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 13 April 2017 at 16:46, Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/13/17 11:41 AM, Reuben Thomas wrote:
>
> > =E2=80=8BThis is not the result I obtained. I simply ran gdb on the bas=
h binary,
> > valgrind was not involved.=E2=80=8B
>
> If you didn't build the binary yourself,


=E2=80=8BI did, from git master. Sorry that wasn't clear.=E2=80=8B

=E2=80=8BThanks for your gdb traces.

Here's mine on Ubuntu 16.04:

$ ./bash --version
GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.htm=
l
>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ gdb ./bash
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.htm=
l
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bash...done.
(gdb) b xfree
Breakpoint 1 at 0x47ca80: file xmalloc.c, line 147.
(gdb) r -c ''
Starting program: /home/rrt/.local/var/repo/bash/bash -c ''
s is  0x721368
s is  0x721368
string is  0x721368

Breakpoint 1, xfree (string=3D0x721368) at xmalloc.c:147
147      if (string)
(gdb) s
148        free (string);
(gdb) s
internal_free (mem=3D0x721368, file=3D0x0, line=3D0, flags=3D<optimised out=
>) at
malloc.c:846
846    malloc.c: No such file or directory.
(gdb) s
858    in malloc.c
(gdb) p free
$1 =3D {void (void *)} 0x7ffff7df0d80 <free>
(gdb)

So it seems I misunderstood what gdb was telling me: "p free" gives the
address of glibc free (even if I do it inside xfree). But it is running
bash's free.

(There are some extra diagnostics there which are debugging statements I
put in.)

Meanwhile, in the valgrind bug report, Mark Wielaard observed:

"I think the problem is that bash not only has its own malloc/free
implementation (valgrind should intercept that just fine). But also has
malloc wrappers for some malloc functions that call their internal
counterparts directly (so valgrind won't know that is a matching
allocation/deallocation function)."

Mark manages to fix the problem by defining DISABLE_MALLOC_WRAPPERS, which
is at least less drastic than configuring --without-bash-malloc.

I shall pursue the matter on the Valgrind side. Mark also says that
compiled thus he finds some small memory leaks in bash, so I'll report back
if I can confirm.

Thanks very much again for your help with this problem.

--=20
http://rrt.sc3d.org

--94eb2c057126cca19b054d11ba78
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1=
3 April 2017 at 16:46, Chet Ramey <span dir=3D"ltr">&lt;<a href=3D"mailto:c=
het.ramey@case.edu" target=3D"_blank">chet.ramey@case.edu</a>&gt;</span> wr=
ote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=3D"gm=
ail-m_8576630350259732944gmail-">On 4/13/17 11:41 AM, Reuben Thomas wrote:<=
br>
<br>
&gt; =E2=80=8BThis is not the result I obtained. I simply ran gdb on the ba=
sh binary,<br>
&gt; valgrind was not involved.=E2=80=8B<br>
<br>
</span>If you didn&#39;t build the binary yourself,</blockquote><div><br><d=
iv style=3D"font-size:small" class=3D"gmail_default">=E2=80=8BI did, from g=
it master. Sorry that wasn&#39;t clear.=E2=80=8B</div><br><div style=3D"fon=
t-size:small" class=3D"gmail_default">=E2=80=8BThanks for your gdb traces.<=
br><br>Here&#39;s mine on Ubuntu 16.04:<br><br>$ ./bash --version<br>GNU ba=
sh, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)<br>Copyright (C) 2=
016 Free Software Foundation, Inc.<br>License GPLv3+: GNU GPL version 3 or =
later &lt;<a href=3D"http://gnu.org/licenses/gpl.html" target=3D"_blank">ht=
tp://gnu.org/licenses/gpl.<wbr>html</a>&gt;<br><br>This is free software; y=
ou are free to change and redistribute it.<br>There is NO WARRANTY, to the =
extent permitted by law.<br>$ gdb ./bash<br>GNU gdb (Ubuntu 7.11.1-0ubuntu1=
~16.04) 7.11.1<br>Copyright (C) 2016 Free Software Foundation, Inc.<br>Lice=
nse GPLv3+: GNU GPL version 3 or later &lt;<a href=3D"http://gnu.org/licens=
es/gpl.html" target=3D"_blank">http://gnu.org/licenses/gpl.<wbr>html</a>&gt=
;<br>This is free software: you are free to change and redistribute it.<br>=
There is NO WARRANTY, to the extent permitted by law.=C2=A0 Type &quot;show=
 copying&quot;<br>and &quot;show warranty&quot; for details.<br>This GDB wa=
s configured as &quot;x86_64-linux-gnu&quot;.<br>Type &quot;show configurat=
ion&quot; for configuration details.<br>For bug reporting instructions, ple=
ase see:<br>&lt;<a href=3D"http://www.gnu.org/software/gdb/bugs/" target=3D=
"_blank">http://www.gnu.org/software/<wbr>gdb/bugs/</a>&gt;.<br>Find the GD=
B manual and other documentation resources online at:<br>&lt;<a href=3D"htt=
p://www.gnu.org/software/gdb/documentation/" target=3D"_blank">http://www.g=
nu.org/software/<wbr>gdb/documentation/</a>&gt;.<br>For help, type &quot;he=
lp&quot;.<br>Type &quot;apropos word&quot; to search for commands related t=
o &quot;word&quot;...<br>Reading symbols from ./bash...done.<br>(gdb) b xfr=
ee<br>Breakpoint 1 at 0x47ca80: file xmalloc.c, line 147.<br>(gdb) r -c &#3=
9;&#39;<br>Starting program: /home/rrt/.local/var/repo/<wbr>bash/bash -c &#=
39;&#39;<br>s is=C2=A0 0x721368<br>s is=C2=A0 0x721368<br>string is=C2=A0 0=
x721368<br><br>Breakpoint 1, xfree (string=3D0x721368) at xmalloc.c:147<br>=
147=C2=A0=C2=A0=C2=A0 =C2=A0 if (string)<br>(gdb) s<br>148=C2=A0=C2=A0=C2=
=A0 =C2=A0=C2=A0=C2=A0 free (string);<br>(gdb) s<br>internal_free (mem=3D0x=
721368, file=3D0x0, line=3D0, flags=3D&lt;optimised out&gt;) at malloc.c:84=
6<br>846=C2=A0=C2=A0=C2=A0 malloc.c: No such file or directory.<br>(gdb) s<=
br>858=C2=A0=C2=A0=C2=A0 in malloc.c<br>(gdb) p free<br>$1 =3D {void (void =
*)} 0x7ffff7df0d80 &lt;free&gt;<br>(gdb) <br><br></div><div style=3D"font-s=
ize:small" class=3D"gmail_default">So it seems I misunderstood what gdb was=
 telling me: &quot;p free&quot; gives the address of glibc free (even if I =
do it inside xfree). But it is running bash&#39;s free.<br><br></div><div s=
tyle=3D"font-size:small" class=3D"gmail_default">(There are some extra diag=
nostics there which are debugging statements I put in.)<br><br></div><div s=
tyle=3D"font-size:small" class=3D"gmail_default">Meanwhile, in the valgrind=
 bug report, Mark Wielaard observed:<br><br>&quot;I think the problem is th=
at bash not only has its own malloc/free implementation (valgrind should in=
tercept that just fine). But also has malloc wrappers for some malloc funct=
ions that call their internal counterparts directly (so valgrind won&#39;t =
know that is a matching allocation/deallocation function).&quot;<br><br></d=
iv><div style=3D"font-size:small" class=3D"gmail_default">Mark manages to f=
ix the problem by defining DISABLE_MALLOC_WRAPPERS, which is at least less =
drastic than configuring --without-bash-malloc.<br><br></div><div style=3D"=
font-size:small" class=3D"gmail_default">I shall pursue the matter on the V=
algrind side. Mark also says that compiled thus he finds some small memory =
leaks in bash, so I&#39;ll report back if I can confirm.<br><br></div><div =
style=3D"font-size:small" class=3D"gmail_default">Thanks very much again fo=
r your help with this problem.<br></div></div></div><br>-- <br><div class=
=3D"gmail-m_8576630350259732944gmail_signature"><a href=3D"http://rrt.sc3d.=
org" target=3D"_blank">http://rrt.sc3d.org</a></div>
</div></div>

--94eb2c057126cca19b054d11ba78--


From MAILER-DAEMON Thu Apr 13 16:12:12 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cyl6C-0007tB-95
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 16:12:12 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55311)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyl6A-0007t3-NC
	for bug-bash@gnu.org; Thu, 13 Apr 2017 16:12:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cyl69-0003zJ-ND
	for bug-bash@gnu.org; Thu, 13 Apr 2017 16:12:10 -0400
Received: from mail-qt0-x229.google.com ([2607:f8b0:400d:c0d::229]:32840)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cyl69-0003z0-GH
	for bug-bash@gnu.org; Thu, 13 Apr 2017 16:12:09 -0400
Received: by mail-qt0-x229.google.com with SMTP id m36so54308236qtb.0
	for <bug-bash@gnu.org>; Thu, 13 Apr 2017 13:12:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:from:date:message-id:subject:to;
	bh=FJfCjNP87jTrbLgofxvC1kax7qr1HBwqmmTTgoSHjtc=;
	b=YLASB38trCNd2gZ7uqhkl1diyErctSccVZWooVnkksS1X1vzU+cj1aZzyXiab9aaJ/
	hKpjnKu0ttj8Zu1ByIzx22thn0vErBTdUIf1YpISLTXt1wFYT6FKdYXpJ0u1IXZ8YdNn
	Dch6aLo8eDqPAqf0/qauiSBsf+AW24O5mRz9Y=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=FJfCjNP87jTrbLgofxvC1kax7qr1HBwqmmTTgoSHjtc=;
	b=OqAT3W1/Yi2HB4QGYIIleaL6rJPqSuIQ1lVtn+ht5WGaqRD7VmpL5qXJSQ9tQjNp6d
	LcTvC2m78EUFBKGZsUx4gvLcIaHh4ADhAOfoB3DAmk3ZMWE4iA5uYej7U6IYjywMZaja
	Xk8Oub2kepWanME3twxBduTdDEIicfZNQcRqDw0hRerBmMphkwRdCFNIhOQrzIvZzLtS
	EoxW6Z9byTzHKPb6r5BIl5ViwV5sc7WXcBVS5boUqg88BamOnEAGvou8+Pq+ukaXwRjk
	zaIQLgmpBv8VBMtPQ7DgGGGLxadFZF/y2PoEdhAWNOlnVczp40nnBQDMw1xmlEnmqhyo
	7UHA==
X-Gm-Message-State: AN3rC/7xeay4Oi1/jcqupe/E7qH7i6ijaJi8w49zyFzg7Kgymm8BCAAU
	i7Z7x1MLaJFtWlM/7HlsSQQm8mEr8QGx6OQ=
X-Received: by 10.200.53.45 with SMTP id y42mr4346158qtb.136.1492114328470;
	Thu, 13 Apr 2017 13:12:08 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Thu, 13 Apr 2017 13:12:08 -0700 (PDT)
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 13 Apr 2017 21:12:08 +0100
Message-ID: <CAOnWdoj8scO+BBpktmjfQidJMvJ75t2-=P6BK3ycP91qN5D81w@mail.gmail.com>
Subject: Leaks detected by valgrind
To: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a11403cc8836592054d11f0f2
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c0d::229
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 20:12:11 -0000

--001a11403cc8836592054d11f0f2
Content-Type: text/plain; charset=UTF-8

Here they are. I guess you probably won't care about them as as far as I
can see they are all one-off allocations at initialization:

==1289== 276 bytes in 1 blocks are definitely lost in loss record 230 of 249
==1289==    at 0x4C2DB2F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1289==    by 0x4793CF: xmalloc (xmalloc.c:112)
==1289==    by 0x472F48: set_default_locale (locale.c:81)
==1289==    by 0x420900: main (shell.c:411)
==1289==
==1289== 1,008 bytes in 1 blocks are definitely lost in loss record 232 of
249
==1289==    at 0x4C2DB2F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1289==    by 0x47939A: xmalloc (xmalloc.c:112)
==1289==    by 0x496FDD: sh_setlinebuf (setlinebuf.c:45)
==1289==    by 0x41F83C: shell_initialize (shell.c:1799)
==1289==    by 0x4210BB: main (shell.c:570)
==1289==
==1289== 1,008 bytes in 1 blocks are definitely lost in loss record 233 of
249
==1289==    at 0x4C2DB2F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1289==    by 0x47939A: xmalloc (xmalloc.c:112)
==1289==    by 0x496FDD: sh_setlinebuf (setlinebuf.c:45)
==1289==    by 0x41F848: shell_initialize (shell.c:1800)
==1289==    by 0x4210BB: main (shell.c:570)
==1289==

-- 
http://rrt.sc3d.org

--001a11403cc8836592054d11f0f2
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-size:small">Her=
e they are. I guess you probably won&#39;t care about them as as far as I c=
an see they are all one-off allocations at initialization:<br><br>=3D=3D128=
9=3D=3D 276 bytes in 1 blocks are definitely lost in loss record 230 of 249=
<br>=3D=3D1289=3D=3D=C2=A0=C2=A0=C2=A0 at 0x4C2DB2F: malloc (in /usr/lib/va=
lgrind/vgpreload_memcheck-amd64-linux.so)<br>=3D=3D1289=3D=3D=C2=A0=C2=A0=
=C2=A0 by 0x4793CF: xmalloc (xmalloc.c:112)<br>=3D=3D1289=3D=3D=C2=A0=C2=A0=
=C2=A0 by 0x472F48: set_default_locale (locale.c:81)<br>=3D=3D1289=3D=3D=C2=
=A0=C2=A0=C2=A0 by 0x420900: main (shell.c:411)<br>=3D=3D1289=3D=3D <br>=3D=
=3D1289=3D=3D 1,008 bytes in 1 blocks are definitely lost in loss record 23=
2 of 249<br>=3D=3D1289=3D=3D=C2=A0=C2=A0=C2=A0 at 0x4C2DB2F: malloc (in /us=
r/lib/valgrind/vgpreload_memcheck-amd64-linux.so)<br>=3D=3D1289=3D=3D=C2=A0=
=C2=A0=C2=A0 by 0x47939A: xmalloc (xmalloc.c:112)<br>=3D=3D1289=3D=3D=C2=A0=
=C2=A0=C2=A0 by 0x496FDD: sh_setlinebuf (setlinebuf.c:45)<br>=3D=3D1289=3D=
=3D=C2=A0=C2=A0=C2=A0 by 0x41F83C: shell_initialize (shell.c:1799)<br>=3D=
=3D1289=3D=3D=C2=A0=C2=A0=C2=A0 by 0x4210BB: main (shell.c:570)<br>=3D=3D12=
89=3D=3D <br>=3D=3D1289=3D=3D 1,008 bytes in 1 blocks are definitely lost i=
n loss record 233 of 249<br>=3D=3D1289=3D=3D=C2=A0=C2=A0=C2=A0 at 0x4C2DB2F=
: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)<br>=3D=3D=
1289=3D=3D=C2=A0=C2=A0=C2=A0 by 0x47939A: xmalloc (xmalloc.c:112)<br>=3D=3D=
1289=3D=3D=C2=A0=C2=A0=C2=A0 by 0x496FDD: sh_setlinebuf (setlinebuf.c:45)<b=
r>=3D=3D1289=3D=3D=C2=A0=C2=A0=C2=A0 by 0x41F848: shell_initialize (shell.c=
:1800)<br>=3D=3D1289=3D=3D=C2=A0=C2=A0=C2=A0 by 0x4210BB: main (shell.c:570=
)<br>=3D=3D1289=3D=3D <br clear=3D"all"></div><br>-- <br><div class=3D"gmai=
l_signature"><a href=3D"http://rrt.sc3d.org" target=3D"_blank">http://rrt.s=
c3d.org</a></div>
</div>

--001a11403cc8836592054d11f0f2--


From MAILER-DAEMON Thu Apr 13 16:17:23 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cylBC-0008MF-Uf
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 16:17:22 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57713)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cylBA-0008LF-EY
	for bug-bash@gnu.org; Thu, 13 Apr 2017 16:17:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cylB7-0007lg-9u
	for bug-bash@gnu.org; Thu, 13 Apr 2017 16:17:20 -0400
Received: from mpv3-2015.cwru.edu ([129.22.103.194]:13677
	helo=mpv3-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cylB7-0007kU-0x
	for bug-bash@gnu.org; Thu, 13 Apr 2017 16:17:17 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv3-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALM04247; Thu, 13 Apr 2017 16:17:14 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCR30218 (AUTH cpr);
	Thu, 13 Apr 2017 16:17:14 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Running bash under valgrind gives "invalid free()"
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
	<CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
	<84ba06f5-1585-01b0-4eb4-66c27351a5d4@case.edu>
	<CAOnWdohJ3gDsPiga4pYXxOs1oXRAJ4btG3_MbuoSUyCWoiKfnQ@mail.gmail.com>
	<b52915a1-2e01-346b-7dd0-17bfb16a0088@case.edu>
	<CAOnWdogMSHJpRFY-OdHcU1S4x9fwQcNW3QD=A5WV75FrODiZHw@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>
Cc: chet.ramey@case.edu, Bash - Bug <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <758c539f-7c00-20fd-fb52-c9f7133684c0@case.edu>
Date: Thu, 13 Apr 2017 16:17:14 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdogMSHJpRFY-OdHcU1S4x9fwQcNW3QD=A5WV75FrODiZHw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv3-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.13.193017:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODY_SIZE_700_799,
	BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1,
	__MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10,
	BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES, __CC_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.194
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 20:17:21 -0000

On 4/13/17 3:57 PM, Reuben Thomas wrote:

> Meanwhile, in the valgrind bug report, Mark Wielaard observed:
> 
> "I think the problem is that bash not only has its own malloc/free
> implementation (valgrind should intercept that just fine). But also has
> malloc wrappers for some malloc functions that call their internal
> counterparts directly (so valgrind won't know that is a matching
> allocation/deallocation function)."

Yes, if he wants the details, feel free to forward my message from earlier
today.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 13 16:23:31 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cylH9-0000bH-KA
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 16:23:31 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60343)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cylH7-0000bA-EK
	for bug-bash@gnu.org; Thu, 13 Apr 2017 16:23:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1cylH2-0002sD-GA
	for bug-bash@gnu.org; Thu, 13 Apr 2017 16:23:29 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:12080
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1cylH2-0002rf-AJ
	for bug-bash@gnu.org; Thu, 13 Apr 2017 16:23:24 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMR03378; Thu, 13 Apr 2017 16:23:22 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCR31473 (AUTH cpr);
	Thu, 13 Apr 2017 16:23:20 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Leaks detected by valgrind
References: <CAOnWdoj8scO+BBpktmjfQidJMvJ75t2-=P6BK3ycP91qN5D81w@mail.gmail.com>
To: Reuben Thomas <rrt@sc3d.org>, Bash - Bug <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <99befd89-6de7-828f-210f-2f4333a7dad8@case.edu>
Date: Thu, 13 Apr 2017 16:23:19 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOnWdoj8scO+BBpktmjfQidJMvJ75t2-=P6BK3ycP91qN5D81w@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.13.195417:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODY_SIZE_1100_1199,
	BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1,
	__MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10,
	BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, __SINGLE_URI_TEXT,
	SINGLE_URI_IN_BODY, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 20:23:30 -0000

On 4/13/17 4:12 PM, Reuben Thomas wrote:
> Here they are. I guess you probably won't care about them as as far as I
> can see they are all one-off allocations at initialization:
> 
> ==1289== 276 bytes in 1 blocks are definitely lost in loss record 230 of 249
> ==1289==    at 0x4C2DB2F: malloc (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==1289==    by 0x4793CF: xmalloc (xmalloc.c:112)
> ==1289==    by 0x472F48: set_default_locale (locale.c:81)
> ==1289==    by 0x420900: main (shell.c:411)

This one is interesting. It's come up before. Bash makes a copy of the
default locale (as returned by setlocale()) for its own purposes.  Some
systems use a static buffer for that value; some systems, including glibc,
return allocated memory (even though the man page warns to not assume
anything about the returned string).

You're right about the two buffers for setlinebuf().

Thanks.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 13 17:05:26 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cylvi-0004Tn-JB
	for mharc-bug-bash@gnu.org; Thu, 13 Apr 2017 17:05:26 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49485)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cylvg-0004Te-1M
	for bug-bash@gnu.org; Thu, 13 Apr 2017 17:05:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cylve-0004fV-L3
	for bug-bash@gnu.org; Thu, 13 Apr 2017 17:05:24 -0400
Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:34912)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cylve-0004fI-GR
	for bug-bash@gnu.org; Thu, 13 Apr 2017 17:05:22 -0400
Received: by mail-qk0-x232.google.com with SMTP id f133so57786631qke.2
	for <bug-bash@gnu.org>; Thu, 13 Apr 2017 14:05:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=GOcmbwiDMO/av/5rpcuSRpZgIcfkjU+lUY3ePrwPer0=;
	b=QMnIhnupwuI9Tim19ITdCdjKi52szdAzs/yqFM94ErjynN7SE5kucRfNYwrDIwhv/u
	2dLr0SRsgyMjRgTKNBtSKBiaJlsZBIzGXcVCG990gJl5WmvgyQ1cbtA86zY6nUBfq+YW
	ZzxnYj89AvtqyMGLeRGBNKWd4kSn5hY6BFcOU=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=GOcmbwiDMO/av/5rpcuSRpZgIcfkjU+lUY3ePrwPer0=;
	b=Ucs4+TOdZA9M0Zs9PxTtMF0zuwoBI+WLurq7cdALjbRh+xfEOjH/4tnM3Xb3XYk6d7
	FTwGaM57/8WIrQoDZt2QdG8twVzfwOyWKl4PuKPcaypXadupwMBFPdGOPx+H/sPkw6bw
	RRnEm5PQnsAH0aMo5R5EvvKebAwXL9GWbLVKViEgSadHiwZ8eQ/k+NNoi7W1RaLYYogx
	HnYL5N7rHHZiRLqc+Mgk5T0DQlypAp5AlbOLB6FDgXjTYX6kjMNJR2RY9svfzxgI84zV
	QzYZYDJTKbQysKHaBrpC+XjIQr553dUXcQ+pKUUpsdCfd6UVMHPUHvyvdLyAkcbR764d
	usZQ==
X-Gm-Message-State: AN3rC/63FCnCvlWzAxU14eJeUGwgxNL0M6aEWlRo2zHefmtwDnfE8yPW
	tfXFYCCIBpBe/SNlUALzWNdHj5gx3NjkHrQ=
X-Received: by 10.55.42.19 with SMTP id q19mr4719095qkh.9.1492117521410; Thu,
	13 Apr 2017 14:05:21 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Thu, 13 Apr 2017 14:05:20 -0700 (PDT)
In-Reply-To: <758c539f-7c00-20fd-fb52-c9f7133684c0@case.edu>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
	<CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
	<84ba06f5-1585-01b0-4eb4-66c27351a5d4@case.edu>
	<CAOnWdohJ3gDsPiga4pYXxOs1oXRAJ4btG3_MbuoSUyCWoiKfnQ@mail.gmail.com>
	<b52915a1-2e01-346b-7dd0-17bfb16a0088@case.edu>
	<CAOnWdogMSHJpRFY-OdHcU1S4x9fwQcNW3QD=A5WV75FrODiZHw@mail.gmail.com>
	<758c539f-7c00-20fd-fb52-c9f7133684c0@case.edu>
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 13 Apr 2017 22:05:20 +0100
Message-ID: <CAOnWdoiE9yZiOXkevsSbKM59SkWnCktWe6Ab9w9RYzhLNGumpA@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a11494a98d3c8e9054d12ae28
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::232
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 13 Apr 2017 21:05:25 -0000

--001a11494a98d3c8e9054d12ae28
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 13 April 2017 at 21:17, Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/13/17 3:57 PM, Reuben Thomas wrote:
>
> > Meanwhile, in the valgrind bug report, Mark Wielaard observed:
> >
> > "I think the problem is that bash not only has its own malloc/free
> > implementation (valgrind should intercept that just fine). But also has
> > malloc wrappers for some malloc functions that call their internal
> > counterparts directly (so valgrind won't know that is a matching
> > allocation/deallocation function)."
>
> Yes, if he wants the details, feel free to forward my message from earlie=
r
> today.
>

=E2=80=8BThanks, I
=E2=80=8B already linked to it in the valgrind bug report
.=E2=80=8B

=E2=80=8B=E2=80=8B
--=20
http://rrt.sc3d.org

--001a11494a98d3c8e9054d12ae28
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1=
3 April 2017 at 21:17, Chet Ramey <span dir=3D"ltr">&lt;<a href=3D"mailto:c=
het.ramey@case.edu" target=3D"_blank">chet.ramey@case.edu</a>&gt;</span> wr=
ote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=3D"gm=
ail-">On 4/13/17 3:57 PM, Reuben Thomas wrote:<br>
<br>
&gt; Meanwhile, in the valgrind bug report, Mark Wielaard observed:<br>
&gt;<br>
&gt; &quot;I think the problem is that bash not only has its own malloc/fre=
e<br>
&gt; implementation (valgrind should intercept that just fine). But also ha=
s<br>
&gt; malloc wrappers for some malloc functions that call their internal<br>
&gt; counterparts directly (so valgrind won&#39;t know that is a matching<b=
r>
&gt; allocation/deallocation function).&quot;<br>
<br>
</span>Yes, if he wants the details, feel free to forward my message from e=
arlier<br>
today.<br></blockquote><div><br><div class=3D"gmail-h5">=E2=80=8BThanks, I<=
div style=3D"font-size:small;display:inline" class=3D"gmail_default">=E2=80=
=8B already linked to it in the valgrind bug report</div><div style=3D"font=
-size:small;display:inline" class=3D"gmail_default">.=E2=80=8B<br><br clear=
=3D"all"></div><div style=3D"font-size:small" class=3D"gmail_default">=E2=
=80=8B=E2=80=8B</div></div></div></div>-- <br><div class=3D"gmail_signature=
"><a href=3D"http://rrt.sc3d.org" target=3D"_blank">http://rrt.sc3d.org</a>=
</div>
</div></div>

--001a11494a98d3c8e9054d12ae28--


From MAILER-DAEMON Fri Apr 14 17:18:57 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cz8cK-00011X-R6
	for mharc-bug-bash@gnu.org; Fri, 14 Apr 2017 17:18:56 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36147)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cz8cG-00010C-A6
	for bug-bash@gnu.org; Fri, 14 Apr 2017 17:18:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1cz8cE-0008Bx-W2
	for bug-bash@gnu.org; Fri, 14 Apr 2017 17:18:52 -0400
Received: from mail-qt0-x22b.google.com ([2607:f8b0:400d:c0d::22b]:36531)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <rrt@sc3d.org>) id 1cz8cE-0008Bs-Pp
	for bug-bash@gnu.org; Fri, 14 Apr 2017 17:18:50 -0400
Received: by mail-qt0-x22b.google.com with SMTP id g60so5389641qtd.3
	for <bug-bash@gnu.org>; Fri, 14 Apr 2017 14:18:50 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=DZvElJLihlYNQCNdN6Hv7qUEVG+xasnMQ/s5GMpyJiw=;
	b=FRZVVNoR92k6ZQFfb1ZQe6kB9VZGWKKnHaT0Re3SoHRfOufvq3dh/ZIGboKqcz0gCf
	xsEBCH3/lou+SEKgzFnHj97sb2SRmeGyUxrKoVlzGwS9UTdVQraD2N1wPmc/OV++6Nj/
	A24SiE7kir+xrqcWcqOF4eKmDVA1pUaXFV9QU=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=DZvElJLihlYNQCNdN6Hv7qUEVG+xasnMQ/s5GMpyJiw=;
	b=CXaE6Jpsu8AEbGBz7wa0EKrMtAt7t/tsx5LWiyM63tQVADMDIcSMRLLt1njWE6eSQM
	4JzFU+/3mLAlE5Z/IwXqOCqQtnYQjXlQJH20IL+ThaBnYBaOT1EUoh4vqi+3L3XVfJnz
	q5/zS7gUnvmUo3MeiCBqTyW7gUaQTyGoIaqOrWX3LBQbC3RouUVKTtGJZ9DH8+J3GV0H
	l4gj9fOgkqWVrXIa/IH9xSWB9M1R/iSZRB8kGVi8SZzkT4ism14zCZVKIIAeRoh04txa
	CI4qgtlYMtiA0ENoAGuLljhSQ4wAaOtzdJ2X8al+8jNj48GtkxVzk6Cw+RArIThcaMIS
	0+hg==
X-Gm-Message-State: AN3rC/6ziUTuEmzdGYlMmt9TMktd3it5AS2Km09yrtAJ+vp1CE1Kad/N
	QtMgD6C8qKuVOL1SiCiXHTI5FBcDc+JU
X-Received: by 10.200.40.187 with SMTP id i56mr8721286qti.148.1492204729956;
	Fri, 14 Apr 2017 14:18:49 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.85.170 with HTTP; Fri, 14 Apr 2017 14:18:49 -0700 (PDT)
In-Reply-To: <CAOnWdoiE9yZiOXkevsSbKM59SkWnCktWe6Ab9w9RYzhLNGumpA@mail.gmail.com>
References: <CAOnWdogbUTODbUyJboeed-ViG3fWvaSgeX0hOWZWY7WpU4j9Xg@mail.gmail.com>
	<91c27eef-00d4-3a49-0966-d45a8773a9d9@case.edu>
	<CAOnWdohtnwQ+V0QiV1F+ctQwZm4b7vNYvBs67TMd_0AvamY8iQ@mail.gmail.com>
	<908939d3-54e7-1991-1b83-b0970196c140@case.edu>
	<CAOnWdojJoGJ1_+Au39MjiuEa1XrgCfanV=1e_bGsWNK5JxGZKQ@mail.gmail.com>
	<64f77290-6662-4b4d-37e6-6c4a88be30e6@case.edu>
	<CAOnWdohtXiNRph-F7U_LPLwfH_4SJEdzB2Wrb+Q7rnbXQv1ySg@mail.gmail.com>
	<84ba06f5-1585-01b0-4eb4-66c27351a5d4@case.edu>
	<CAOnWdohJ3gDsPiga4pYXxOs1oXRAJ4btG3_MbuoSUyCWoiKfnQ@mail.gmail.com>
	<b52915a1-2e01-346b-7dd0-17bfb16a0088@case.edu>
	<CAOnWdogMSHJpRFY-OdHcU1S4x9fwQcNW3QD=A5WV75FrODiZHw@mail.gmail.com>
	<758c539f-7c00-20fd-fb52-c9f7133684c0@case.edu>
	<CAOnWdoiE9yZiOXkevsSbKM59SkWnCktWe6Ab9w9RYzhLNGumpA@mail.gmail.com>
From: Reuben Thomas <rrt@sc3d.org>
Date: Fri, 14 Apr 2017 22:18:49 +0100
Message-ID: <CAOnWdoin4tf84fGw+LO=qsORHMHVAuWndDDZRQX0YrYc6ykDJA@mail.gmail.com>
Subject: Re: Running bash under valgrind gives "invalid free()"
To: Chester Ramey <chet.ramey@case.edu>
Cc: Bash - Bug <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a113f45ccdc9353054d26fc19
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c0d::22b
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Fri, 14 Apr 2017 21:18:53 -0000

--001a113f45ccdc9353054d26fc19
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 13 April 2017 at 22:05, Reuben Thomas <rrt@sc3d.org> wrote:

>
> On 13 April 2017 at 21:17, Chet Ramey <chet.ramey@case.edu> wrote:
>
>> On 4/13/17 3:57 PM, Reuben Thomas wrote:
>>
>> > Meanwhile, in the valgrind bug report, Mark Wielaard observed:
>> >
>> > "I think the problem is that bash not only has its own malloc/free
>> > implementation (valgrind should intercept that just fine). But also ha=
s
>> > malloc wrappers for some malloc functions that call their internal
>> > counterparts directly (so valgrind won't know that is a matching
>> > allocation/deallocation function)."
>>
>> Yes, if he wants the details, feel free to forward my message from earli=
er
>> today.
>>
>
> =E2=80=8BThanks, I
> =E2=80=8B already linked to it in the valgrind bug report
> .=E2=80=8B
>

=E2=80=8BI've closed the Valgrind bug report WONTFIX. Mark Wielaard there k=
indly
provides a patch to bash to make it play nicely with Valgrind, though I
doubt you'll want to take it (just to be clear, I wouldn't if I were a bash
maintainer!).

=E2=80=8BSince RedHat and Fedora build --without-bash-malloc, that seems an
acceptable solution for Debian/Ubuntu. (Not least, performance there is
less of an issue since the default /bin/sh is no longer bash.)

As Mark says, and if it hasn't already been tried, it would be good if any
benchmarks could be brought to the attention of the glibc maintainers if
there's potential for improvement in glibc's malloc.

--=20
http://rrt.sc3d.org

--001a113f45ccdc9353054d26fc19
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1=
3 April 2017 at 22:05, Reuben Thomas <span dir=3D"ltr">&lt;<a href=3D"mailt=
o:rrt@sc3d.org" target=3D"_blank">rrt@sc3d.org</a>&gt;</span> wrote:<br><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #=
ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div class=3D"gmail_extra"=
><div class=3D"gmail_quote"><span class=3D"">On 13 April 2017 at 21:17, Che=
t Ramey <span dir=3D"ltr">&lt;<a href=3D"mailto:chet.ramey@case.edu" target=
=3D"_blank">chet.ramey@case.edu</a>&gt;</span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><span class=3D"m_9166479922983159645gmail-=
">On 4/13/17 3:57 PM, Reuben Thomas wrote:<br>
<br>
&gt; Meanwhile, in the valgrind bug report, Mark Wielaard observed:<br>
&gt;<br>
&gt; &quot;I think the problem is that bash not only has its own malloc/fre=
e<br>
&gt; implementation (valgrind should intercept that just fine). But also ha=
s<br>
&gt; malloc wrappers for some malloc functions that call their internal<br>
&gt; counterparts directly (so valgrind won&#39;t know that is a matching<b=
r>
&gt; allocation/deallocation function).&quot;<br>
<br>
</span>Yes, if he wants the details, feel free to forward my message from e=
arlier<br>
today.<br></blockquote></span><div><br><div class=3D"m_9166479922983159645g=
mail-h5">=E2=80=8BThanks, I<div>=E2=80=8B already linked to it in the valgr=
ind bug report</div><div>.=E2=80=8B<br></div></div></div></div></div></div>=
</blockquote></div><br><div style=3D"font-size:small" class=3D"gmail_defaul=
t">=E2=80=8BI&#39;ve closed the Valgrind bug report WONTFIX. Mark Wielaard =
there kindly provides a patch to bash to make it play nicely with Valgrind,=
 though I doubt you&#39;ll want to take it (just to be clear, I wouldn&#39;=
t if I were a bash maintainer!).<br clear=3D"all"></div><br><div style=3D"f=
ont-size:small" class=3D"gmail_default">=E2=80=8BSince RedHat and Fedora bu=
ild --without-bash-malloc, that seems an acceptable solution for Debian/Ubu=
ntu. (Not least, performance there is less of an issue since the default /b=
in/sh is no longer bash.)<br><br></div><div style=3D"font-size:small" class=
=3D"gmail_default">As Mark says, and if it hasn&#39;t already been tried, i=
t would be good if any benchmarks could be brought to the attention of the =
glibc maintainers if there&#39;s potential for improvement in glibc&#39;s m=
alloc.<br></div><br>-- <br><div class=3D"gmail_signature" data-smartmail=3D=
"gmail_signature"><a href=3D"http://rrt.sc3d.org" target=3D"_blank">http://=
rrt.sc3d.org</a></div>
</div></div>

--001a113f45ccdc9353054d26fc19--


From MAILER-DAEMON Sun Apr 16 20:09:46 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1czuEk-0004Sx-Dt
	for mharc-bug-bash@gnu.org; Sun, 16 Apr 2017 20:09:46 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:45057)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1czuEh-0004Sr-V6
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:09:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1czuEd-00048g-2d
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:09:43 -0400
Received: from homie.mail.dreamhost.com ([208.97.132.208]:38982
	helo=homiemail-a2.g.dreamhost.com)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <jidanni@jidanni.org>) id 1czuEc-00047B-Ps
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:09:39 -0400
Received: from homiemail-a2.g.dreamhost.com (localhost [127.0.0.1])
	by homiemail-a2.g.dreamhost.com (Postfix) with ESMTP id E79F5280069
	for <bug-bash@gnu.org>; Sun, 16 Apr 2017 17:09:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to
	:subject:date:message-id:mime-version:content-type; s=
	jidanni.org; bh=aQmVTaZL91AL77TRRtujvCNTwYA=; b=lGbxdTOJcz+lMhM0
	G4r51b/DT350gL0ng8PYto6tr/Rum/Otoj/Vhbh+ryZuEymVDAiQ37FvqhbMtT2D
	n580s7WD7CF8dQDUVGXH5NALDMsne5FsJ/etjG6pSioizRFe3lt9K+d0aN+mjixd
	CeY4ZefyFE6Oqnlg9qb3PIyD5EM=
Received: from jidanni.org (122-118-150-84.dynamic.hinet.net [122.118.150.84])
	(using TLSv1 with cipher AES256-SHA (256/256 bits))
	(No client certificate requested)
	(Authenticated sender: jidanni@jidanni.org)
	by homiemail-a2.g.dreamhost.com (Postfix) with ESMTPSA id B7131280062
	for <bug-bash@gnu.org>; Sun, 16 Apr 2017 17:09:36 -0700 (PDT)
From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson <jidanni@jidanni.org>
To: bug-bash@gnu.org
Subject: echo x > a > b > c > d
Date: Mon, 17 Apr 2017 07:42:14 +0800
Message-ID: <87mvbfq5rd.fsf@jidanni.org>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy]
X-Received-From: 208.97.132.208
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 00:09:45 -0000

Maybe bash should catch this
$ echo x > a > b > c > d
and print a warning.
Same with
$ cat < a < b < c < d


From MAILER-DAEMON Sun Apr 16 20:22:58 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1czuRW-000626-Ht
	for mharc-bug-bash@gnu.org; Sun, 16 Apr 2017 20:22:58 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46808)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1czuRU-00061Y-6b
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:22:57 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1czuRT-0005He-AG
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:22:56 -0400
Received: from mail-io0-x233.google.com ([2607:f8b0:4001:c06::233]:36776)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1czuRT-0005GE-4S
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:22:55 -0400
Received: by mail-io0-x233.google.com with SMTP id o22so15635325iod.3
	for <bug-bash@gnu.org>; Sun, 16 Apr 2017 17:22:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-transfer-encoding;
	bh=uf0/U4mQxrtS4OWlfwzBF6krlppWxvdN55qBiM3y4fo=;
	b=U36LZtsFLtTyuX6eHXwHZNdmu9NSgjiLyT7nPGhddZBxr1eut1IbN28Lbw/rHHuJTj
	CEToMCtJlV2xgno/UV5GiO+jqQD22U5tg5+MoUXX3tam486AL+IN5jB0tuRZ2S1MTGs6
	lRQR7sx/ilec+ZwAwsfE5Z2V/Z9eZfuwdpPYpndNMk///mFVNCGq9zAHMbfLfBWzcHnb
	2VGNYVZUEpDbEUz2HC8usJKtxJnDfp758bgmr9UHxKJkBsLaroZkf7L/NUgJXHt6dACF
	1yP3YkwuYEEIVEqaNLrDoeJVSAixSBqGAPc+2UGJklRrZCMCxvJsOqgQSaqpLzdw4zLM
	acnw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc:content-transfer-encoding;
	bh=uf0/U4mQxrtS4OWlfwzBF6krlppWxvdN55qBiM3y4fo=;
	b=MdUYdgoYxpJoSeJl6qAX7QtJFO+RnNGrlqFFIK4+Erh9FrfaPtnu2aP4lsoKmrGuh5
	KrnDgm7hshfozYbV5hIVY1OBV6p86TISzh+yOgkHl4tdgd+Bzb74RX+y64+E0L1HQfNv
	qzEnLXpXSv3cXZ3JKZb5DPW77xQNGegKoe8vMBW7XqYYip8JhBld9drNDZGc1/po1vsw
	pZ8igpyD/XvnsdXKOIQHqpxRvGKwBFF+jADOZ9vZMmyiYEhdmH6UPzVzEWphldbEdA21
	+KPzlGEvD1OWrNp009JBbtzkXd+mQEZefAKH6lGSdbugzDcJJEGotbaRlzMS5+Bsazod
	6wmA==
X-Gm-Message-State: AN3rC/75iaflM2H1KXBSQZ9ZsQVkqzgoG8KIydINWVNtdVU70IdOHCVQ
	15qZZLQiDTB/+avicpAo4ZGh28me7A==
X-Received: by 10.36.43.213 with SMTP id h204mr7910508ita.113.1492388574277;
	Sun, 16 Apr 2017 17:22:54 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.36.135 with HTTP; Sun, 16 Apr 2017 17:22:33 -0700 (PDT)
In-Reply-To: <87mvbfq5rd.fsf@jidanni.org>
References: <87mvbfq5rd.fsf@jidanni.org>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Sun, 16 Apr 2017 19:22:33 -0500
Message-ID: <CAOSMAust8M81HOCEAQnL=bCzjRpBJLfvJ9mecx1bz1jhWt14HQ@mail.gmail.com>
Subject: Re: echo x > a > b > c > d
To: =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= <jidanni@jidanni.org>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::233
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 00:22:57 -0000

On Sun, Apr 16, 2017 at 6:42 PM, =E7=A9=8D=E4=B8=B9=E5=B0=BC Dan Jacobson <=
jidanni@jidanni.org> wrote:
> Maybe bash should catch this
> $ echo x > a > b > c > d
> and print a warning.
> Same with
> $ cat < a < b < c < d

Why? These are perfectly valid grammatical constructs. What kind of
warning are you expecting to see and why?


From MAILER-DAEMON Sun Apr 16 20:41:03 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1czuj1-0007Nr-OF
	for mharc-bug-bash@gnu.org; Sun, 16 Apr 2017 20:41:03 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50688)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1czuj0-0007Nj-0l
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:41:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1czuiw-0002Bj-VU
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:41:02 -0400
Received: from homie.mail.dreamhost.com ([208.97.132.208]:49162
	helo=homiemail-a14.g.dreamhost.com)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <jidanni@jidanni.org>) id 1czuiw-00028r-MV
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:40:58 -0400
Received: from homiemail-a14.g.dreamhost.com (localhost [127.0.0.1])
	by homiemail-a14.g.dreamhost.com (Postfix) with ESMTP id 413C0392076;
	Sun, 16 Apr 2017 17:40:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc
	:subject:references:date:message-id:mime-version:content-type;
	s=jidanni.org; bh=fs2bSZsGb0vkuS+P6FuJVqQS9pU=; b=eAqAEPIT7LjHA
	zAZipIe3Ab+qY0XDA1jzxUY8hGrk65Ky3HP6rgsU+Jaw8I3fe7D2h2iQwES9kF4v
	vrGQb3UU9+9oWBIr7pqM/6aJ+GQ5XWRHJwF3KeStHpaHgUG2/lzn/WkhHtKaQkp5
	piFhuK4ldV7dD64vqtIlcX9wN2oAVM=
Received: from jidanni.org (122-118-150-84.dynamic.hinet.net [122.118.150.84])
	(using TLSv1 with cipher AES256-SHA (256/256 bits))
	(No client certificate requested)
	(Authenticated sender: jidanni@jidanni.org)
	by homiemail-a14.g.dreamhost.com (Postfix) with ESMTPSA id 094D3392075; 
	Sun, 16 Apr 2017 17:40:56 -0700 (PDT)
From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson <jidanni@jidanni.org>
To: Eduardo Bustamante <dualbus@gmail.com>
Cc: "bug-bash\@gnu.org" <bug-bash@gnu.org>
Subject: Re: echo x > a > b > c > d
References: <87mvbfq5rd.fsf@jidanni.org>
Date: Mon, 17 Apr 2017 08:40:53 +0800
Message-ID: <87inm3q31m.fsf@jidanni.org>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 208.97.132.208
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 00:41:02 -0000

OK sorry. I guess they make a lot of sense.


From MAILER-DAEMON Sun Apr 16 20:50:04 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1czurk-000865-GM
	for mharc-bug-bash@gnu.org; Sun, 16 Apr 2017 20:50:04 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51682)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1czuri-00085x-1u
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:50:03 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1czurh-0006RF-BD
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:50:02 -0400
Received: from mail-io0-x231.google.com ([2607:f8b0:4001:c06::231]:36008)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1czurh-0006R3-6q
	for bug-bash@gnu.org; Sun, 16 Apr 2017 20:50:01 -0400
Received: by mail-io0-x231.google.com with SMTP id o22so15968762iod.3
	for <bug-bash@gnu.org>; Sun, 16 Apr 2017 17:50:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-transfer-encoding;
	bh=FXl50QLAaD15hDqpA8G4Td0TLlreKq3Fwp6m+Q27anU=;
	b=XhUDPaK1Rwb/kRzorh94YZ47EsWF+SZy3+6T1mjVWFWbytDPcjjnL2Ipww9WviQuQO
	0uN7vPbxpFnKD4Laz0XWEbxs0uP8a2fOMXlefDC1/q8xn4tEgzxeQlwzw5w3k9WKUZbZ
	wlsLL5BfKFhHcOGoaPEvBhYCfdC0dPjslvt2lnpOMeLD3kwSTE8PJN3Q9esr5txwpOv6
	L36uFAl8qitiulnJN840YjlWkluXE7xizGROqRMk6XepqbtkFczx5y739jbV9ZpA6XcJ
	PtqyNiUz82V3R0rbgM/OkcPqlnIkXgSompMZ6M6ypexNP8pFDQYSwkrND1PjQtHyQPdQ
	aaMQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc:content-transfer-encoding;
	bh=FXl50QLAaD15hDqpA8G4Td0TLlreKq3Fwp6m+Q27anU=;
	b=qAfGyc+aW0KwElzlrSZyQRHOA7+pLYqXHzyZUV+qZG7ySmpGTq/nHWqjLrptxdszI7
	t9MvowxxIQ8P5SBJJYReMMAyW1zFQyhhkuJ6rwfdEZAZ6fXAi1pksGcksNSXI9nxo6S9
	0Buz/SGBHlHSriAPW92jcPIq6W4P9pP/B8u8Yt3FblxpFolsc5vMIPRTXKOW8UtFZbgK
	K2qZf4X5jN1HBGnGX+0Wu0mGFSFkGcjIHt+acqp4GavTnkt/OwfLS0PL4JErEt0KXUoX
	62AXHSVy54xL8GAfQ0uxx3mAqEZG5aIgsOFrQ4HFkbY9iHGnqZAt7WnkKnX77dNV0pwz
	KhPA==
X-Gm-Message-State: AN3rC/6SYRZ++CLR/XNzz/C/AHackVOXvtgyKV/LPY1ASLH4rbJyDaeN
	9sPADPz2V+P39r0OZPe1b9jJTmyG97TX
X-Received: by 10.36.122.212 with SMTP id a203mr6953220itc.113.1492390200292; 
	Sun, 16 Apr 2017 17:50:00 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.36.135 with HTTP; Sun, 16 Apr 2017 17:49:40 -0700 (PDT)
In-Reply-To: <87inm3q31m.fsf@jidanni.org>
References: <87mvbfq5rd.fsf@jidanni.org> <87inm3q31m.fsf@jidanni.org>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Sun, 16 Apr 2017 19:49:40 -0500
Message-ID: <CAOSMAuuFMkbYHg-MKqhX8mP51i9tNTy=GevRGPNjCKHe3z=XGQ@mail.gmail.com>
Subject: Re: echo x > a > b > c > d
To: =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= <jidanni@jidanni.org>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::231
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 00:50:03 -0000

On Sun, Apr 16, 2017 at 7:40 PM, =E7=A9=8D=E4=B8=B9=E5=B0=BC Dan Jacobson <=
jidanni@jidanni.org> wrote:
> OK sorry. I guess they make a lot of sense.

These constructs are valid grammatically, and have a well defined
semantic meaning. See:

dualbus@debian:~$ strace -e open bash -c ': <a <b <c <d' 2>&1|tail -n5
open("a", O_RDONLY)                     =3D 3
open("b", O_RDONLY)                     =3D 3
open("c", O_RDONLY)                     =3D 3
open("d", O_RDONLY)                     =3D 3
+++ exited with 0 +++

dualbus@debian:~$ strace -e open bash -c ': >a >b >c >d' 2>&1|tail -n5
open("a", O_WRONLY|O_CREAT|O_TRUNC, 0666) =3D 3
open("b", O_WRONLY|O_CREAT|O_TRUNC, 0666) =3D 3
open("c", O_WRONLY|O_CREAT|O_TRUNC, 0666) =3D 3
open("d", O_WRONLY|O_CREAT|O_TRUNC, 0666) =3D 3
+++ exited with 0 +++

Yes, it might be an awkward thing to write in a script, but it's still
valid. If you want recommendations on bad shell scripting practices,
perhaps you might want to try shellcheck instead?


From MAILER-DAEMON Sun Apr 16 21:00:33 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1czv1t-0000n5-HX
	for mharc-bug-bash@gnu.org; Sun, 16 Apr 2017 21:00:33 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52865)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1czv1r-0000mg-LJ
	for bug-bash@gnu.org; Sun, 16 Apr 2017 21:00:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1czv1o-0002Mz-LD
	for bug-bash@gnu.org; Sun, 16 Apr 2017 21:00:31 -0400
Received: from homie.mail.dreamhost.com ([208.97.132.208]:45788
	helo=homiemail-a14.g.dreamhost.com)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <jidanni@jidanni.org>) id 1czv1o-0002M7-CS
	for bug-bash@gnu.org; Sun, 16 Apr 2017 21:00:28 -0400
Received: from homiemail-a14.g.dreamhost.com (localhost [127.0.0.1])
	by homiemail-a14.g.dreamhost.com (Postfix) with ESMTP id 8723A392077;
	Sun, 16 Apr 2017 18:00:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc
	:subject:references:date:message-id:mime-version:content-type;
	s=jidanni.org; bh=Hh67jHEsFkF4//KEcdWDdoZqSp8=; b=Iy/UcJKuDz1gS
	bhrZfbwoL7WGPg7OhoiIV4rYSwyMCr5t7H6N+uclfDojcI3mXlmWYmvhRf/9V1oz
	almdICFYRHiymsp0lvEvwmDl7LmJmhhPOWpkgtM5UgALioU5A0TeumOQxTLfL8FR
	G2/dxddDJbHpkKr6z2Yt32Ftxl+Gs8=
Received: from jidanni.org (122-118-150-84.dynamic.hinet.net [122.118.150.84])
	(using TLSv1 with cipher AES256-SHA (256/256 bits))
	(No client certificate requested)
	(Authenticated sender: jidanni@jidanni.org)
	by homiemail-a14.g.dreamhost.com (Postfix) with ESMTPSA id 51142392075; 
	Sun, 16 Apr 2017 18:00:26 -0700 (PDT)
From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson <jidanni@jidanni.org>
To: Eduardo Bustamante <dualbus@gmail.com>
Cc: "bug-bash\@gnu.org" <bug-bash@gnu.org>
Subject: Re: echo x > a > b > c > d
References: <87mvbfq5rd.fsf@jidanni.org>
Date: Mon, 17 Apr 2017 09:00:23 +0800
Message-ID: <87efwrq254.fsf@jidanni.org>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 208.97.132.208
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 01:00:32 -0000

OK. (But shellcheck doesn't catch it either.)
$ { echo '#!/bin/sh'; echo 'echo x > c > c > c';}|shellcheck /dev/stdin
$ { echo '#!/bin/sh'; echo 'echo x < c < c < c';}|shellcheck /dev/stdin


From MAILER-DAEMON Mon Apr 17 15:52:22 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0ChC-0003Yk-Qp
	for mharc-bug-bash@gnu.org; Mon, 17 Apr 2017 15:52:22 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50264)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <psmith369@gmail.com>) id 1d0B29-00068g-AE
	for bug-bash@gnu.org; Mon, 17 Apr 2017 14:05:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <psmith369@gmail.com>) id 1d0B28-0007zn-Gz
	for bug-bash@gnu.org; Mon, 17 Apr 2017 14:05:53 -0400
Received: from mail-oi0-x22a.google.com ([2607:f8b0:4003:c06::22a]:33150)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <psmith369@gmail.com>) id 1d0B28-0007zS-5q
	for bug-bash@gnu.org; Mon, 17 Apr 2017 14:05:52 -0400
Received: by mail-oi0-x22a.google.com with SMTP id b187so150529488oif.0
	for <bug-bash@gnu.org>; Mon, 17 Apr 2017 11:05:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=tBRFxI+lBC9PmXgOZTaqEjC/CnAU7Ko9t9Ro++RPrk4=;
	b=WvYg19OaQBBY5DyfNWHvyE8iosbpc/CjspQhTJOLsmoDtFwcWDkWOTZX2xgUx+A0hY
	wu4ngJoLsoO3/gEWs9Pjb82kX+YjMxfohphIXTYDVsmqUhEGuO9MlzlICdoLDVfYMkOG
	dYq/yVK/tSwUi61t8Eu9bjbppFVoR5rhwmbP0wu20sRoVGe4xZVpcmlQKV4RrD4GreCe
	1TnOeCTMHYhVnq7HSYr0Yn4pwk0sQinwC0mVRTZEzdt9Kg27/HWGwRK2dCF8WEq3UBKX
	eXtT8uXfoPRxVwUSIoTxw3NVnJ6Rm3t4b9Qj5ezruCWccGFAbHWQqgDtp6+mZ1g11KPJ
	8Hwg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=tBRFxI+lBC9PmXgOZTaqEjC/CnAU7Ko9t9Ro++RPrk4=;
	b=RsTnEc9TAeecXvl5Lx/Za5thW2R79f4pbeov1GNI5hAqThE+YCH5J61G6nMF9MXi5m
	mP9pRfHPCxz7peCcUEbAPE3FzbWIkxfFHRULTsBnC8yapfwGDzvDwX6Nag9hMnCxmFrR
	qXKiIyFSncKjXJNKZ2KMQmV8p0sT8c/hVyzn284bJ8xVtLv6ezuM9S9SsGPcIsijrzAm
	QDBvzkAz4K4sRj0xnH13l4Cs5lNtJ70q/RoCt0Z75v3L5NBS0gMUOBkv3EOcpgcYcEsP
	/88E3MiU8y0QEi58OtJ4HbhKi1Yb+H6aHptEIaKOLEPm5ibLP0pCDWozj5s9+oUy7t85
	5jRQ==
X-Gm-Message-State: AN3rC/56rqBm/j3TWKWZ4G3nK35cwShr7St/u3VJIgJqtarPKhoB1EzP
	pOE2zs0LzGbp8cRgXM4ergwKGXueKbmL
X-Received: by 10.202.6.2 with SMTP id 2mr5134348oig.198.1492452351004; Mon,
	17 Apr 2017 11:05:51 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.202.107.135 with HTTP; Mon, 17 Apr 2017 11:05:50 -0700 (PDT)
From: Pete Smith <psmith369@gmail.com>
Date: Mon, 17 Apr 2017 11:05:50 -0700
Message-ID: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
Subject: Issus with popd and pushd
To: bug-bash@gnu.org
Content-Type: multipart/alternative; boundary=94eb2c18cda439d4a4054d60a45f
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4003:c06::22a
X-Mailman-Approved-At: Mon, 17 Apr 2017 15:52:22 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 18:05:54 -0000

--94eb2c18cda439d4a4054d60a45f
Content-Type: text/plain; charset=UTF-8

The problem with: dirs, pushd, popd is that they output a single line of
paths that's difficult to parse visually quickly, especially when there are
many paths in the dir stack and the path
names are long.

dirs offers a reasonable solution with the -v option

Unfortunately popd and pushd do NOT offer this option.

Using an alias solution:

  popd | sed 's/\s/\n/g' | nl

doesn't work, probably because they are shell built-ins.

I'd recommend the addition of the -v option to popd and pushd, or a fix so
that an alias like the one outline above, works.

Appreciate your comments and feedback on this.

-Pete

--94eb2c18cda439d4a4054d60a45f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">The problem with: dirs, pushd, popd is that they output a =
single line of paths that&#39;s difficult to parse visually quickly, especi=
ally when there are many paths in the dir stack and the path<div>names are =
long.</div><div><br></div><div>dirs offers a reasonable solution with the -=
v option<br><div><br></div></div><div>Unfortunately popd and pushd do NOT o=
ffer this option.</div><div><br></div><div>Using an alias solution:</div><d=
iv><br></div><div>=C2=A0 popd | sed &#39;s/\s/\n/g&#39; | nl<br></div><div>=
<br></div><div>doesn&#39;t work, probably because they are shell built-ins.=
<br></div><div><br></div><div>I&#39;d recommend the addition of the -v opti=
on to popd and pushd, or a fix so that an alias like the one outline above,=
 works.</div><div><br></div><div>Appreciate your comments and feedback on t=
his.</div><div><br></div><div>-Pete</div></div>

--94eb2c18cda439d4a4054d60a45f--


From MAILER-DAEMON Mon Apr 17 16:28:47 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0DGR-0002OU-3l
	for mharc-bug-bash@gnu.org; Mon, 17 Apr 2017 16:28:47 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33031)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <reuti@staff.uni-marburg.de>) id 1d0DGO-0002Nw-EV
	for bug-bash@gnu.org; Mon, 17 Apr 2017 16:28:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <reuti@staff.uni-marburg.de>) id 1d0DGK-0003QJ-HY
	for bug-bash@gnu.org; Mon, 17 Apr 2017 16:28:44 -0400
Received: from vhrz24.hrz.uni-marburg.de ([137.248.1.34]:55336)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <reuti@staff.uni-marburg.de>)
	id 1d0DGK-0003Ot-6n
	for bug-bash@gnu.org; Mon, 17 Apr 2017 16:28:40 -0400
Received: from [10.0.1.5] (pD9E3C4B5.dip0.t-ipconnect.de [217.227.196.181])
	(authenticated bits=0)
	by vhrz24.HRZ.Uni-Marburg.DE (8.14.4/8.14.4/Debian-8+deb8u1) with ESMTP
	id v3HKSPM7051708
	(version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-SHA bits=128 verify=NOT); 
	Mon, 17 Apr 2017 22:28:27 +0200
Subject: Re: Issus with popd and pushd
Mime-Version: 1.0 (Apple Message framework v1085)
Content-Type: text/plain; charset=us-ascii
From: Reuti <reuti@staff.uni-marburg.de>
In-Reply-To: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
Date: Mon, 17 Apr 2017 22:28:24 +0200
Cc: bug-bash@gnu.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <D1BDD975-1F82-4023-A387-500049FBF6D3@staff.uni-marburg.de>
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
To: Pete Smith <psmith369@gmail.com>
X-Pgp-Agent: GPGMail 1.4.1
X-Mailer: Apple Mail (2.1085)
X-Null-Tag: 3ffa439cb7fb3dd4a1a138142c1765d9
X-UniMR-MailScanner-Information: see
	http://www.uni-marburg.de/hrz/internet/mail/spam/
X-UniMR-MailScanner-ID: v3HKSPM7051708
X-UniMR-MailScanner: Found to be clean
X-UniMR-MailScanner-From: reuti@staff.uni-marburg.de
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 137.248.1.34
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 20:28:45 -0000

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Am 17.04.2017 um 20:05 schrieb Pete Smith:

> The problem with: dirs, pushd, popd is that they output a single line =
of paths that's difficult to parse visually quickly, especially when =
there are many paths in the dir stack and the path
> names are long.
>=20
> dirs offers a reasonable solution with the -v option
>=20
> Unfortunately popd and pushd do NOT offer this option.
>=20
> Using an alias solution:
>=20
>   popd | sed 's/\s/\n/g' | nl
>=20
> doesn't work, probably because they are shell built-ins.

It's a question whether it's a feature or a bug: if stdout is redirected =
for it, the directory isn't changed any longer AFAICS.

- -- Reuti


> I'd recommend the addition of the -v option to popd and pushd, or a =
fix so that an alias like the one outline above, works.
>=20
> Appreciate your comments and feedback on this.
>=20
> -Pete

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iEYEARECAAYFAlj1JWgACgkQo/GbGkBRnRofagCfUNXHWBVDDYoKZUS73A5+YGkp
JP8An0NkPu2i5U0rI3tUcbrgXbB8sTKF
=3D8mly
-----END PGP SIGNATURE-----


From MAILER-DAEMON Mon Apr 17 16:33:15 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0DKl-0003RU-KG
	for mharc-bug-bash@gnu.org; Mon, 17 Apr 2017 16:33:15 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34252)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0DKj-0003RN-PP
	for bug-bash@gnu.org; Mon, 17 Apr 2017 16:33:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0DKf-0004sx-Rt
	for bug-bash@gnu.org; Mon, 17 Apr 2017 16:33:13 -0400
Received: from mpv3-2015.cwru.edu ([129.22.103.194]:28484
	helo=mpv3-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d0DKf-0004si-MB
	for bug-bash@gnu.org; Mon, 17 Apr 2017 16:33:09 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv3-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALN30716; Mon, 17 Apr 2017 16:33:08 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDH67215 (AUTH cpr);
	Mon, 17 Apr 2017 16:33:07 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Issus with popd and pushd
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
To: Pete Smith <psmith369@gmail.com>, bug-bash@gnu.org
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <944173e6-453f-39fe-8f09-9496032ea540@case.edu>
Date: Mon, 17 Apr 2017 16:33:07 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv3-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.17.194516:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_400_499, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS,
	__SINGLE_URI_TEXT, SINGLE_URI_IN_BODY, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.194
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 20:33:15 -0000

On 4/17/17 2:05 PM, Pete Smith wrote:

> Using an alias solution:
> 
>   popd | sed 's/\s/\n/g' | nl
> 
> doesn't work, probably because they are shell built-ins.

That will never change the current directory, since the popd is run in
a subshell.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Mon Apr 17 16:58:34 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0DjG-0007RK-9I
	for mharc-bug-bash@gnu.org; Mon, 17 Apr 2017 16:58:34 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40602)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <svashish@redhat.com>) id 1d0DjE-0007R7-83
	for bug-bash@gnu.org; Mon, 17 Apr 2017 16:58:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <svashish@redhat.com>) id 1d0Dj9-0000Nh-AZ
	for bug-bash@gnu.org; Mon, 17 Apr 2017 16:58:32 -0400
Received: from mx1.redhat.com ([209.132.183.28]:53870)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <svashish@redhat.com>) id 1d0Dj9-0000ND-4F
	for bug-bash@gnu.org; Mon, 17 Apr 2017 16:58:27 -0400
Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com
	[10.5.11.16])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 0466FAC2F7
	for <bug-bash@gnu.org>; Mon, 17 Apr 2017 20:58:25 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0466FAC2F7
Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com;
	dmarc=none (p=none dis=none) header.from=redhat.com
Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com;
	spf=pass smtp.mailfrom=svashish@redhat.com
DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0466FAC2F7
Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21])
	by smtp.corp.redhat.com (Postfix) with ESMTPS id EE1895C54E
	for <bug-bash@gnu.org>; Mon, 17 Apr 2017 20:58:24 +0000 (UTC)
Received: from zmail23.collab.prod.int.phx2.redhat.com
	(zmail23.collab.prod.int.phx2.redhat.com [10.5.83.28])
	by colo-mx.corp.redhat.com (Postfix) with ESMTP id C187E5EC60
	for <bug-bash@gnu.org>; Mon, 17 Apr 2017 20:58:24 +0000 (UTC)
Date: Mon, 17 Apr 2017 16:58:24 -0400 (EDT)
From: Siteshwar Vashisht <svashisht@redhat.com>
To: bug-bash@gnu.org
Message-ID: <1345974701.17156143.1492462704467.JavaMail.zimbra@redhat.com>
In-Reply-To: <695812195.17154050.1492461694566.JavaMail.zimbra@redhat.com>
Subject: 'history -n' should re-read history file if history is cleared
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_17156141_1255976665.1492462704463"
X-Originating-IP: [10.40.204.73, 10.4.195.3]
Thread-Topic: 'history -n' should re-read history file if history is cleared
Thread-Index: fZ8fltv0FLN+PGMs5xJtfT1ztn3VHw==
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.38]);
	Mon, 17 Apr 2017 20:58:25 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 209.132.183.28
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 20:58:33 -0000

------=_Part_17156141_1255976665.1492462704463
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Reproducer steps :

> PROMPT_COMMAND="history -a; history -c; history -n"
> history

Actual output :
    2  history

Expected output:
  All the older history items from bash history file should be re-read.

I am providing a test patch that resolves this issue.

-- 
--
Siteshwar Vashisht

------=_Part_17156141_1255976665.1492462704463
Content-Type: text/x-patch; name=bash-clear-history.patch
Content-Disposition: attachment; filename=bash-clear-history.patch
Content-Transfer-Encoding: base64

ZGlmZiAtLWdpdCBhL2Jhc2hoaXN0LmMgYi9iYXNoaGlzdC5jCmluZGV4IDk5NzlmOTkuLjVjY2Y5
ZGIgMTAwNjQ0Ci0tLSBhL2Jhc2hoaXN0LmMKKysrIGIvYmFzaGhpc3QuYwpAQCAtMzMyLDcgKzMz
Miw3IEBAIGJhc2hfY2xlYXJfaGlzdG9yeSAoKQogewogICBjbGVhcl9oaXN0b3J5ICgpOwogICBo
aXN0b3J5X2xpbmVzX3RoaXNfc2Vzc2lvbiA9IDA7Ci0gIC8qIFhYWCAtIHJlc2V0IGhpc3Rvcnlf
bGluZXNfcmVhZF9mcm9tX2ZpbGU/ICovCisgIGhpc3RvcnlfbGluZXNfaW5fZmlsZSA9IGhpc3Rv
cnlfbGluZXNfcmVhZF9mcm9tX2ZpbGUgPSAwOwogfQogCiAvKiBEZWxldGUgYW5kIGZyZWUgdGhl
IGhpc3RvcnkgbGlzdCBlbnRyeSBhdCBvZmZzZXQgSS4gKi8K
------=_Part_17156141_1255976665.1492462704463--


From MAILER-DAEMON Mon Apr 17 17:57:31 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0EeJ-0008Rm-03
	for mharc-bug-bash@gnu.org; Mon, 17 Apr 2017 17:57:31 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53673)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <psmith369@gmail.com>) id 1d0EeG-0008Rb-8I
	for bug-bash@gnu.org; Mon, 17 Apr 2017 17:57:29 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <psmith369@gmail.com>) id 1d0EeF-0004iL-9P
	for bug-bash@gnu.org; Mon, 17 Apr 2017 17:57:28 -0400
Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:33142)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <psmith369@gmail.com>) id 1d0EeF-0004hz-4G
	for bug-bash@gnu.org; Mon, 17 Apr 2017 17:57:27 -0400
Received: by mail-oi0-x236.google.com with SMTP id b187so157064098oif.0
	for <bug-bash@gnu.org>; Mon, 17 Apr 2017 14:57:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=5/h6g6yLp9jM2Ri9GBTS4wwNbM8T4s3XZvCWsqW5Ypk=;
	b=dwY5V/CpWiZ+tYYhhRWedDMdkyqFe2OyQb2L81AadYkqXsrEoyUX8P1YL66uPcIprd
	PTUiwFa5mZxYiJK4gkTA7zQn+sC+oHavkJWpAC+qw7esTpabuN486baNPMAkOx8WVkQC
	NoyRXhg6q6FkOfyEBTJ5LgpSBRpN2R1wZ7qysWKQeVOHGCOHotVrEEOBxpjuKqjsjEHb
	ysJE6uHTsIMtdERwgB9qUTm18urrlsOEhGjvG5UL7OvNXjVU00hWs8Il5GmugQpSW/p6
	d6D1hIZxV4kdojVZ+GNZwLj8f2LTHNUlRBGy3y51VISsFh8NUo/BUKMaIqXtgAePSVCT
	o51Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=5/h6g6yLp9jM2Ri9GBTS4wwNbM8T4s3XZvCWsqW5Ypk=;
	b=pCw+aIY34Lef5xbwKMqWe9XwAgSRdd0VxBbTKV09bbam8itCmkhAG6cE0lgQ/Gs6r9
	kzz92rQFFCh6ub9lE1uhTuoMF0qzf+h5GCIji5wV/DOf0Xpr/M2knHqvXQc3j8ZO4QBP
	c7fyzURnWnf3fvB05X0zjBgD22rCgz45th2kmZ1ninkLMR5NFK8LktqIXroocaW15rAC
	fw4jinJ+3yuNjq3+kOQq4CKTpbBLsbM9dbGRHRX7Ya5xgFQfXd2tiXC0pVggfRxptKaZ
	SSU6s5mbXLfUuxYxQqcJQ+LzmIvF1RzRn0kbYrS6cgZsfUfrrRlG5usz0WaEfFPOOaT5
	JtHg==
X-Gm-Message-State: AN3rC/5SVqa6WOpVy9HJLgtq6ezl/edCgznLf0zf4wKEN/9E0cEYsHcx
	TTwKQpdI7oB5axHrIHrAvt85VSGZGg==
X-Received: by 10.202.78.130 with SMTP id c124mr5314220oib.20.1492466246251;
	Mon, 17 Apr 2017 14:57:26 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.202.107.135 with HTTP; Mon, 17 Apr 2017 14:57:25 -0700 (PDT)
In-Reply-To: <944173e6-453f-39fe-8f09-9496032ea540@case.edu>
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>
From: Pete Smith <psmith369@gmail.com>
Date: Mon, 17 Apr 2017 14:57:25 -0700
Message-ID: <CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
Subject: Re: Issus with popd and pushd
To: chet.ramey@case.edu
Cc: bug-bash@gnu.org
Content-Type: multipart/alternative; boundary=001a1134e182727c59054d63e00c
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4003:c06::236
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 17 Apr 2017 21:57:29 -0000

--001a1134e182727c59054d63e00c
Content-Type: text/plain; charset=UTF-8

Ahh that makes sense:

   "That will never change the current directory, since the popd is run in
a subshell."

So what's the possibility of adding -v option to popd and pushd???

-Pete

On Mon, Apr 17, 2017 at 1:33 PM, Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/17/17 2:05 PM, Pete Smith wrote:
>
> > Using an alias solution:
> >
> >   popd | sed 's/\s/\n/g' | nl
> >
> > doesn't work, probably because they are shell built-ins.
>
> That will never change the current directory, since the popd is run in
> a subshell.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~
> chet/
>

--001a1134e182727c59054d63e00c
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Ahh that makes sense:<div><br><div>=C2=A0 =C2=A0&quot;That=
 will never change the current directory, since the popd is run in a subshe=
ll.&quot;</div></div><div><br></div><div>So what&#39;s the possibility of a=
dding -v option to popd and pushd???</div><div><br></div><div>-Pete</div></=
div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Mon, Apr 1=
7, 2017 at 1:33 PM, Chet Ramey <span dir=3D"ltr">&lt;<a href=3D"mailto:chet=
.ramey@case.edu" target=3D"_blank">chet.ramey@case.edu</a>&gt;</span> wrote=
:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><span class=3D"">On 4/17/17 2:05 PM, Pe=
te Smith wrote:<br>
<br>
&gt; Using an alias solution:<br>
&gt;<br>
&gt;=C2=A0 =C2=A0popd | sed &#39;s/\s/\n/g&#39; | nl<br>
&gt;<br>
&gt; doesn&#39;t work, probably because they are shell built-ins.<br>
<br>
</span>That will never change the current directory, since the popd is run =
in<br>
a subshell.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
``The lyf so short, the craft so long to lerne.&#39;&#39; - Chaucer<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0``Ars longa, =
vita brevis&#39;&#39; - Hippocrates<br>
Chet Ramey, UTech, CWRU=C2=A0 =C2=A0 <a href=3D"mailto:chet@case.edu">chet@=
case.edu</a>=C2=A0 =C2=A0 <a href=3D"http://cnswww.cns.cwru.edu/~chet/" rel=
=3D"noreferrer" target=3D"_blank">http://cnswww.cns.cwru.edu/~<wbr>chet/</a=
><br>
</font></span></blockquote></div><br></div>

--001a1134e182727c59054d63e00c--


From MAILER-DAEMON Tue Apr 18 09:35:57 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0TIT-0004cO-4c
	for mharc-bug-bash@gnu.org; Tue, 18 Apr 2017 09:35:57 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46302)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d0TIQ-0004cG-Bn
	for bug-bash@gnu.org; Tue, 18 Apr 2017 09:35:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d0TIP-0006XT-Gi
	for bug-bash@gnu.org; Tue, 18 Apr 2017 09:35:54 -0400
Received: from mail-io0-x236.google.com ([2607:f8b0:4001:c06::236]:33628)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d0TIP-0006XD-CD
	for bug-bash@gnu.org; Tue, 18 Apr 2017 09:35:53 -0400
Received: by mail-io0-x236.google.com with SMTP id k87so166622144ioi.0
	for <bug-bash@gnu.org>; Tue, 18 Apr 2017 06:35:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=WOpu7O6vwx5fFyiBY08RSQCeCgRWoyB37v9xUbwRm1A=;
	b=VoNyabQlH2q3HXDUZbAvJrpwfiJqeM1kVWsJANPawx1cD7ChZaYI2sYAF4v6TXilso
	YGCza/fuY6ak4IwL724qXDRZWXagHjjRxLYcBPFFy6vLvZuGUEdfJAcBKxy6dSi1QeoW
	Tgiv5MYfJ8hbc2PA4x4jv9uGOHlsaJlp8gXUkkWXBWPNX6BQGTh3ILQBUFNA2YYHVqnE
	yAlZUqDq+H71SlYjFBKqXAsIyA73GkV+jDpvJ9QcnjKwafALhb1P0pVfvWwdUsV2LlAG
	MJ/90uLpHBzJktipiRy3XJJAm1hSaRO+/tBDy3Xli+Cv1kp68Drt765Z57IOA8BnmlCh
	aWew==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=WOpu7O6vwx5fFyiBY08RSQCeCgRWoyB37v9xUbwRm1A=;
	b=a73g0XUPdYMEXqxjfIb3yd5fwTVr2QtRGq6Y/hD2x3bY+72llvA/y/oesQM6fF5JRp
	B6tuY06Xdq4bOHEyUwn00FNYmwX8HamGK85n4Xu6JBVBbKu2YorESffre28rfhgQbGaa
	TCZlrqBWGKcJo6Ayfz46Qf2D4B89NfKqWoB7SiyiDLWypBeXCjNL7o2bPhTnTUw99bNy
	d3ZJ6RzwjIqdqvtoLCgPg2y46bWpmPBP9PEcFFJVtOjTc1buEkJoSVEi9zUjvwl+MkIA
	FyFh4P/oY4CSJ29LZYyFVEh3zFFft3NagdQ0Bj4hUTZ1XzAIlK18tlCIw+ZenKiDG+4H
	j4HA==
X-Gm-Message-State: AN3rC/5k6nr5tm9zUceZYKLtJlgQ6sshvNrIX8MfHmOhuKzHnpcXXcgs
	Xwu6KxXVoIrIOEssjs8xq2op7tNIhA==
X-Received: by 10.107.7.18 with SMTP id 18mr13415100ioh.218.1492522551472;
	Tue, 18 Apr 2017 06:35:51 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.36.135 with HTTP; Tue, 18 Apr 2017 06:35:31 -0700 (PDT)
In-Reply-To: <CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>
	<CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Tue, 18 Apr 2017 08:35:31 -0500
Message-ID: <CAOSMAutUQ2o+VjD-F8UfRGXzytjjmuz0ka7XA_T9DFQ59xm_Xw@mail.gmail.com>
Subject: Re: Issus with popd and pushd
To: Pete Smith <psmith369@gmail.com>
Cc: Chet Ramey <chet.ramey@case.edu>, "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::236
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 18 Apr 2017 13:35:55 -0000

On Mon, Apr 17, 2017 at 4:57 PM, Pete Smith <psmith369@gmail.com> wrote:
[...]
> So what's the possibility of adding -v option to popd and pushd???

Feel free to send patches. Under the hood, the pushd/popd builtins
call the dirs builtin with no arguments after their execution, so it's
just a matter of adding to pushd/popd the ability to interpret the -v
flag, and then pass this flag back to the dirs_builtin execution. In
the below patch I just pass the flag unconditionally, but it should
give you an idea of what you need to do.

# patched
bash-4.4$ pwd
/home/dualbus/foo/bar/baz
bash-4.4$ pushd aaaaaaaaa/
 0  ~/foo/bar/baz/aaaaaaaaa
 1  ~/foo/bar/baz
bash-4.4$ pushd bbbbbbbbbb/
 0  ~/foo/bar/baz/aaaaaaaaa/bbbbbbbbbb
 1  ~/foo/bar/baz/aaaaaaaaa
 2  ~/foo/bar/baz
bash-4.4$ popd
 0  ~/foo/bar/baz/aaaaaaaaa
 1  ~/foo/bar/baz

Or now that I think about it, you can get away with these functions:

# masked builtins
dualbus@debian:~/foo/bar/baz$ pushd() { builtin pushd "$@" >/dev/null;
dirs -v; }; popd(){ builtin popd "$@" >/dev/null; dirs -v; }
dualbus@debian:~/foo/bar/baz$ pushd aaaaaaaaa/
 0  ~/foo/bar/baz/aaaaaaaaa
 1  ~/foo/bar/baz
dualbus@debian:~/foo/bar/baz/aaaaaaaaa$ pushd bbbbbbbbbb/
 0  ~/foo/bar/baz/aaaaaaaaa/bbbbbbbbbb
 1  ~/foo/bar/baz/aaaaaaaaa
 2  ~/foo/bar/baz


# patch
dualbus@debian:~/src/gnu/bash$ PAGER= git diff -- builtins
diff --git a/builtins/pushd.def b/builtins/pushd.def
index 6579e4c8..bd41fcca 100644
--- a/builtins/pushd.def
+++ b/builtins/pushd.def
@@ -178,6 +178,8 @@ pushd_builtin (list)
   int j, flags, skipopt;
   intmax_t num;
   char direction;
+  WORD_DESC *wd;
+  WORD_LIST *wl;

   orig_list = list;

@@ -300,7 +302,11 @@ pushd_builtin (list)
   if (j == EXECUTION_SUCCESS)
     {
       add_dirstack_element ((flags & NOCD) ? savestring
(list->word->word) : current_directory);
-      dirs_builtin ((WORD_LIST *)NULL);
+
+      wd = make_word ("-v");
+      wl = make_word_list (wd, NULL);
+
+      dirs_builtin (wl);
       if (flags & NOCD)
        free (current_directory);
       return (EXECUTION_SUCCESS);
@@ -324,6 +330,8 @@ popd_builtin (list)
   int flags;
   char direction;
   char *which_word;
+  WORD_DESC *wd;
+  WORD_LIST *wl;

   CHECK_HELPOPT (list);

@@ -400,7 +408,10 @@ popd_builtin (list)
        pushd_directory_list[i] = pushd_directory_list[i + 1];
     }

-  dirs_builtin ((WORD_LIST *)NULL);
+  wd = make_word ("-v");
+  wl = make_word_list (wd, NULL);
+
+  dirs_builtin (wl);
   return (EXECUTION_SUCCESS);
 }


From MAILER-DAEMON Tue Apr 18 10:16:19 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0TvX-0004Sn-Kv
	for mharc-bug-bash@gnu.org; Tue, 18 Apr 2017 10:16:19 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58494)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0TvU-0004RR-I1
	for bug-bash@gnu.org; Tue, 18 Apr 2017 10:16:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0TvR-0007fa-Sr
	for bug-bash@gnu.org; Tue, 18 Apr 2017 10:16:16 -0400
Received: from mpv3-2015.cwru.edu ([129.22.103.194]:62540
	helo=mpv3-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d0TvR-0007fN-Nh
	for bug-bash@gnu.org; Tue, 18 Apr 2017 10:16:13 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv3-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALN57120; Tue, 18 Apr 2017 10:16:11 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDI66279 (AUTH cpr);
	Tue, 18 Apr 2017 10:16:11 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Issus with popd and pushd
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>
	<CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
	<CAOSMAutUQ2o+VjD-F8UfRGXzytjjmuz0ka7XA_T9DFQ59xm_Xw@mail.gmail.com>
To: Eduardo Bustamante <dualbus@gmail.com>, Pete Smith <psmith369@gmail.com>
Cc: chet.ramey@case.edu, "bug-bash@gnu.org" <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <f2ba0481-b15c-a7e1-7d94-ca5d1d8a4444@case.edu>
Date: Tue, 18 Apr 2017 10:16:10 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOSMAutUQ2o+VjD-F8UfRGXzytjjmuz0ka7XA_T9DFQ59xm_Xw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv3-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.18.134215:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID,
	DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT,
	__MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR,
	__SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG,
	__FORWARDED_MSG, __NO_HTML_TAG_RAW, BODY_SIZE_600_699,
	BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1,
	__MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10,
	__FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS, IN_REP_TO,
	MSG_THREAD, __FROM_DOMAIN_IN_RCPT, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.194
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 18 Apr 2017 14:16:17 -0000

On 4/18/17 9:35 AM, Eduardo Bustamante wrote:

> Or now that I think about it, you can get away with these functions:
> 
> # masked builtins
> dualbus@debian:~/foo/bar/baz$ pushd() { builtin pushd "$@" >/dev/null;
> dirs -v; }; popd(){ builtin popd "$@" >/dev/null; dirs -v; }

This would be the preferable alternative, since it's so trivial.  The one
change I would suggest would be to make the `;' a `&&':

pushd()
{
	builtin pushd "$@" >/dev/null && dirs -v
}

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Tue Apr 18 10:46:28 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0UOi-0002K1-RT
	for mharc-bug-bash@gnu.org; Tue, 18 Apr 2017 10:46:28 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43187)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0UOg-0002Ji-9m
	for bug-bash@gnu.org; Tue, 18 Apr 2017 10:46:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0UOc-0005DH-Uw
	for bug-bash@gnu.org; Tue, 18 Apr 2017 10:46:26 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:7185
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d0UOc-0005CP-Pc
	for bug-bash@gnu.org; Tue, 18 Apr 2017 10:46:22 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMN39951; Tue, 18 Apr 2017 10:46:21 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDI75092 (AUTH cpr);
	Tue, 18 Apr 2017 10:46:20 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Issus with popd and pushd
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>
	<CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
To: Pete Smith <psmith369@gmail.com>
Cc: chet.ramey@case.edu, bug-bash@gnu.org
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <b94805b4-93f1-6825-c992-f5e97f5a9d79@case.edu>
Date: Tue, 18 Apr 2017 10:46:20 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.18.140617:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY,
	__URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW,
	BODY_SIZE_600_699, BODYTEXTP_SIZE_3000_LESS,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 18 Apr 2017 14:46:27 -0000

On 4/17/17 5:57 PM, Pete Smith wrote:
> Ahh that makes sense:
> 
>    "That will never change the current directory, since the popd is run in
> a subshell."
> 
> So what's the possibility of adding -v option to popd and pushd???

I'd advise doing it with a shell function first; that's much easier to
play around with.  Start with something similar to what Eduardo or I
sent and add whatever option parsing you want.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Tue Apr 18 11:36:16 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0VAu-0004sz-Ko
	for mharc-bug-bash@gnu.org; Tue, 18 Apr 2017 11:36:16 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60290)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0VAs-0004ss-Mm
	for bug-bash@gnu.org; Tue, 18 Apr 2017 11:36:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0VAp-0004po-6b
	for bug-bash@gnu.org; Tue, 18 Apr 2017 11:36:14 -0400
Received: from mpv3-2015.cwru.edu ([129.22.103.194]:15776
	helo=mpv3-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d0VAp-0004ou-0R
	for bug-bash@gnu.org; Tue, 18 Apr 2017 11:36:11 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv3-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALN63348; Tue, 18 Apr 2017 11:36:06 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDI88878 (AUTH cpr);
	Tue, 18 Apr 2017 11:36:05 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: 'history -n' should re-read history file if history is cleared
References: <1345974701.17156143.1492462704467.JavaMail.zimbra@redhat.com>
To: Siteshwar Vashisht <svashisht@redhat.com>, bug-bash@gnu.org
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <ad29b1ce-0e55-be70-1cb4-c746e3aa55a6@case.edu>
Date: Tue, 18 Apr 2017 11:36:05 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <1345974701.17156143.1492462704467.JavaMail.zimbra@redhat.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv3-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.18.144516:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_500_599, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS,
	__SINGLE_URI_TEXT, SINGLE_URI_IN_BODY, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.194
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 18 Apr 2017 15:36:15 -0000

On 4/17/17 4:58 PM, Siteshwar Vashisht wrote:
> Reproducer steps :
> 
>> PROMPT_COMMAND="history -a; history -c; history -n"
>> history
> 
> Actual output :
>     2  history
> 
> Expected output:
>   All the older history items from bash history file should be re-read.

Why should explicitly clearing old items from the history cause them to
be treated as new?

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Tue Apr 18 13:00:41 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0WUb-0003PZ-RY
	for mharc-bug-bash@gnu.org; Tue, 18 Apr 2017 13:00:41 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34268)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d0WUZ-0003PE-Gi
	for bug-bash@gnu.org; Tue, 18 Apr 2017 13:00:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d0WUU-0001ap-Gx
	for bug-bash@gnu.org; Tue, 18 Apr 2017 13:00:39 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:57202
	helo=Ishtar.sc.tlinx.org)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <bash@tlinx.org>) id 1d0WUU-0001WN-7q
	for bug-bash@gnu.org; Tue, 18 Apr 2017 13:00:34 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
	v3IH0QWF067010; Tue, 18 Apr 2017 10:00:28 -0700
Message-ID: <58F6462A.4080106@tlinx.org>
Date: Tue, 18 Apr 2017 10:00:26 -0700
From: L A Walsh <bash@tlinx.org>
User-Agent: Thunderbird
MIME-Version: 1.0
To: Pete Smith <psmith369@gmail.com>
CC: bug-bash@gnu.org
Subject: Re: Issus with popd and pushd
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
In-Reply-To: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 18 Apr 2017 17:00:40 -0000

Pete Smith wrote:
> The problem with: dirs, pushd, popd
> ...
> Using an alias solution:
>   popd | sed 's/\s/\n/g' | nl
----
   
Um... don't you mean to use the alias command somewhere, like:

   alias popd='builtin popd|tr " " "\n"'

Then it seems to work.
Is that what you mean by using an alias?



From MAILER-DAEMON Tue Apr 18 13:04:09 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0WXx-0004jv-0t
	for mharc-bug-bash@gnu.org; Tue, 18 Apr 2017 13:04:09 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35322)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d0WXu-0004jj-Oe
	for bug-bash@gnu.org; Tue, 18 Apr 2017 13:04:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d0WXp-00038P-ME
	for bug-bash@gnu.org; Tue, 18 Apr 2017 13:04:06 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:57258
	helo=Ishtar.sc.tlinx.org)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <bash@tlinx.org>) id 1d0WXp-000380-DV
	for bug-bash@gnu.org; Tue, 18 Apr 2017 13:04:01 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
	v3IH3vni067592; Tue, 18 Apr 2017 10:03:59 -0700
Message-ID: <58F646FD.50506@tlinx.org>
Date: Tue, 18 Apr 2017 10:03:57 -0700
From: L A Walsh <bash@tlinx.org>
User-Agent: Thunderbird
MIME-Version: 1.0
To: Pete Smith <psmith369@gmail.com>
CC: bug-bash@gnu.org
Subject: Re: Issus with popd and pushd
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<58F6462A.4080106@tlinx.org>
In-Reply-To: <58F6462A.4080106@tlinx.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 18 Apr 2017 17:04:07 -0000

L A Walsh wrote:
> Pete Smith wrote:
>> The problem with: dirs, pushd, popd
>> ...
>> Using an alias solution:
>>   popd | sed 's/\s/\n/g' | nl
> ----
>   Um... don't you mean to use the alias command somewhere, like:
>
>   alias popd='builtin popd|tr " " "\n"'
>
> Then it seems to work.
> Is that what you mean by using an alias?
scratch that... just focused on output, not on function.
*sigh*...need coffee!

>
>


From MAILER-DAEMON Tue Apr 18 14:13:28 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0Xd2-0007iW-Kf
	for mharc-bug-bash@gnu.org; Tue, 18 Apr 2017 14:13:28 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58785)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d0Xd1-0007iM-3E
	for bug-bash@gnu.org; Tue, 18 Apr 2017 14:13:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d0Xcx-0000Iv-4j
	for bug-bash@gnu.org; Tue, 18 Apr 2017 14:13:27 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:58294
	helo=Ishtar.sc.tlinx.org)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <bash@tlinx.org>) id 1d0Xcw-0000II-RE
	for bug-bash@gnu.org; Tue, 18 Apr 2017 14:13:23 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
	v3IIDCZG074402; Tue, 18 Apr 2017 11:13:14 -0700
Message-ID: <58F65738.90502@tlinx.org>
Date: Tue, 18 Apr 2017 11:13:12 -0700
From: L A Walsh <bash@tlinx.org>
User-Agent: Thunderbird
MIME-Version: 1.0
To: chet.ramey@case.edu
CC: Eduardo Bustamante <dualbus@gmail.com>, Pete Smith <psmith369@gmail.com>, 
	"bug-bash@gnu.org" <bug-bash@gnu.org>
Subject: Re: Issus with popd and pushd
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>	<CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>	<CAOSMAutUQ2o+VjD-F8UfRGXzytjjmuz0ka7XA_T9DFQ59xm_Xw@mail.gmail.com>
	<f2ba0481-b15c-a7e1-7d94-ca5d1d8a4444@case.edu>
In-Reply-To: <f2ba0481-b15c-a7e1-7d94-ca5d1d8a4444@case.edu>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 18 Apr 2017 18:13:28 -0000

Chet Ramey wrote:
> On 4/18/17 9:35 AM, Eduardo Bustamante wrote:
>
>   
>> Or now that I think about it, you can get away with these functions:
>>
>> # masked builtins
>> dualbus@debian:~/foo/bar/baz$ pushd() { builtin pushd "$@" >/dev/null;
>> dirs -v; }; popd(){ builtin popd "$@" >/dev/null; dirs -v; }
>>     
>
> This would be the preferable alternative, since it's so trivial.  The one
> change I would suggest would be to make the `;' a `&&':
>
> pushd()
> {
> 	builtin pushd "$@" >/dev/null && dirs -v
> }
>
>   
Maybe add 'builtin' before "dirs" since we're redefining builtins
(i.e. get into habit?)

(Ms. "Shoot-1st, then aim")





From MAILER-DAEMON Tue Apr 18 14:17:30 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0Xgw-0000SV-Dd
	for mharc-bug-bash@gnu.org; Tue, 18 Apr 2017 14:17:30 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59513)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0Xgu-0000Qv-DA
	for bug-bash@gnu.org; Tue, 18 Apr 2017 14:17:29 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0Xgq-0001VU-8k
	for bug-bash@gnu.org; Tue, 18 Apr 2017 14:17:28 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:33672
	helo=mpv4-2015.case.edu) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0Xgq-0001UO-3a
	for bug-bash@gnu.org; Tue, 18 Apr 2017 14:17:24 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALI75661; Tue, 18 Apr 2017 14:17:19 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCY34637 (AUTH cpr);
	Tue, 18 Apr 2017 14:17:19 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Issus with popd and pushd
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>
	<CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
	<CAOSMAutUQ2o+VjD-F8UfRGXzytjjmuz0ka7XA_T9DFQ59xm_Xw@mail.gmail.com>
	<f2ba0481-b15c-a7e1-7d94-ca5d1d8a4444@case.edu>
	<58F65738.90502@tlinx.org>
To: L A Walsh <bash@tlinx.org>
Cc: chet.ramey@case.edu, "bug-bash@gnu.org" <bug-bash@gnu.org>,
	Eduardo Bustamante <dualbus@gmail.com>, Pete Smith <psmith369@gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <7e2c8764-f6a8-0fa9-e886-ab3aaffc51a5@case.edu>
Date: Tue, 18 Apr 2017 14:17:19 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <58F65738.90502@tlinx.org>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.18.172719:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_1000_1099, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY,
	BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 18 Apr 2017 18:17:29 -0000

On 4/18/17 2:13 PM, L A Walsh wrote:
> Chet Ramey wrote:
>> On 4/18/17 9:35 AM, Eduardo Bustamante wrote:
>>
>>  
>>> Or now that I think about it, you can get away with these functions:
>>>
>>> # masked builtins
>>> dualbus@debian:~/foo/bar/baz$ pushd() { builtin pushd "$@" >/dev/null;
>>> dirs -v; }; popd(){ builtin popd "$@" >/dev/null; dirs -v; }
>>>     
>>
>> This would be the preferable alternative, since it's so trivial.  The one
>> change I would suggest would be to make the `;' a `&&':
>>
>> pushd()
>> {
>>     builtin pushd "$@" >/dev/null && dirs -v
>> }
>>
>>   
> Maybe add 'builtin' before "dirs" since we're redefining builtins
> (i.e. get into habit?)

Sure, if there's a chance there's a function named `dirs' and you *don't*
want to use it, this is good practice.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Wed Apr 19 05:30:29 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0lwT-00082r-Fe
	for mharc-bug-bash@gnu.org; Wed, 19 Apr 2017 05:30:29 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47567)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d0lwM-00082I-R6
	for bug-bash@gnu.org; Wed, 19 Apr 2017 05:30:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d0lwM-0007MQ-06
	for bug-bash@gnu.org; Wed, 19 Apr 2017 05:30:22 -0400
Received: from mail-qk0-x230.google.com ([2607:f8b0:400d:c09::230]:32814)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <pierre.gaston@gmail.com>)
	id 1d0lwL-0007MD-Rd
	for bug-bash@gnu.org; Wed, 19 Apr 2017 05:30:21 -0400
Received: by mail-qk0-x230.google.com with SMTP id h67so15082900qke.0
	for <bug-bash@gnu.org>; Wed, 19 Apr 2017 02:30:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=0M+WUQh8OcR3hJvcEGWclCod/bxEIK2/Z6SnaYla2s0=;
	b=lfhMLNl6t0d3IJo2Hx2TU3Ivs52hI+3jFi1cDSj7HObkFwoTu02+BIzp/6akQkqjKc
	HeoV6xm91WlZcftmxVVVPXFWnitKzarKmbtH2hQjHbUFl8joM0xmEdSMbO+yr2jnqw9R
	Mx9dpuNVqfkmXsAGIxBaVmesBkYW9oXcMTm0UygdW7SGaCPV0L0T4gihhw6EJvF8a80b
	f/Y4h+OZEWqjB9Ckz1CzPkHWfFKe/N0fqpeQj/CeRbkZ2OOlWLmQWWFXxcYgEy2ANZCX
	+FigHjvPTedsow/DYLIp2ggtbQt9SOOj5Pc0P8QT52glWHFM9zQFIa5LyAh+jySCPvOR
	2Vsg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=0M+WUQh8OcR3hJvcEGWclCod/bxEIK2/Z6SnaYla2s0=;
	b=ORZ+AGwQi1mES/jP3AokZAr6DaTWNrZqiTzNinb0nJ2rMqQRuu69Sj5poZOpx7HeJT
	qQE6VLXpnWXfLjOg8i7BGMp9q+/5bC10C+TxqSojFPIwh7Agbh3gX4iT9tbrGibxr2YH
	pPIB0ur4sF2A7OzEROdzyMhoku+j3falwkJuKbfk5vWRYFoyT6Yc70BWP8n2ot2w4gGI
	LwPmU3/DBUYqb8FHhkdZ0cn1Q6LIp32CfjwN5lS4gtriavM/rhdmnu+IyJavBwQ+UEP0
	pOO2FKT26oBRR9r3MNDluN0KqHdU4tmlNCHWq05wUtedN2pJmtqGSqv+wjUt32TahWLd
	17PQ==
X-Gm-Message-State: AN3rC/4aHorILcc1q7vMJYtkYqEGdvnyJAoL4KYqDCpOEOHyXEKbYArq
	Y8HKAJbkpt/if6+8sNKqti2CjF6FyHUN/so=
X-Received: by 10.55.55.67 with SMTP id e64mr1452947qka.262.1492594220975;
	Wed, 19 Apr 2017 02:30:20 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.12.180.13 with HTTP; Wed, 19 Apr 2017 02:30:00 -0700 (PDT)
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Wed, 19 Apr 2017 12:30:00 +0300
Message-ID: <CAPSX3sTVnQSHp7z75CS8d5k9PV+PxHYevCKDVgGQZ9TUj0XWig@mail.gmail.com>
Subject: builtins.h missing include guard
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a1147943455d90b054d81acac
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::230
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 19 Apr 2017 09:30:27 -0000

--001a1147943455d90b054d81acac
Content-Type: text/plain; charset=UTF-8

I'm toying with loadable builtins and I noticed that builtins.h does not
have include guard.

Basically I needed the definition of WORLD_LIST and I was using (not sure
if there is a better way):

#include <config.h>
#include <builtins.h>
#include <shell.h>


That's all
Pierre

--001a1147943455d90b054d81acac
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div>I&#39;m toying with loadable builtins and I noti=
ced that builtins.h does not have include guard.<br><br></div><div>Basicall=
y I needed the definition of WORLD_LIST and I was using (not sure if there =
is a better way):<br><br>#include &lt;config.h&gt;<br>#include &lt;builtins=
.h&gt;<br>#include &lt;shell.h&gt;<br><br></div><div><br></div>That&#39;s a=
ll<br></div>Pierre<br></div>

--001a1147943455d90b054d81acac--


From MAILER-DAEMON Wed Apr 19 09:14:37 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d0pRN-0001z6-BL
	for mharc-bug-bash@gnu.org; Wed, 19 Apr 2017 09:14:37 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33478)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0pRK-0001wC-A2
	for bug-bash@gnu.org; Wed, 19 Apr 2017 09:14:35 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d0pRH-00028T-1S
	for bug-bash@gnu.org; Wed, 19 Apr 2017 09:14:34 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:26547
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d0pRG-00028E-S0
	for bug-bash@gnu.org; Wed, 19 Apr 2017 09:14:30 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMN80728; Wed, 19 Apr 2017 09:14:27 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BCZ44089 (AUTH cpr);
	Wed, 19 Apr 2017 09:14:26 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: builtins.h missing include guard
References: <CAPSX3sTVnQSHp7z75CS8d5k9PV+PxHYevCKDVgGQZ9TUj0XWig@mail.gmail.com>
To: Pierre Gaston <pierre.gaston@gmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <e31d935f-8924-9140-299e-6cd374367e46@case.edu>
Date: Wed, 19 Apr 2017 09:14:26 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAPSX3sTVnQSHp7z75CS8d5k9PV+PxHYevCKDVgGQZ9TUj0XWig@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.19.120316:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_800_899, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS,
	__SINGLE_URI_TEXT, SINGLE_URI_IN_BODY, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 19 Apr 2017 13:14:35 -0000

On 4/19/17 5:30 AM, Pierre Gaston wrote:
> I'm toying with loadable builtins and I noticed that builtins.h does not
> have include guard.

That's true, and I can add one.  But it's not included by any other
headers, so it's up to you to include it once.

> 
> Basically I needed the definition of WORLD_LIST and I was using (not sure
> if there is a better way):
> 
> #include <config.h>
> #include <builtins.h>
> #include <shell.h>

You can do it the way the example "loadables.h" does:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
#include "common.h"


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 20 09:38:20 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d1CHs-0007uN-8P
	for mharc-bug-bash@gnu.org; Thu, 20 Apr 2017 09:38:20 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38339)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <svashish@redhat.com>) id 1d1CHq-0007rk-Cm
	for bug-bash@gnu.org; Thu, 20 Apr 2017 09:38:19 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <svashish@redhat.com>) id 1d1CHn-0006F5-8M
	for bug-bash@gnu.org; Thu, 20 Apr 2017 09:38:18 -0400
Received: from mx1.redhat.com ([209.132.183.28]:47916)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <svashish@redhat.com>) id 1d1CHn-0006Ea-1p
	for bug-bash@gnu.org; Thu, 20 Apr 2017 09:38:15 -0400
Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com
	[10.5.11.15])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id DEEF9C04B94A;
	Thu, 20 Apr 2017 13:38:12 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DEEF9C04B94A
Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com;
	dmarc=none (p=none dis=none) header.from=redhat.com
Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com;
	spf=pass smtp.mailfrom=svashish@redhat.com
DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DEEF9C04B94A
Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21])
	by smtp.corp.redhat.com (Postfix) with ESMTPS id B98CA173A9;
	Thu, 20 Apr 2017 13:38:12 +0000 (UTC)
Received: from zmail23.collab.prod.int.phx2.redhat.com
	(zmail23.collab.prod.int.phx2.redhat.com [10.5.83.28])
	by colo-mx.corp.redhat.com (Postfix) with ESMTP id 975654BB74;
	Thu, 20 Apr 2017 13:38:12 +0000 (UTC)
Date: Thu, 20 Apr 2017 09:38:12 -0400 (EDT)
From: Siteshwar Vashisht <svashisht@redhat.com>
To: chet ramey <chet.ramey@case.edu>
Cc: bug-bash@gnu.org
Message-ID: <1300606638.18038914.1492695492448.JavaMail.zimbra@redhat.com>
In-Reply-To: <ad29b1ce-0e55-be70-1cb4-c746e3aa55a6@case.edu>
References: <1345974701.17156143.1492462704467.JavaMail.zimbra@redhat.com>
	<ad29b1ce-0e55-be70-1cb4-c746e3aa55a6@case.edu>
Subject: Re: 'history -n' should re-read history file if history is cleared
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Originating-IP: [10.34.4.148, 10.4.195.2]
Thread-Topic: 'history -n' should re-read history file if history is cleared
Thread-Index: SyqdnEHqBElFQLZ+pBc3yygIQHZ5Nw==
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.31]);
	Thu, 20 Apr 2017 13:38:13 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 209.132.183.28
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 20 Apr 2017 13:38:19 -0000



----- Original Message -----
> From: "Chet Ramey" <chet.ramey@case.edu>
> To: "Siteshwar Vashisht" <svashisht@redhat.com>, bug-bash@gnu.org
> Cc: "chet ramey" <chet.ramey@case.edu>
> Sent: Tuesday, April 18, 2017 5:36:05 PM
> Subject: Re: 'history -n' should re-read history file if history is cleared
> 
> Why should explicitly clearing old items from the history cause them to
> be treated as new?

I was just a bit skeptical about behavior of 'history -n' if history is cleared. On a second thought, I think the current behavior is fine and may not worth the change.

> 
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> 		 ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
> 

-- 
--
Siteshwar Vashisht


From MAILER-DAEMON Fri Apr 21 11:48:50 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d1ani-0003WE-OC
	for mharc-bug-bash@gnu.org; Fri, 21 Apr 2017 11:48:50 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:56220)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <psmith369@gmail.com>) id 1d1ang-0003TO-0Q
	for bug-bash@gnu.org; Fri, 21 Apr 2017 11:48:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <psmith369@gmail.com>) id 1d1ane-0006RN-AQ
	for bug-bash@gnu.org; Fri, 21 Apr 2017 11:48:48 -0400
Received: from mail-oi0-x234.google.com ([2607:f8b0:4003:c06::234]:34065)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <psmith369@gmail.com>) id 1d1ane-0006Qn-59
	for bug-bash@gnu.org; Fri, 21 Apr 2017 11:48:46 -0400
Received: by mail-oi0-x234.google.com with SMTP id x184so101194520oia.1
	for <bug-bash@gnu.org>; Fri, 21 Apr 2017 08:48:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=gLBvgiD2BzEpCc1+JM5GGVImdOyECazHQJ+kl3YRZ2c=;
	b=melBjqoR+pMRAcSFBx+J7UqEAd19N0FGYjeWIiDMnX5WwCL+dxaxGpJb8Y660W/gNt
	DU2tjVnuCHCa9uJ1QDnzu1JNNOVP4vCiT0LsYYiMErbprwZCPMY63IvAIyuLhl4lNGxU
	2rEzx2D5rB12jfxfFixEMyy4+e+KvNg2DUO1YRowQs0T5KRmMHdmVWMViCT7za1ND7Rf
	IbxN4r6ji9YN8XCvv/l490fk/juVBjtvte2uR4d0i2U6PXg73WRE+ILeys9cUoX/c7gO
	DsozlpIw4JtwA2i46agDG9xhwVVgiHGOmdSxJgw7BP3pkW/Alw8L4gxTSdSCods/ROkL
	n6Aw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=gLBvgiD2BzEpCc1+JM5GGVImdOyECazHQJ+kl3YRZ2c=;
	b=lUD0dGLzutHy7TsHnKneVayIzIhe7ju1hoS918NBhPOwEjhR/5UT3j4Vi1tZRUp6yG
	AF0Ql0Dfe+K6eSTSLPG8y9iXhDjHqhnqRJdxRAZ03LQAR+CGnqNw1X6NPjFM3zBqzbMj
	QvoF/P+5L4BMMctp+JzBVRBrkw9w+iv/kl/5AJ75QMqlCfEtACPb7EoVK7qy0EEb8bRN
	sFbtoEeRm28FvYbjdPCp2XW8g03ATnyGZBP5eiWSS0Be+4d+vOnR2vJqmCgYj+nskpzL
	IB2PFKSKfwOeNkTerr59pmvnSX+NPAYwOjzJF9ey3BTkaPVxsGRTitjY2/LG9JzaExhc
	QkiQ==
X-Gm-Message-State: AN3rC/5o7EaFCao7F0L55zpGI4wg6fOhKss40z1Q0EV8xiq4nTP4gJlg
	g+YR0ict+bytwRfr/h4FMypE8bKluQ==
X-Received: by 10.157.11.45 with SMTP id a42mr8171788ota.70.1492789725028;
	Fri, 21 Apr 2017 08:48:45 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.202.107.135 with HTTP; Fri, 21 Apr 2017 08:48:44 -0700 (PDT)
In-Reply-To: <7e2c8764-f6a8-0fa9-e886-ab3aaffc51a5@case.edu>
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>
	<CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
	<CAOSMAutUQ2o+VjD-F8UfRGXzytjjmuz0ka7XA_T9DFQ59xm_Xw@mail.gmail.com>
	<f2ba0481-b15c-a7e1-7d94-ca5d1d8a4444@case.edu>
	<58F65738.90502@tlinx.org>
	<7e2c8764-f6a8-0fa9-e886-ab3aaffc51a5@case.edu>
From: Pete Smith <psmith369@gmail.com>
Date: Fri, 21 Apr 2017 08:48:44 -0700
Message-ID: <CADMfKPw=SozuLAtw2Fdw1CwS9cSbcN2pDfrGDu4tvWFzkR1_6A@mail.gmail.com>
Subject: Re: Issus with popd and pushd
To: Chester Ramey <chet.ramey@case.edu>
Cc: L A Walsh <bash@tlinx.org>, "bug-bash@gnu.org" <bug-bash@gnu.org>, 
	Eduardo Bustamante <dualbus@gmail.com>
Content-Type: multipart/alternative; boundary=001a113dc54648e85d054daf312e
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4003:c06::234
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Fri, 21 Apr 2017 15:48:49 -0000

--001a113dc54648e85d054daf312e
Content-Type: text/plain; charset=UTF-8

Am clearly out of my league in these exchanges about possible
implementation. Nevertheless am heartened by
seeing these exchanges.

As to the question that came up in the dialogue:

> Um... don't you mean to use the alias command somewhere, like:
>
> alias popd='builtin popd|tr " " "\n"'

I defined the alias in ~/.bash_aliases

>From one of your initial explanations: that points out that the alias would
be executed in a sub shell, it makes sense
to me that, that approach won't work.

It appears to me that the sub shell does inherit the dirs stack, but any
changes that are made to the dir stack remain
in the sub shell and do not propagate back to the parent shell.

I was thrown off track by:

    alias dirs='dirs -v'

But after you explanation of the sub shell execution environment, this
makes sense as dirs does not make any changes
to the dirs stack.

Does the exchanges of your implementation comments mean the possibility of
the addition of the -v option to pushd and
popd are in the realm of possibility?

-Pete


On Tue, Apr 18, 2017 at 11:17 AM, Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/18/17 2:13 PM, L A Walsh wrote:
> > Chet Ramey wrote:
> >> On 4/18/17 9:35 AM, Eduardo Bustamante wrote:
> >>
> >>
> >>> Or now that I think about it, you can get away with these functions:
> >>>
> >>> # masked builtins
> >>> dualbus@debian:~/foo/bar/baz$ pushd() { builtin pushd "$@" >/dev/null;
> >>> dirs -v; }; popd(){ builtin popd "$@" >/dev/null; dirs -v; }
> >>>
> >>
> >> This would be the preferable alternative, since it's so trivial.  The
> one
> >> change I would suggest would be to make the `;' a `&&':
> >>
> >> pushd()
> >> {
> >>     builtin pushd "$@" >/dev/null && dirs -v
> >> }
> >>
> >>
> > Maybe add 'builtin' before "dirs" since we're redefining builtins
> > (i.e. get into habit?)
>
> Sure, if there's a chance there's a function named `dirs' and you *don't*
> want to use it, this is good practice.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~
> chet/
>

--001a113dc54648e85d054daf312e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Am clearly out of my league in these exchanges about possi=
ble implementation. Nevertheless am heartened by=C2=A0<div>seeing these exc=
hanges.<div><div><br></div><div>As to the question that came up in the dial=
ogue:</div><div><br></div><div><div>&gt; Um... don&#39;t you mean to use th=
e alias command somewhere, like:</div><div>&gt;</div><div>&gt; alias popd=
=3D&#39;builtin popd|tr &quot; &quot; &quot;\n&quot;&#39;</div></div><div><=
br></div><div>I defined the alias in ~/.bash_aliases</div><div><br></div><d=
iv>From one of your initial explanations: that points out that the alias wo=
uld be executed in a sub shell, it makes sense</div><div>to me that, that a=
pproach won&#39;t work.</div><div><br></div><div>It appears to me that the =
sub shell does inherit the dirs stack, but any changes that are made to the=
 dir stack remain</div><div>in the sub shell and do not propagate back to t=
he parent shell.</div><div><br></div><div>I was thrown off track by:<br></d=
iv><div><br></div><div>=C2=A0 =C2=A0 alias dirs=3D&#39;dirs -v&#39;</div><d=
iv><br></div><div>But after you explanation of the sub shell execution envi=
ronment, this makes sense as dirs does not make any changes=C2=A0</div><div=
>to the dirs stack.</div><div><div><br class=3D"gmail-Apple-interchange-new=
line">Does the exchanges of your implementation comments mean the possibili=
ty of the addition of the -v option to pushd and=C2=A0</div><div>popd are i=
n the realm of possibility?</div><div><br></div></div><div>-Pete</div><div>=
<br></div></div></div></div><div class=3D"gmail_extra"><br><div class=3D"gm=
ail_quote">On Tue, Apr 18, 2017 at 11:17 AM, Chet Ramey <span dir=3D"ltr">&=
lt;<a href=3D"mailto:chet.ramey@case.edu" target=3D"_blank">chet.ramey@case=
.edu</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D=
"">On 4/18/17 2:13 PM, L A Walsh wrote:<br>
&gt; Chet Ramey wrote:<br>
&gt;&gt; On 4/18/17 9:35 AM, Eduardo Bustamante wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; Or now that I think about it, you can get away with these func=
tions:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; # masked builtins<br>
&gt;&gt;&gt; dualbus@debian:~/foo/bar/baz$ pushd() { builtin pushd &quot;$@=
&quot; &gt;/dev/null;<br>
&gt;&gt;&gt; dirs -v; }; popd(){ builtin popd &quot;$@&quot; &gt;/dev/null;=
 dirs -v; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; This would be the preferable alternative, since it&#39;s so trivia=
l.=C2=A0 The one<br>
&gt;&gt; change I would suggest would be to make the `;&#39; a `&amp;&amp;&=
#39;:<br>
&gt;&gt;<br>
&gt;&gt; pushd()<br>
&gt;&gt; {<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0builtin pushd &quot;$@&quot; &gt;/dev/null &amp=
;&amp; dirs -v<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt; Maybe add &#39;builtin&#39; before &quot;dirs&quot; since we&#39;re re=
defining builtins<br>
&gt; (i.e. get into habit?)<br>
<br>
</span>Sure, if there&#39;s a chance there&#39;s a function named `dirs&#39=
; and you *don&#39;t*<br>
want to use it, this is good practice.<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
``The lyf so short, the craft so long to lerne.&#39;&#39; - Chaucer<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0``Ars longa, =
vita brevis&#39;&#39; - Hippocrates<br>
Chet Ramey, UTech, CWRU=C2=A0 =C2=A0 <a href=3D"mailto:chet@case.edu">chet@=
case.edu</a>=C2=A0 =C2=A0 <a href=3D"http://cnswww.cns.cwru.edu/~chet/" rel=
=3D"noreferrer" target=3D"_blank">http://cnswww.cns.cwru.edu/~<wbr>chet/</a=
><br>
</div></div></blockquote></div><br></div>

--001a113dc54648e85d054daf312e--


From MAILER-DAEMON Fri Apr 21 13:36:16 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d1cTg-0006r2-7s
	for mharc-bug-bash@gnu.org; Fri, 21 Apr 2017 13:36:16 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52284)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d1cTe-0006pz-EA
	for bug-bash@gnu.org; Fri, 21 Apr 2017 13:36:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d1cTb-0005GZ-Af
	for bug-bash@gnu.org; Fri, 21 Apr 2017 13:36:14 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:58177
	helo=mpv1-2015.case.edu) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d1cTa-0005GL-Oo
	for bug-bash@gnu.org; Fri, 21 Apr 2017 13:36:10 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMU12597; Fri, 21 Apr 2017 13:36:06 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDD47245 (AUTH cpr);
	Fri, 21 Apr 2017 13:36:06 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Issus with popd and pushd
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>
	<CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
	<CAOSMAutUQ2o+VjD-F8UfRGXzytjjmuz0ka7XA_T9DFQ59xm_Xw@mail.gmail.com>
	<f2ba0481-b15c-a7e1-7d94-ca5d1d8a4444@case.edu>
	<58F65738.90502@tlinx.org>
	<7e2c8764-f6a8-0fa9-e886-ab3aaffc51a5@case.edu>
	<CADMfKPw=SozuLAtw2Fdw1CwS9cSbcN2pDfrGDu4tvWFzkR1_6A@mail.gmail.com>
To: Pete Smith <psmith369@gmail.com>
Cc: chet.ramey@case.edu, L A Walsh <bash@tlinx.org>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>,
	Eduardo Bustamante <dualbus@gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <7c45ffd3-2bfa-be9d-6d41-b20c5e1b3504@case.edu>
Date: Fri, 21 Apr 2017 13:36:05 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CADMfKPw=SozuLAtw2Fdw1CwS9cSbcN2pDfrGDu4tvWFzkR1_6A@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.21.170616:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_900_999,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES, __CC_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Fri, 21 Apr 2017 17:36:15 -0000

On 4/21/17 11:48 AM, Pete Smith wrote:

> It appears to me that the sub shell does inherit the dirs stack, but any
> changes that are made to the dir stack remain
> in the sub shell and do not propagate back to the parent shell.

Correct; it's a separate process.

> Does the exchanges of your implementation comments mean the possibility of
> the addition of the -v option to pushd and 
> popd are in the realm of possibility?

I think the key takeaway is that this is trivial to do with a shell
function, even if you want to add argument parsing (use getopts) and
pass all the option arguments except -v to the builtins.

I would pursue that implementation first. It's much simpler and can be
done more quickly.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Fri Apr 21 13:52:51 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d1cjj-00062g-QH
	for mharc-bug-bash@gnu.org; Fri, 21 Apr 2017 13:52:51 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57138)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d1cji-00061c-7I
	for bug-bash@gnu.org; Fri, 21 Apr 2017 13:52:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d1cje-00032c-B3
	for bug-bash@gnu.org; Fri, 21 Apr 2017 13:52:50 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:38720
	helo=mpv4-2015.case.edu) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d1cje-00032R-5e
	for bug-bash@gnu.org; Fri, 21 Apr 2017 13:52:46 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALK14636; Fri, 21 Apr 2017 13:52:42 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDD50013 (AUTH cpr);
	Fri, 21 Apr 2017 13:52:42 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Issus with popd and pushd
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>
	<CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
	<CAOSMAutUQ2o+VjD-F8UfRGXzytjjmuz0ka7XA_T9DFQ59xm_Xw@mail.gmail.com>
	<f2ba0481-b15c-a7e1-7d94-ca5d1d8a4444@case.edu>
	<58F65738.90502@tlinx.org>
	<7e2c8764-f6a8-0fa9-e886-ab3aaffc51a5@case.edu>
	<CADMfKPw=SozuLAtw2Fdw1CwS9cSbcN2pDfrGDu4tvWFzkR1_6A@mail.gmail.com>
	<7c45ffd3-2bfa-be9d-6d41-b20c5e1b3504@case.edu>
To: Pete Smith <psmith369@gmail.com>
Cc: chet.ramey@case.edu, L A Walsh <bash@tlinx.org>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>,
	Eduardo Bustamante <dualbus@gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <a2b91066-3569-db0f-8c5e-e3e079f32dfb@case.edu>
Date: Fri, 21 Apr 2017 13:52:41 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <7c45ffd3-2bfa-be9d-6d41-b20c5e1b3504@case.edu>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.21.172716:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__CC_NAME_DIFF_FROM_ACC, __HAS_FROM, FROM_EDU_TLD,
	__HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_400_499,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES, __CC_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Fri, 21 Apr 2017 17:52:51 -0000

On 4/21/17 1:36 PM, Chet Ramey wrote:

> I think the key takeaway is that this is trivial to do with a shell
> function, even if you want to add argument parsing (use getopts) and
> pass all the option arguments except -v to the builtins.

On second thought, don't use getopts.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sat Apr 22 03:38:46 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d1pd0-0004q8-7z
	for mharc-bug-bash@gnu.org; Sat, 22 Apr 2017 03:38:46 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51716)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <psmith369@gmail.com>) id 1d1pcx-0004od-H7
	for bug-bash@gnu.org; Sat, 22 Apr 2017 03:38:44 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <psmith369@gmail.com>) id 1d1pcw-0006gt-HF
	for bug-bash@gnu.org; Sat, 22 Apr 2017 03:38:43 -0400
Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:35643)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <psmith369@gmail.com>) id 1d1pcw-0006gj-BU
	for bug-bash@gnu.org; Sat, 22 Apr 2017 03:38:42 -0400
Received: by mail-oi0-x22b.google.com with SMTP id j201so120277154oih.2
	for <bug-bash@gnu.org>; Sat, 22 Apr 2017 00:38:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=5bf9EHuBIf+omNkEV+ocXmTOzrVzG51WAUPNSzB0AxY=;
	b=DTjuaZ/eEqi0DXSvJR4Hgjt0Hvdfvzx0gfwGZMtNi2YhuQ8pOaOApPmASAXyCWuh5c
	kS5Wo1WU+SNO4VNSLa7E53J9YkJApbspCnbqQzVlyRJ9/FlzGlCjBV+aB+y7LfCIudC6
	kseq3HMG73fPFCvCrEbIKZGzejuGtxy0YtwTsEPMhXLi7q55W4TZVLk4nyBrwpjp/dNo
	lP4KJrP2R3oTYdc9KFRfjyFle6bKgYO7PHQjIRaht0ftTKjHkiEupPsWc2P3VVNdnEU6
	BiEgtxlln+Js16MJC6G3A/WW5HOHvzYOSb5HyL5Bb2axp9vYiGSWBjNRIGxgBVqs/A03
	xbyQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=5bf9EHuBIf+omNkEV+ocXmTOzrVzG51WAUPNSzB0AxY=;
	b=U3rLXPhLYnoQrJv6EVPQ+LLF8IwwNhEmZ7hG8KUG9+xGtACI/TzXsw6Xbyxj0akDOr
	TZlx0UtLwQ+qEidqrQUZLw/S8MGoYkHEpCz+iuWLuZoIki36Tk8aftWBJFmsqkpuX2gA
	xsUf4UWzHK+NSNVrOugyMJ5+le3RwilWvKaU/5nG4c6UNMzp8UOeKKApyEA8FwOg16ly
	P5xgcAe/qUy8g6vwpMHd2x+xvRcVGWum4bqE88saDsmp/Fl42UdpJWFPCc0dXKs7jK3+
	blMEMPts/MPSAJzJBXLtwpqj6OaCpySFnz56wrMJDos2+TNJZZFy92238eo1gPGUmjlh
	ogoA==
X-Gm-Message-State: AN3rC/7ZAmXpoxXQparC/87zZ66JRjiySqsZeFxHJf1TzNdG/kGcbgH4
	cOa5K4Mqnph+yFI3oLQkx2JXA7utUA==
X-Received: by 10.202.234.66 with SMTP id i63mr9774098oih.177.1492846721312;
	Sat, 22 Apr 2017 00:38:41 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.202.97.8 with HTTP; Sat, 22 Apr 2017 00:38:40 -0700 (PDT)
In-Reply-To: <a2b91066-3569-db0f-8c5e-e3e079f32dfb@case.edu>
References: <CADMfKPz=ckj=dLdQkrxhzXKeQ8zYp4JsNMRFX60BBtUjj6tCrA@mail.gmail.com>
	<944173e6-453f-39fe-8f09-9496032ea540@case.edu>
	<CADMfKPwNiJHfgLNbRrLM-vfjD37OmZFeFt6U7zoKPAza-54q+g@mail.gmail.com>
	<CAOSMAutUQ2o+VjD-F8UfRGXzytjjmuz0ka7XA_T9DFQ59xm_Xw@mail.gmail.com>
	<f2ba0481-b15c-a7e1-7d94-ca5d1d8a4444@case.edu>
	<58F65738.90502@tlinx.org>
	<7e2c8764-f6a8-0fa9-e886-ab3aaffc51a5@case.edu>
	<CADMfKPw=SozuLAtw2Fdw1CwS9cSbcN2pDfrGDu4tvWFzkR1_6A@mail.gmail.com>
	<7c45ffd3-2bfa-be9d-6d41-b20c5e1b3504@case.edu>
	<a2b91066-3569-db0f-8c5e-e3e079f32dfb@case.edu>
From: Pete Smith <psmith369@gmail.com>
Date: Sat, 22 Apr 2017 00:38:40 -0700
Message-ID: <CADMfKPwHvQmWmXVWtHDUqfP4NMmcSenk3SA3cQ-PVK4me+0AOA@mail.gmail.com>
Subject: Re: Issus with popd and pushd
To: Chester Ramey <chet.ramey@case.edu>
Cc: L A Walsh <bash@tlinx.org>, "bug-bash@gnu.org" <bug-bash@gnu.org>, 
	Eduardo Bustamante <dualbus@gmail.com>
Content-Type: multipart/alternative; boundary=001a113d6368872c9b054dbc76e1
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4003:c06::22b
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 22 Apr 2017 07:38:44 -0000

--001a113d6368872c9b054dbc76e1
Content-Type: text/plain; charset=UTF-8

Thanks

I was being a bit dense, didn't realize that the format you gave causes the
commands to run in the parent shell.

It works as it should!

-Pete

On Fri, Apr 21, 2017 at 10:52 AM, Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/21/17 1:36 PM, Chet Ramey wrote:
>
> > I think the key takeaway is that this is trivial to do with a shell
> > function, even if you want to add argument parsing (use getopts) and
> > pass all the option arguments except -v to the builtins.
>
> On second thought, don't use getopts.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~
> chet/
>

--001a113d6368872c9b054dbc76e1
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks=C2=A0<div><br></div><div>I was being a bit dense, d=
idn&#39;t realize that the format you gave causes the commands to run in th=
e parent shell.</div><div><br></div><div>It works as it should!</div><div><=
br></div><div>-Pete</div></div><div class=3D"gmail_extra"><br><div class=3D=
"gmail_quote">On Fri, Apr 21, 2017 at 10:52 AM, Chet Ramey <span dir=3D"ltr=
">&lt;<a href=3D"mailto:chet.ramey@case.edu" target=3D"_blank">chet.ramey@c=
ase.edu</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=
=3D"">On 4/21/17 1:36 PM, Chet Ramey wrote:<br>
<br>
&gt; I think the key takeaway is that this is trivial to do with a shell<br=
>
&gt; function, even if you want to add argument parsing (use getopts) and<b=
r>
&gt; pass all the option arguments except -v to the builtins.<br>
<br>
</span>On second thought, don&#39;t use getopts.<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
``The lyf so short, the craft so long to lerne.&#39;&#39; - Chaucer<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0``Ars longa, =
vita brevis&#39;&#39; - Hippocrates<br>
Chet Ramey, UTech, CWRU=C2=A0 =C2=A0 <a href=3D"mailto:chet@case.edu">chet@=
case.edu</a>=C2=A0 =C2=A0 <a href=3D"http://cnswww.cns.cwru.edu/~chet/" rel=
=3D"noreferrer" target=3D"_blank">http://cnswww.cns.cwru.edu/~<wbr>chet/</a=
><br>
</div></div></blockquote></div><br></div>

--001a113d6368872c9b054dbc76e1--


From MAILER-DAEMON Sat Apr 22 14:36:39 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d1ztf-0003tl-Lj
	for mharc-bug-bash@gnu.org; Sat, 22 Apr 2017 14:36:39 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58876)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <andrew.mcglashan@affinityvision.com.au>)
	id 1d1z9v-0004Fu-Og
	for bug-bash@gnu.org; Sat, 22 Apr 2017 13:49:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <andrew.mcglashan@affinityvision.com.au>)
	id 1d1z9s-00072k-Mb
	for bug-bash@gnu.org; Sat, 22 Apr 2017 13:49:23 -0400
Received: from ns2.affinityvision.com.au ([220.233.38.77]:48352
	helo=mail.affinityvision.com.au)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <andrew.mcglashan@affinityvision.com.au>)
	id 1d1z9s-00071r-89
	for bug-bash@gnu.org; Sat, 22 Apr 2017 13:49:20 -0400
Received: from [192.168.0.43] (port=57428)
	by mail.affinityvision.com.au with esmtpsa
	(TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80)
	(envelope-from <andrew.mcglashan@affinityvision.com.au>)
	id 1d1z9e-000229-Fn; Sun, 23 Apr 2017 03:49:07 +1000
To: bug-bash@gnu.org, bash@packages.debian.org
From: Andrew McGlashan <andrew.mcglashan@affinityvision.com.au>
Message-ID: <30d824f1-9ebb-f7ce-034b-99fb49098257@affinityvision.com.au>
Date: Sun, 23 Apr 2017 03:49:03 +1000
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
	Thunderbird/45.8.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Authenticated-User: Yes -- sender address:
	andrew.mcglashan@affinityvision.com.au
X-SA-Exim-Connect-IP: 192.168.0.43
X-SA-Exim-Mail-From: andrew.mcglashan@affinityvision.com.au
Subject: arithmetic problem, incorrect return code with ((var++)) when var is
	0 before operation
X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000)
X-SA-Exim-Scanned: Yes (on mail.affinityvision.com.au)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy]
X-Received-From: 220.233.38.77
X-Mailman-Approved-At: Sat, 22 Apr 2017 14:36:38 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 22 Apr 2017 17:49:24 -0000

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib
-Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat
-Werror=format-security -Wall
uname output: Linux andrewm-Satellite-P50-A 4.4.0-72-generic #93-Ubuntu
SMP Fri Mar 31 14:07:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.3
Patch Level: 42
Release Status: release

Description:

The return code from ((i++)) operation is different when i has an
initial value of 0.

This problem was discovered when running run a bash script with "set
-ue" and having "((i++))" as the last command in a loop.


Repeat-By:

The following script will quit with an error after the first iteration
due to the return code errantly being 1.

#!/bin/bash
set -eu
i=0
for a in a b c
do
   echo "${a}"
   ((i++))
done


NB: If i starts as 1, the script works as expected.

Also, using ((i+=1)) works fine, but I prefer the ((i++)) format.


Proof outside a loop:

$ c=0;((c++));echo $?
1


$ c=1;((c++));echo $?
0




From MAILER-DAEMON Sat Apr 22 15:03:19 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d20JT-0006wd-1B
	for mharc-bug-bash@gnu.org; Sat, 22 Apr 2017 15:03:19 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46362)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d20JO-0006us-8Y
	for bug-bash@gnu.org; Sat, 22 Apr 2017 15:03:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d20JM-0005T4-QN
	for bug-bash@gnu.org; Sat, 22 Apr 2017 15:03:14 -0400
Received: from mail-it0-x231.google.com ([2607:f8b0:4001:c0b::231]:37216)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d20JM-0005Sl-LO
	for bug-bash@gnu.org; Sat, 22 Apr 2017 15:03:12 -0400
Received: by mail-it0-x231.google.com with SMTP id x188so14602004itb.0
	for <bug-bash@gnu.org>; Sat, 22 Apr 2017 12:03:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=1XcoCYFrmPf6xOrvUTwRWq/CHHWkoe2O+BnCzMUYBxM=;
	b=a5I4RifSlPH5zCLBdZZTz6uRWyEInS3euZ9AmmjrlBOBQiA5/NFDeZ0LJ1Yk0D3zKW
	P5za2QOwvIhEaNkAAL7AYriFzwE3dgxuYpW0NXClYmx9G58OuKn9xabqnBO4A0cQxvbF
	I2O2CnB5vqoAvzj0SWbPKO2/a3sCxX4dBn6sbs2YWRP/zPrylRJGc6gRu/LbO/4tZs1v
	Xy+BXS5PsoahIT54Xor2GzneJquMZRbtkXCL3iEofuBrWT/ryVHvL72SK8koOu9UDuhZ
	ykiV+B/ethomcniq2HKRjYmb/+pX2tRKo3C5lfHRONgNjJfaXbS734TDoRuj3tLjTy7p
	lcwg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=1XcoCYFrmPf6xOrvUTwRWq/CHHWkoe2O+BnCzMUYBxM=;
	b=rYxucKXPf8ISDuZ9QSyMNLmOelXIz9nPLML5bhmls30i5OlVCIDOqOTXo0wkT8w23Y
	YzJqzKfPTp3AaJjwNEprkRymA7AiQsdk07d9iByhF7en31egS1sNbFkPUTOKmhn6vsnO
	RDgQkLBy8X2WBG/kfiFcJ5Tt22zX/X+O7Ks1ZmyiSpu6F4IVhascpLDvrhdmPOW8XGLU
	kjB1XTZo16RSfynB0xngYoenSgB/DmuiheOeBFZqfpxpvRhxDnZGi9ws2bGfs4F8ZPBG
	EJnus82aAmX8FAnAEiC5pd9yYhjt1738SzHP74w1bbmI7CvQm4TzPufsjybibRpLMMtz
	2ajQ==
X-Gm-Message-State: AN3rC/70wHCT9BSw2nkuPzNsWdCZGbUi7uEfLbNbcYtSMQUY+BIVJC1o
	0wi2hcfiIdbM0vlkpaD4U3ZsKzT19cl1
X-Received: by 10.36.43.213 with SMTP id h204mr5353913ita.113.1492887791922;
	Sat, 22 Apr 2017 12:03:11 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Sat, 22 Apr 2017 12:02:51 -0700 (PDT)
In-Reply-To: <30d824f1-9ebb-f7ce-034b-99fb49098257@affinityvision.com.au>
References: <30d824f1-9ebb-f7ce-034b-99fb49098257@affinityvision.com.au>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Sat, 22 Apr 2017 14:02:51 -0500
Message-ID: <CAOSMAuv0oFL_+SU7FcTEZicqzHxaJFQvMHm9ZicAs-ABEFvGgQ@mail.gmail.com>
Subject: Re: arithmetic problem, incorrect return code with ((var++)) when var
	is 0 before operation
To: Andrew McGlashan <andrew.mcglashan@affinityvision.com.au>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>,
	"bash@packages.debian.org" <bash@packages.debian.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c0b::231
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 22 Apr 2017 19:03:17 -0000

On Sat, Apr 22, 2017 at 12:49 PM, Andrew McGlashan
<andrew.mcglashan@affinityvision.com.au> wrote:
[...]
>
> The return code from ((i++)) operation is different when i has an
> initial value of 0.

This is not a bug.

Please read the Bash reference manual section on conditional
constructs: https://www.gnu.org/software/bash/manual/bash.html#index-commands_002c-conditional

    | The arithmetic expression is evaluated according to the rules
described below (see Shell Arithmetic). If the value of the expression
is non-zero, the return status is 0; otherwise the return status is 1.
This is exactly equivalent to
    |
    | let "expression"

This is also described in other sources:

1. http://wiki.bash-hackers.org/commands/builtin/let#description
2. http://mywiki.wooledge.org/ArithmeticExpression#Arithmetic_Commands

Also see the 1st example in http://mywiki.wooledge.org/BashFAQ/105
("Why doesn't set -e (or set -o errexit, or trap ERR) do what I
expected?"), which mentions this pitfall.

You can also find extensive discussions in the bug-bash archives on
why you shouldn't be using set -e, regardless of how many "sources" on
the web claim that it helps write "robust" or "correct" shell scripts.


From MAILER-DAEMON Sun Apr 23 06:12:20 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2EVA-0003Av-Gc
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 06:12:20 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55235)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2EV8-0003Am-4O
	for bug-bash@gnu.org; Sun, 23 Apr 2017 06:12:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2EV4-0004fb-W0
	for bug-bash@gnu.org; Sun, 23 Apr 2017 06:12:18 -0400
Received: from pv35p18im-ztdg05101101.me.com ([17.133.188.44]:15045)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d2EV4-0004f9-NI
	for bug-bash@gnu.org; Sun, 23 Apr 2017 06:12:14 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05101101.me.com by
	pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OOU00I00XGSGV00@pv35p18im-ztdg05101101.me.com> for
	bug-bash@gnu.org; Sun, 23 Apr 2017 10:12:11 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1492942331; bh=Mzht1+b42ytiUEnBhjiUhD2JnCpd1aN6FcKiTinBV0w=;
	h=From:Content-type:Subject:Message-id:Date:To:MIME-version;
	b=WeTFQAqaMJ9u9uL/Fy379xPyS4uQ4eruwi35ml4OiGUlO5LHxsecv+2PPBEXT+Bg5
	dRR7aVNVkqDjelaRpJdCyUkedKoWaIcBh7NvuFzcKIE2PR3CBCjQ3053eT1ypKp64s
	JRoLGoNLIcNFn4MQkAGHEk6VUsDvOgC67X3xk33ZrmXEuMeMWT2CatjhyRI9FmwEEp
	tbOcJZ6j53zqNApPSbvmkudSaajVaWpM9hZyPdNKSKArUXVI70gziS5JB5vP/eeTvq
	LFY33Eo3zSxUYI5dkx5QzWpY9S5gD6hZ0/z9pCnD7539qMlvWZpGib4pw3LbMPKk/i
	0beY5RakA6wKQ==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OOU0024KXO8F140@pv35p18im-ztdg05101101.me.com> for
	bug-bash@gnu.org; Sun, 23 Apr 2017 10:12:11 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-23_09:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704230184
From: Florian Mayer <mayerflorian@me.com>
Content-type: text/plain; charset=utf-8
Content-transfer-encoding: quoted-printable
Subject: Curious case of arithmetic expansion
Message-id: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
Date: Sun, 23 Apr 2017 12:12:08 +0200
To: bug-bash@gnu.org
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
X-Mailer: Apple Mail (2.3124)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.44
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 10:12:19 -0000

Consider

$ foo=3Dbar; bar=3Dmoo; moo=3D123
$ echo $foo $bar $moo
=3D> bar moo 123
$ echo $((foo))
=3D> 123=20
$ echo $foo $bar $moo
=3D> bar moo 123
$ # so far so good but
$ ((foo++))
$ echo $foo $bar $moo
=3D> 123 moo 123

Now my chain of indirections is broken=E2=80=A6=20=


From MAILER-DAEMON Sun Apr 23 07:55:55 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2G7P-0003fa-4n
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 07:55:55 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40662)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d2G7M-0003eI-Jw
	for bug-bash@gnu.org; Sun, 23 Apr 2017 07:55:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d2G7L-0008TA-N9
	for bug-bash@gnu.org; Sun, 23 Apr 2017 07:55:52 -0400
Received: from mail-qt0-x230.google.com ([2607:f8b0:400d:c0d::230]:32793)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <pierre.gaston@gmail.com>)
	id 1d2G7L-0008Rs-Hs
	for bug-bash@gnu.org; Sun, 23 Apr 2017 07:55:51 -0400
Received: by mail-qt0-x230.google.com with SMTP id m36so96219590qtb.0
	for <bug-bash@gnu.org>; Sun, 23 Apr 2017 04:55:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=/Z6/h5VWPewEYjzoD7Ttam019UVGILSphCffcQLvkjs=;
	b=Fq4yN7phpTzPX8DdxS+pfCScR+wu8mZ6ZFHFqYfP/cdiUmqJdW6PIr8xa+s2wST2Fp
	Y67dcVDv2CGC0REgMngGV9W1YMRRiYD6CH7YWoXzxHBuogdmc+qU5S0TXdV+0a9k4IEZ
	QuDRh0ElINFBm84KvYCTmXPl6p4TUFuAM4TmTPJPj+/cRA3RrK0qyMKG5q6ArSHasgRD
	RwVbVheluxuka/qW9pm+aaEIifQcHUouSM+PnIrufWiB8PgJa6OhqMzxMjaKZmkt2wA7
	52W8EKSBZM+IFPmqHF/zbl+e5HgGOYTkv5ohRPhZDGyf93RUy0zYtU7y0XXEhCttNN/6
	IFhw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=/Z6/h5VWPewEYjzoD7Ttam019UVGILSphCffcQLvkjs=;
	b=MUkpCN3bmBYUEcAejsSfl1+kFmNTUH4+lN4GV+9W9QzmtahZZPw8/BSW0UjRtvIgoD
	9RBn4IzVCmloAOc4kcQIu9dIVm1yjQgIPSBACDDzML2PCE+OgNWRuStlYa8OapYwmTZP
	0v8mavU8strLMYm37oN5+Xbq+/NTiCW840HjaHAWfVYGxl+g5HjT25aFh0c1Us2LqQrm
	kCdFOHIaomxj7uKK3xxvqzuigqE3iYO0Aqw/HygPHVHf2somuB/3yftq5LLOkf3T300N
	qy/ASeVL2GjEP9w4jdIbU2hEJuSFC+0QPuuXL4GfEnQKAeVwbP/R3sl+nbKmGWpKtnmD
	fo8A==
X-Gm-Message-State: AN3rC/6b+8omzq/yfZ49iZ4WpI2EGG/7+gPUl1C4JOMYqFVzoLL5vJyI
	fuUMH7kisWY+kD20DCEnbthXYQRsCw==
X-Received: by 10.237.53.124 with SMTP id b57mr20237610qte.240.1492948549253; 
	Sun, 23 Apr 2017 04:55:49 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.12.180.13 with HTTP; Sun, 23 Apr 2017 04:55:28 -0700 (PDT)
In-Reply-To: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Sun, 23 Apr 2017 14:55:28 +0300
Message-ID: <CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
Subject: Re: Curious case of arithmetic expansion
To: Florian Mayer <mayerflorian@me.com>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a11c103c8f24cc0054dd42b5b
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c0d::230
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 11:55:53 -0000

--001a11c103c8f24cc0054dd42b5b
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sun, Apr 23, 2017 at 1:12 PM, Florian Mayer <mayerflorian@me.com> wrote:

> Consider
>
> $ foo=3Dbar; bar=3Dmoo; moo=3D123
> $ echo $foo $bar $moo
> =3D> bar moo 123
> $ echo $((foo))
> =3D> 123
> $ echo $foo $bar $moo
> =3D> bar moo 123
> $ # so far so good but
> $ ((foo++))
> $ echo $foo $bar $moo
> =3D> 123 moo 123
>
> Now my chain of indirections is broken=E2=80=A6
>

It prints "124 moo 123" no?

It's because it's not really indirection, rather the content of the
variable is evaluated:

$ foo=3D1+2;echo $((foo))
3

In the last case it evaluates the value of foo, 123, and then increment the
value of foo and foo becomes 124

--001a11c103c8f24cc0054dd42b5b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Sun, Apr 23, 2017 at 1:12 PM, Florian Mayer <span dir=3D"ltr">&lt;<a=
 href=3D"mailto:mayerflorian@me.com" target=3D"_blank">mayerflorian@me.com<=
/a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">=
Consider<br>
<br>
$ foo=3Dbar; bar=3Dmoo; moo=3D123<br>
$ echo $foo $bar $moo<br>
=3D&gt; bar moo 123<br>
$ echo $((foo))<br>
=3D&gt; 123<br>
$ echo $foo $bar $moo<br>
=3D&gt; bar moo 123<br>
$ # so far so good but<br>
$ ((foo++))<br>
$ echo $foo $bar $moo<br>
=3D&gt; 123 moo 123<br>
<br>
Now my chain of indirections is broken=E2=80=A6<br>
</blockquote></div><br>It prints &quot;124 moo 123&quot; no?<br></div><div =
class=3D"gmail_extra"><br>It&#39;s because it&#39;s not really indirection,=
 rather the content of the variable is evaluated:<br><br>$ foo=3D1+2;echo $=
((foo))<br>3<br><br></div><div class=3D"gmail_extra">In the last case it ev=
aluates the value of foo, 123, and then increment the value of foo and foo =
becomes 124<br></div><div class=3D"gmail_extra"><br></div></div>

--001a11c103c8f24cc0054dd42b5b--


From MAILER-DAEMON Sun Apr 23 08:28:23 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2Gcp-00064J-8A
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 08:28:23 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46091)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2Gcn-00064C-Gt
	for bug-bash@gnu.org; Sun, 23 Apr 2017 08:28:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2Gck-0001CO-BV
	for bug-bash@gnu.org; Sun, 23 Apr 2017 08:28:21 -0400
Received: from pv35p18im-ztdg05101101.me.com ([17.133.188.44]:41895)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d2Gck-0001Bi-2K
	for bug-bash@gnu.org; Sun, 23 Apr 2017 08:28:18 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05101101.me.com by
	pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OOV00C003PFNE00@pv35p18im-ztdg05101101.me.com> for
	bug-bash@gnu.org; Sun, 23 Apr 2017 12:28:06 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1492950486; bh=GFaZX6ba60x16tAKcDKwHYQmQvcTVvCRg03fw0T0WDU=;
	h=From:Content-type:Message-id:MIME-version:Subject:Date:To;
	b=U/1CoMWg65c2mEOnt3pVQ7aYYvUJibYLmy/3eYhQ1l6Fafh7VTlVMolSF0fm5+ax/
	WRunFX9zcjKwDXEyPAE+bwh7JAPnv1m5PeZGvTpIKNUgSm9LJx9n3TSFgiLTPpziQg
	xiHVAEdAv+JLl0HZ791OLDupgqZ8DFtGJyyt2tB33sPS0bsfvCI05zcd/2NEVL/Od7
	dSJ+f5ua7ZgdWln2b08YciRKqvK782Ns+CWaKaf7HYXZUMbE3AtbKL8evePCTfynRc
	mcXwiVu1XfzHArczrWZAsK3Mczbjd+edIIV2VV1AvIMNpCNCS5XstkSdwpcflbLnde
	y5WVuj45S33YA==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OOV00HYU3YRKG40@pv35p18im-ztdg05101101.me.com>; Sun,
	23 Apr 2017 12:28:06 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-23_11:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704230228
From: Florian Mayer <mayerflorian@me.com>
Content-type: multipart/alternative;
	boundary="Apple-Mail=_C4F549B1-282B-4493-87F3-F205994DAE5C"
Message-id: <7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
Subject: Re: Curious case of arithmetic expansion
Date: Sun, 23 Apr 2017 14:28:01 +0200
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
To: Pierre Gaston <pierre.gaston@gmail.com>, bug-bash@gnu.org
In-reply-to: <CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
X-Mailer: Apple Mail (2.3124)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.44
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 12:28:22 -0000


--Apple-Mail=_C4F549B1-282B-4493-87F3-F205994DAE5C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

What I=E2=80=99m saying is, that if bash does recursively apply =
expansion
mechanisms on the identifiers until it can retrieve a number,=20
it should do it symmetrically. That is,
it should remember what chain of expansion had been necessary for
a particular number to appear at the end of the expansion.

So instead of=20
124 moo 123
The echo command should produce
bar moo 124

(The expansion chain here was foo->bar->moo->123)

> It's because it's not really indirection, rather the content of the =
variable is evaluated:
No it is really indirection. Bash even has a special (and very limited) =
syntax for that.
Consider=20
$ foo=3Dbar; bar=3Dmoo
You can get the string =E2=80=9Emoo=E2=80=9C through foo by using
$ echo ${!foo}

$ echo ${!!foo} # or something else does not work, though...

>=20
>=20
> It prints "124 moo 123" no?
>=20
> It's because it's not really indirection, rather the content of the =
variable is evaluated:
>=20
> $ foo=3D1+2;echo $((foo))
> 3
>=20
> In the last case it evaluates the value of foo, 123, and then =
increment the value of foo and foo becomes 124
>=20


--Apple-Mail=_C4F549B1-282B-4493-87F3-F205994DAE5C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D""><div class=3D"">What I=E2=80=99m saying is, that if bash does =
recursively apply expansion</div><div class=3D"">mechanisms on the =
identifiers until it can retrieve a number,&nbsp;</div><div class=3D"">it =
should do it symmetrically. That is,</div><div class=3D"">it should =
remember what chain of expansion had been necessary for</div><div =
class=3D"">a particular number to appear at the end of the =
expansion.</div><div class=3D""><br class=3D""></div><div class=3D"">So =
instead of&nbsp;</div><div class=3D"">124 moo 123</div><div class=3D"">The=
 echo command should produce</div><div class=3D"">bar moo 124</div><div =
class=3D""><br class=3D""></div><div class=3D"">(The expansion chain =
here was foo-&gt;bar-&gt;moo-&gt;123)</div><div class=3D""><br =
class=3D""></div><div class=3D""><blockquote type=3D"cite" class=3D""><div=
 dir=3D"ltr" class=3D""><div class=3D"gmail_extra">It's because it's not =
really indirection, rather the content of the variable is evaluated:<br =
class=3D""></div></div></blockquote>No it is really indirection. Bash =
even has a special (and very limited) syntax for that.</div><div =
class=3D"">Consider&nbsp;</div><div class=3D"">$ foo=3Dbar; =
bar=3Dmoo</div><div class=3D"">You can get the string =E2=80=9Emoo=E2=80=9C=
 through foo by using</div><div class=3D"">$ echo ${!foo}</div><div =
class=3D""><br class=3D""></div><div class=3D"">$ echo ${!!foo} # or =
something else does not work, though...</div><div class=3D""><br =
class=3D""></div><div><blockquote type=3D"cite" class=3D""><div =
class=3D""><div dir=3D"ltr" class=3D""><div class=3D"gmail_extra"><div =
class=3D"gmail_quote"><blockquote class=3D"gmail_quote" =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex"><br class=3D"">
</blockquote></div><br class=3D"">It prints "124 moo 123" no?<br =
class=3D""></div><div class=3D"gmail_extra"><br class=3D"">It's because =
it's not really indirection, rather the content of the variable is =
evaluated:<br class=3D""><br class=3D"">$ foo=3D1+2;echo $((foo))<br =
class=3D"">3<br class=3D""><br class=3D""></div><div =
class=3D"gmail_extra">In the last case it evaluates the value of foo, =
123, and then increment the value of foo and foo becomes 124<br =
class=3D""></div><div class=3D"gmail_extra"><br class=3D""></div></div>
</div></blockquote></div><br class=3D""></body></html>=

--Apple-Mail=_C4F549B1-282B-4493-87F3-F205994DAE5C--


From MAILER-DAEMON Sun Apr 23 08:44:15 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2GsB-0000WN-6r
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 08:44:15 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48816)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d2Gs7-0000Uj-B3
	for bug-bash@gnu.org; Sun, 23 Apr 2017 08:44:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d2Gs6-0005aQ-DR
	for bug-bash@gnu.org; Sun, 23 Apr 2017 08:44:11 -0400
Received: from mail-qk0-x234.google.com ([2607:f8b0:400d:c09::234]:36601)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <pierre.gaston@gmail.com>)
	id 1d2Gs6-0005a6-6x
	for bug-bash@gnu.org; Sun, 23 Apr 2017 08:44:10 -0400
Received: by mail-qk0-x234.google.com with SMTP id u75so2383296qka.3
	for <bug-bash@gnu.org>; Sun, 23 Apr 2017 05:44:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=6dca8JmGSRqnCHnKYiXV9iS6CYnLhH12X5bBSLCfIwo=;
	b=l9DYt+woPjTlDiGzYfuHF2THoc8BV+pixH7TYmLv5TGH9Pqua4A8vsLje1U56CiZs3
	8gJc5SXqSObCsBIebHbwXd8JlpnoRnuSTXt2qpMg9qScPv7o5t2MX27H4pAoSb+H2j/T
	2rZhJwyGvAl3SbRUEvymho5AcodkyvQsc+Rwb2AV0HszkmYyZSUxMaLQp+8Fw4/PuvGq
	qwB948/G8NuAeRPG9L1BLRSo5ZGHeyJIy9OURU1a50cDUn3P88VppuLJ21/2MPioisrK
	Pi/ZLIt5ffye6wSk8EWQTylWnYzOhoXW+IFphDPVuf5at2TuwxVAe7cuir5GPLI1WQQy
	4Kng==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=6dca8JmGSRqnCHnKYiXV9iS6CYnLhH12X5bBSLCfIwo=;
	b=MpKkWfX2jSIMBVLk6prkSM1olysA/7kXPQLDPHafTcbw8u8r9RbQ/lFnsDHrfk4Mbc
	dgIYOwNdgrIDvqZ0n4ekm9KAqYHE7fpt+JQNLLkwrKPbMWaQkeAe0jko2nb2k1sbOd8k
	/cETG9vx/ZVkiudk19Ksc4t1DFCC+4q+Zjvul0YQoJeRGeG0hKxm5JjVMLNA+SPKg4+b
	RzfGWgjvXYfcuUs3s7E/mrxlLw6/BAJ5QRO0mWuiBZZBm4ORJkfdbTITwCqvkDfrL9xu
	6DB4R7uooCr9mJSU949oWmbvvnDmdqxt0DG2q2YU8Zsq2YOuo5Fz3gb5rB/B99rNxlUE
	xMMQ==
X-Gm-Message-State: AN3rC/4Thr/WPKH6zBlQc1uerNNbKYp+2bf+z/P4M4F4+F6NIYh01oIO
	IFCbLkGxzgIHVTXBbrXdOJBMijiLzA==
X-Received: by 10.55.23.84 with SMTP id i81mr1661276qkh.153.1492951449401;
	Sun, 23 Apr 2017 05:44:09 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.12.180.13 with HTTP; Sun, 23 Apr 2017 05:43:49 -0700 (PDT)
In-Reply-To: <7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Sun, 23 Apr 2017 15:43:49 +0300
Message-ID: <CAPSX3sQeGxmLmfmap-=C85K=7fHY4TSvkar1UNB3mpT3zbXsxw@mail.gmail.com>
Subject: Re: Curious case of arithmetic expansion
To: Florian Mayer <mayerflorian@me.com>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a1146fe62cf0977054dd4d876
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::234
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 12:44:12 -0000

--001a1146fe62cf0977054dd4d876
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sun, Apr 23, 2017 at 3:28 PM, Florian Mayer <mayerflorian@me.com> wrote:

> What I=E2=80=99m saying is, that if bash does recursively apply expansion
> mechanisms on the identifiers until it can retrieve a number,
> it should do it symmetrically. That is,
> it should remember what chain of expansion had been necessary for
> a particular number to appear at the end of the expansion.
>
> So instead of
> 124 moo 123
> The echo command should produce
> bar moo 124
>
> (The expansion chain here was foo->bar->moo->123)
>
> It's because it's not really indirection, rather the content of the
> variable is evaluated:
>
> No it is really indirection. Bash even has a special (and very limited)
> syntax for that.
> Consider
> $ foo=3Dbar; bar=3Dmoo
> You can get the string =E2=80=9Emoo=E2=80=9C through foo by using
> $ echo ${!foo}
>
> $ echo ${!!foo} # or something else does not work, though...
>
>
This is indirection indeed, but in arithmetic evaluation it's not.

Quoting the manual:

"The value of a variable is evaluated as an  arithmetic  expression
 when  it  is  referenced, or when a variable which has been given the
integer attribute using declare -i is assigned a value. "

Consider this:
foo=3D1+3
echo $foo
echo $((foo++))
echo $foo

--001a1146fe62cf0977054dd4d876
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Sun, Apr 23, 2017 at 3:28 PM, Florian Mayer <span dir=3D"ltr">&lt;<a=
 href=3D"mailto:mayerflorian@me.com" target=3D"_blank">mayerflorian@me.com<=
/a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">=
<div style=3D"overflow-wrap: break-word;"><div>What I=E2=80=99m saying is, =
that if bash does recursively apply expansion</div><div>mechanisms on the i=
dentifiers until it can retrieve a number,=C2=A0</div><div>it should do it =
symmetrically. That is,</div><div>it should remember what chain of expansio=
n had been necessary for</div><div>a particular number to appear at the end=
 of the expansion.</div><div><br></div><div>So instead of=C2=A0</div><div>1=
24 moo 123</div><div>The echo command should produce</div><div>bar moo 124<=
/div><div><br></div><div>(The expansion chain here was foo-&gt;bar-&gt;moo-=
&gt;123)</div><div><br></div><div><span class=3D"gmail-"><blockquote type=
=3D"cite"><div dir=3D"ltr"><div class=3D"gmail_extra">It&#39;s because it&#=
39;s not really indirection, rather the content of the variable is evaluate=
d:<br></div></div></blockquote></span>No it is really indirection. Bash eve=
n has a special (and very limited) syntax for that.</div><div>Consider=C2=
=A0</div><div>$ foo=3Dbar; bar=3Dmoo</div><div>You can get the string =E2=
=80=9Emoo=E2=80=9C through foo by using</div><div>$ echo ${!foo}</div><div>=
<br></div><div>$ echo ${!!foo} # or something else does not work, though...=
</div><span class=3D"gmail-"><div><br></div></span></div></blockquote><div>=
=C2=A0</div></div>This is indirection indeed, but in arithmetic evaluation =
it&#39;s not.<br><br>Quoting the manual:<br><br>&quot;The value of a variab=
le is evaluated as an=C2=A0 arithmetic=C2=A0 expression<br>=C2=A0when=C2=A0=
 it=C2=A0 is=C2=A0 referenced, or when a variable which has been given the =
integer attribute using declare -i is assigned a value. &quot;<br><br></div=
><div class=3D"gmail_extra">Consider this:<br></div><div class=3D"gmail_ext=
ra">foo=3D1+3<br></div><div class=3D"gmail_extra">echo $foo<br></div><div c=
lass=3D"gmail_extra">echo $((foo++))<br></div><div class=3D"gmail_extra">ec=
ho $foo<br></div><div class=3D"gmail_extra"><br></div></div>

--001a1146fe62cf0977054dd4d876--


From MAILER-DAEMON Sun Apr 23 09:07:35 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2HEl-0002hs-29
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 09:07:35 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51521)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2HEg-0002hh-8D
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:07:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2HEd-00064I-5x
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:07:30 -0400
Received: from pv35p18im-ztdg05091101.me.com ([17.133.188.43]:23289)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d2HEc-00064E-Qh
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:07:27 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05091101.me.com by
	pv35p18im-ztdg05091101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OOV00E005PE9S00@pv35p18im-ztdg05091101.me.com> for
	bug-bash@gnu.org; Sun, 23 Apr 2017 13:07:25 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1492952845; bh=gx+emd7GvKxBQsiJrapD0Ez6iG6q3qVgZeY1cf95Xws=;
	h=From:Content-type:Message-id:MIME-version:Subject:Date:To;
	b=pYuXHaKiPULLebK7SfMQlVb+r/AZ0z4ahH2tZ0v3YRbATBbixrHvcEU/KDzOUpz86
	nWo/8pd4kiNpyFDnznIJ61fYPUyADHYdQOCm7S2kZnQDw3YJwo2DDh0WeH8FkCjIak
	QXbfdBbZJi/EH+8emILhYBdOBLLSB/VRJ9tvcWfBUYeZOm0Tt1lIEpVSLzw0hMzENi
	M2hTvIHkFCBOHuFBDIxR26BqnVdHHmt0e01Zm485RUkp8juxOg2zKoFILIlzmNHcoD
	BvuLD6Oa8WXpkUM2exGkX7a/utXOSkWeJ7J9PXHFsconmhRPKwhRux7g5edoJrWRXm
	9drsdXSnkWGYA==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05091101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OOV0044B5S8D610@pv35p18im-ztdg05091101.me.com>; Sun,
	23 Apr 2017 13:07:24 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-23_12:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704230240
From: Florian Mayer <mayerflorian@me.com>
Content-type: multipart/alternative;
	boundary="Apple-Mail=_89B512BC-5B8B-42B4-A46D-40E5B31B355C"
Message-id: <78F6ACCF-B5F4-4BAF-9921-99D36BF043D2@me.com>
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
Subject: Re: Curious case of arithmetic expansion
Date: Sun, 23 Apr 2017 15:07:20 +0200
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<CAPSX3sQeGxmLmfmap-=C85K=7fHY4TSvkar1UNB3mpT3zbXsxw@mail.gmail.com>
To: Pierre Gaston <pierre.gaston@gmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
In-reply-to: <CAPSX3sQeGxmLmfmap-=C85K=7fHY4TSvkar1UNB3mpT3zbXsxw@mail.gmail.com>
X-Mailer: Apple Mail (2.3124)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.43
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 13:07:31 -0000


--Apple-Mail=_89B512BC-5B8B-42B4-A46D-40E5B31B355C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

It does not matter, how this construct in this particular context is =
called.
The difference between $(()) and (()) is that $(()) actually expands to =
something
whereas (()) just executes a C-like expression. In ((<expression>)) =
<expression> can also
include assignments, as the bash manual that you properly cited, also =
elaborates on.
You can do, for example, things like
$ foo=3D2
$ ((foo+=3D100)) # fo is now 102
$ ((++(foo++)))
or even
$ ((foo++, foo++, foo++, foo++, foo+=3D100))
and (oh boy why) even
$ foo=3D(123 321)
$ ((foo[0]++, foo[1]=E2=80=94))

So I might have chosen the wrong subject text for this mail,
but again, it does not matter whether those constructs actually expand =
to some string
or not. The side effects are what matter here. And in my opinion those =
are not correct...

> Am 23.04.2017 um 14:43 schrieb Pierre Gaston =
<pierre.gaston@gmail.com>:
>=20
>=20
>=20
> On Sun, Apr 23, 2017 at 3:28 PM, Florian Mayer <mayerflorian@me.com =
<mailto:mayerflorian@me.com>> wrote:
> What I=E2=80=99m saying is, that if bash does recursively apply =
expansion
> mechanisms on the identifiers until it can retrieve a number,=20
> it should do it symmetrically. That is,
> it should remember what chain of expansion had been necessary for
> a particular number to appear at the end of the expansion.
>=20
> So instead of=20
> 124 moo 123
> The echo command should produce
> bar moo 124
>=20
> (The expansion chain here was foo->bar->moo->123)
>=20
>> It's because it's not really indirection, rather the content of the =
variable is evaluated:
> No it is really indirection. Bash even has a special (and very =
limited) syntax for that.
> Consider=20
> $ foo=3Dbar; bar=3Dmoo
> You can get the string =E2=80=9Emoo=E2=80=9C through foo by using
> $ echo ${!foo}
>=20
> $ echo ${!!foo} # or something else does not work, though...
>=20
> =20
> This is indirection indeed, but in arithmetic evaluation it's not.
>=20
> Quoting the manual:
>=20
> "The value of a variable is evaluated as an  arithmetic  expression
>  when  it  is  referenced, or when a variable which has been given the =
integer attribute using declare -i is assigned a value. "
>=20
> Consider this:
> foo=3D1+3
> echo $foo
> echo $((foo++))
> echo $foo
>=20


--Apple-Mail=_89B512BC-5B8B-42B4-A46D-40E5B31B355C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D""><div class=3D"">It does not matter, how this construct in =
this particular context is called.</div><div class=3D"">The difference =
between $(()) and (()) is that $(()) actually expands to =
something</div><div class=3D"">whereas (()) just executes a C-like =
expression. In ((&lt;expression&gt;)) &lt;expression&gt; can =
also</div><div class=3D"">include assignments, as the bash manual that =
you properly cited, also elaborates on.</div><div class=3D"">You can do, =
for example, things like</div><div class=3D"">$ foo=3D2</div><div =
class=3D"">$ ((foo+=3D100)) # fo is now 102</div><div class=3D"">$ =
((++(foo++)))</div><div class=3D"">or even</div><div class=3D"">$ =
((foo++, foo++, foo++, foo++, foo+=3D100))</div><div class=3D"">and (oh =
boy why) even</div><div class=3D"">$ foo=3D(123 321)</div><div =
class=3D"">$ ((foo[0]++, foo[1]=E2=80=94))</div><div class=3D""><br =
class=3D""></div><div class=3D"">So I might have chosen the wrong =
subject text for this mail,</div><div class=3D"">but again, it does not =
matter whether those constructs actually <i class=3D"">expand</i>&nbsp;to =
some string</div><div class=3D"">or not. The side effects are what =
matter here. And in my opinion those are not correct...</div><br =
class=3D""><div><blockquote type=3D"cite" class=3D""><div class=3D"">Am =
23.04.2017 um 14:43 schrieb Pierre Gaston &lt;<a =
href=3D"mailto:pierre.gaston@gmail.com" =
class=3D"">pierre.gaston@gmail.com</a>&gt;:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" =
class=3D""><br class=3D""><div class=3D"gmail_extra"><br class=3D""><div =
class=3D"gmail_quote">On Sun, Apr 23, 2017 at 3:28 PM, Florian Mayer =
<span dir=3D"ltr" class=3D"">&lt;<a href=3D"mailto:mayerflorian@me.com" =
target=3D"_blank" class=3D"">mayerflorian@me.com</a>&gt;</span> =
wrote:<br class=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex"><div style=3D"overflow-wrap: =
break-word;" class=3D""><div class=3D"">What I=E2=80=99m saying is, that =
if bash does recursively apply expansion</div><div class=3D"">mechanisms =
on the identifiers until it can retrieve a number,&nbsp;</div><div =
class=3D"">it should do it symmetrically. That is,</div><div class=3D"">it=
 should remember what chain of expansion had been necessary =
for</div><div class=3D"">a particular number to appear at the end of the =
expansion.</div><div class=3D""><br class=3D""></div><div class=3D"">So =
instead of&nbsp;</div><div class=3D"">124 moo 123</div><div class=3D"">The=
 echo command should produce</div><div class=3D"">bar moo 124</div><div =
class=3D""><br class=3D""></div><div class=3D"">(The expansion chain =
here was foo-&gt;bar-&gt;moo-&gt;123)</div><div class=3D""><br =
class=3D""></div><div class=3D""><span class=3D"gmail-"><blockquote =
type=3D"cite" class=3D""><div dir=3D"ltr" class=3D""><div =
class=3D"gmail_extra">It's because it's not really indirection, rather =
the content of the variable is evaluated:<br =
class=3D""></div></div></blockquote></span>No it is really indirection. =
Bash even has a special (and very limited) syntax for that.</div><div =
class=3D"">Consider&nbsp;</div><div class=3D"">$ foo=3Dbar; =
bar=3Dmoo</div><div class=3D"">You can get the string =E2=80=9Emoo=E2=80=9C=
 through foo by using</div><div class=3D"">$ echo ${!foo}</div><div =
class=3D""><br class=3D""></div><div class=3D"">$ echo ${!!foo} # or =
something else does not work, though...</div><span class=3D"gmail-"><div =
class=3D""><br class=3D""></div></span></div></blockquote><div =
class=3D"">&nbsp;</div></div>This is indirection indeed, but in =
arithmetic evaluation it's not.<br class=3D""><br class=3D"">Quoting the =
manual:<br class=3D""><br class=3D"">"The value of a variable is =
evaluated as an&nbsp; arithmetic&nbsp; expression<br =
class=3D"">&nbsp;when&nbsp; it&nbsp; is&nbsp; referenced, or when a =
variable which has been given the integer attribute using declare -i is =
assigned a value. "<br class=3D""><br class=3D""></div><div =
class=3D"gmail_extra">Consider this:<br class=3D""></div><div =
class=3D"gmail_extra">foo=3D1+3<br class=3D""></div><div =
class=3D"gmail_extra">echo $foo<br class=3D""></div><div =
class=3D"gmail_extra">echo $((foo++))<br class=3D""></div><div =
class=3D"gmail_extra">echo $foo<br class=3D""></div><div =
class=3D"gmail_extra"><br class=3D""></div></div>
</div></blockquote></div><br class=3D""></body></html>=

--Apple-Mail=_89B512BC-5B8B-42B4-A46D-40E5B31B355C--


From MAILER-DAEMON Sun Apr 23 09:16:03 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2HMx-0003Hw-5D
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 09:16:03 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52469)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2HMu-0003Ho-1h
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:16:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2HMq-0007T7-R0
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:16:00 -0400
Received: from pv35p18im-ztdg05091101.me.com ([17.133.188.43]:44489)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d2HMq-0007Sy-HM
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:15:56 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05091101.me.com by
	pv35p18im-ztdg05091101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OOV00H005WK6W00@pv35p18im-ztdg05091101.me.com> for
	bug-bash@gnu.org; Sun, 23 Apr 2017 13:15:55 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1492953355; bh=TYSLxtd7O+cOjiO+ZYrb83FIgAJZ2/ysfKhppZZwOic=;
	h=Date:From:Subject:To:Message-id:MIME-version:Content-type;
	b=pPUlXSFtiKsv29LBSX/brtvS6mVAJVAqFdr77j2dSCswmAmikYInzDOFGjgEnbbqt
	cSd6jABfwmXWA9C7W1vxzd/PFkQV6pO3pZDYrSKLlaji+Q/E9f2nkr/1yGOhAo1TkQ
	HGKlAhvLr4qzUpqppaagTLa/6tx6LsATK7gUbQQOtoGNNQ+iYtGLpjda3ug66JkXmx
	5zMNJ770UXNwkKJ5sf6b399dYchjgolh2yWLWt0ewf5VNs1PLYTIwTS8NJv+GpAL1z
	l9jN7Qm/Woq6q1lVh0WgnRSiydHKix3Eup3jLqbmD/SkUdip3OZgK98uU4KMgHfs3g
	xATAsmGfps2Hg==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05091101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OOV00D005MF6200@pv35p18im-ztdg05091101.me.com>; Sun,
	23 Apr 2017 13:15:55 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-23_12:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704230243
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05091101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OOV00LG165RDI20@pv35p18im-ztdg05091101.me.com>; Sun,
	23 Apr 2017 13:15:40 +0000 (GMT)
Date: Sun, 23 Apr 2017 15:15:26 +0200
From: Florian Mayer <mayerflorian@me.com>
Subject: Re: Curious case of arithmetic expansion
In-reply-to: <78F6ACCF-B5F4-4BAF-9921-99D36BF043D2@me.com>
To: Pierre Gaston <pierre.gaston@gmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
Message-id: <678422CF-B4B2-4FBA-8041-6B05BF518442@me.com>
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
X-Mailer: Apple Mail (2.3124)
Content-type: multipart/alternative;
	boundary="Apple-Mail=_2A585405-C3B9-4F3A-A877-548D4FDC9F65"
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<CAPSX3sQeGxmLmfmap-=C85K=7fHY4TSvkar1UNB3mpT3zbXsxw@mail.gmail.com>
	<78F6ACCF-B5F4-4BAF-9921-99D36BF043D2@me.com>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.43
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 13:16:01 -0000


--Apple-Mail=_2A585405-C3B9-4F3A-A877-548D4FDC9F65
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

> And in my opinion those are not correct...


So in a scenario like the mentioned
$ foo=3Dbar; bar=3Dmoo; moo=3D123
the line
$ ((foo++)); echo $foo $bar $moo
should actually evaluate to
=E2=80=9Ebar moo 124=E2=80=9C

or at least say something like
=E2=80=9Eerror, can not execute side effects, because I=20
can=E2=80=99t keep track of what I expanded in order to get a number"

which it does not=E2=80=A6

I know that (()) probably was never intended for such a thing, but
it=E2=80=99d be a nice-to-have addition, while being certainly doable :)

> Am 23.04.2017 um 15:07 schrieb Florian Mayer <mayerflorian@me.com>:
>=20
> It does not matter, how this construct in this particular context is =
called.
> The difference between $(()) and (()) is that $(()) actually expands =
to something
> whereas (()) just executes a C-like expression. In ((<expression>)) =
<expression> can also
> include assignments, as the bash manual that you properly cited, also =
elaborates on.
> You can do, for example, things like
> $ foo=3D2
> $ ((foo+=3D100)) # fo is now 102
> $ ((++(foo++)))
> or even
> $ ((foo++, foo++, foo++, foo++, foo+=3D100))
> and (oh boy why) even
> $ foo=3D(123 321)
> $ ((foo[0]++, foo[1]=E2=80=94))
>=20
> So I might have chosen the wrong subject text for this mail,
> but again, it does not matter whether those constructs actually expand =
to some string
> or not. The side effects are what matter here. And in my opinion those =
are not correct...
>=20
>> Am 23.04.2017 um 14:43 schrieb Pierre Gaston <pierre.gaston@gmail.com =
<mailto:pierre.gaston@gmail.com>>:
>>=20
>>=20
>>=20
>> On Sun, Apr 23, 2017 at 3:28 PM, Florian Mayer <mayerflorian@me.com =
<mailto:mayerflorian@me.com>> wrote:
>> What I=E2=80=99m saying is, that if bash does recursively apply =
expansion
>> mechanisms on the identifiers until it can retrieve a number,=20
>> it should do it symmetrically. That is,
>> it should remember what chain of expansion had been necessary for
>> a particular number to appear at the end of the expansion.
>>=20
>> So instead of=20
>> 124 moo 123
>> The echo command should produce
>> bar moo 124
>>=20
>> (The expansion chain here was foo->bar->moo->123)
>>=20
>>> It's because it's not really indirection, rather the content of the =
variable is evaluated:
>> No it is really indirection. Bash even has a special (and very =
limited) syntax for that.
>> Consider=20
>> $ foo=3Dbar; bar=3Dmoo
>> You can get the string =E2=80=9Emoo=E2=80=9C through foo by using
>> $ echo ${!foo}
>>=20
>> $ echo ${!!foo} # or something else does not work, though...
>>=20
>> =20
>> This is indirection indeed, but in arithmetic evaluation it's not.
>>=20
>> Quoting the manual:
>>=20
>> "The value of a variable is evaluated as an  arithmetic  expression
>>  when  it  is  referenced, or when a variable which has been given =
the integer attribute using declare -i is assigned a value. "
>>=20
>> Consider this:
>> foo=3D1+3
>> echo $foo
>> echo $((foo++))
>> echo $foo
>>=20
>=20


--Apple-Mail=_2A585405-C3B9-4F3A-A877-548D4FDC9F65
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D""><div class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D"" style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space;"><div class=3D"">And in my =
opinion those are not correct...</div></div></blockquote></div><div =
class=3D""><br class=3D""></div><div class=3D"">So in a scenario like =
the mentioned</div><div class=3D"">$ foo=3Dbar; bar=3Dmoo; =
moo=3D123</div><div class=3D"">the line</div><div class=3D"">$ =
((foo++)); echo $foo $bar $moo</div><div class=3D"">should actually =
evaluate to</div><div class=3D"">=E2=80=9Ebar moo 124=E2=80=9C</div><div =
class=3D""><br class=3D""></div><div class=3D"">or at least say =
something like</div><div class=3D"">=E2=80=9Eerror, can not execute side =
effects, because I&nbsp;</div><div class=3D"">can=E2=80=99t keep track =
of what I expanded in order to get a number"</div><div class=3D""><br =
class=3D""></div><div class=3D"">which it does not=E2=80=A6</div><div =
class=3D""><br class=3D""></div><div class=3D"">I know that (()) =
probably was never intended for such a thing, but</div><div =
class=3D"">it=E2=80=99d be a nice-to-have addition, while being =
certainly doable :)</div><br class=3D""><div><blockquote type=3D"cite" =
class=3D""><div class=3D"">Am 23.04.2017 um 15:07 schrieb Florian Mayer =
&lt;<a href=3D"mailto:mayerflorian@me.com" =
class=3D"">mayerflorian@me.com</a>&gt;:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><meta =
http-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf-8" =
class=3D""><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: =
space; -webkit-line-break: after-white-space;" class=3D""><div =
class=3D"">It does not matter, how this construct in this particular =
context is called.</div><div class=3D"">The difference between $(()) and =
(()) is that $(()) actually expands to something</div><div =
class=3D"">whereas (()) just executes a C-like expression. In =
((&lt;expression&gt;)) &lt;expression&gt; can also</div><div =
class=3D"">include assignments, as the bash manual that you properly =
cited, also elaborates on.</div><div class=3D"">You can do, for example, =
things like</div><div class=3D"">$ foo=3D2</div><div class=3D"">$ =
((foo+=3D100)) # fo is now 102</div><div class=3D"">$ =
((++(foo++)))</div><div class=3D"">or even</div><div class=3D"">$ =
((foo++, foo++, foo++, foo++, foo+=3D100))</div><div class=3D"">and (oh =
boy why) even</div><div class=3D"">$ foo=3D(123 321)</div><div =
class=3D"">$ ((foo[0]++, foo[1]=E2=80=94))</div><div class=3D""><br =
class=3D""></div><div class=3D"">So I might have chosen the wrong =
subject text for this mail,</div><div class=3D"">but again, it does not =
matter whether those constructs actually <i class=3D"">expand</i>&nbsp;to =
some string</div><div class=3D"">or not. The side effects are what =
matter here. And in my opinion those are not correct...</div><br =
class=3D""><div class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D"">Am 23.04.2017 um 14:43 schrieb Pierre Gaston &lt;<a =
href=3D"mailto:pierre.gaston@gmail.com" =
class=3D"">pierre.gaston@gmail.com</a>&gt;:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" =
class=3D""><br class=3D""><div class=3D"gmail_extra"><br class=3D""><div =
class=3D"gmail_quote">On Sun, Apr 23, 2017 at 3:28 PM, Florian Mayer =
<span dir=3D"ltr" class=3D"">&lt;<a href=3D"mailto:mayerflorian@me.com" =
target=3D"_blank" class=3D"">mayerflorian@me.com</a>&gt;</span> =
wrote:<br class=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex"><div style=3D"overflow-wrap: =
break-word;" class=3D""><div class=3D"">What I=E2=80=99m saying is, that =
if bash does recursively apply expansion</div><div class=3D"">mechanisms =
on the identifiers until it can retrieve a number,&nbsp;</div><div =
class=3D"">it should do it symmetrically. That is,</div><div class=3D"">it=
 should remember what chain of expansion had been necessary =
for</div><div class=3D"">a particular number to appear at the end of the =
expansion.</div><div class=3D""><br class=3D""></div><div class=3D"">So =
instead of&nbsp;</div><div class=3D"">124 moo 123</div><div class=3D"">The=
 echo command should produce</div><div class=3D"">bar moo 124</div><div =
class=3D""><br class=3D""></div><div class=3D"">(The expansion chain =
here was foo-&gt;bar-&gt;moo-&gt;123)</div><div class=3D""><br =
class=3D""></div><div class=3D""><span class=3D"gmail-"><blockquote =
type=3D"cite" class=3D""><div dir=3D"ltr" class=3D""><div =
class=3D"gmail_extra">It's because it's not really indirection, rather =
the content of the variable is evaluated:<br =
class=3D""></div></div></blockquote></span>No it is really indirection. =
Bash even has a special (and very limited) syntax for that.</div><div =
class=3D"">Consider&nbsp;</div><div class=3D"">$ foo=3Dbar; =
bar=3Dmoo</div><div class=3D"">You can get the string =E2=80=9Emoo=E2=80=9C=
 through foo by using</div><div class=3D"">$ echo ${!foo}</div><div =
class=3D""><br class=3D""></div><div class=3D"">$ echo ${!!foo} # or =
something else does not work, though...</div><span class=3D"gmail-"><div =
class=3D""><br class=3D""></div></span></div></blockquote><div =
class=3D"">&nbsp;</div></div>This is indirection indeed, but in =
arithmetic evaluation it's not.<br class=3D""><br class=3D"">Quoting the =
manual:<br class=3D""><br class=3D"">"The value of a variable is =
evaluated as an&nbsp; arithmetic&nbsp; expression<br =
class=3D"">&nbsp;when&nbsp; it&nbsp; is&nbsp; referenced, or when a =
variable which has been given the integer attribute using declare -i is =
assigned a value. "<br class=3D""><br class=3D""></div><div =
class=3D"gmail_extra">Consider this:<br class=3D""></div><div =
class=3D"gmail_extra">foo=3D1+3<br class=3D""></div><div =
class=3D"gmail_extra">echo $foo<br class=3D""></div><div =
class=3D"gmail_extra">echo $((foo++))<br class=3D""></div><div =
class=3D"gmail_extra">echo $foo<br class=3D""></div><div =
class=3D"gmail_extra"><br class=3D""></div></div>
</div></blockquote></div><br class=3D""></div></div></blockquote></div><br=
 class=3D""></body></html>=

--Apple-Mail=_2A585405-C3B9-4F3A-A877-548D4FDC9F65--


From MAILER-DAEMON Sun Apr 23 09:20:17 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2HR3-0003ij-Lk
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 09:20:17 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53530)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d2HR0-0003ic-Tv
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:20:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d2HQz-0000Ca-OK
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:20:14 -0400
Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:33065)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <pierre.gaston@gmail.com>)
	id 1d2HQz-0000CU-IR
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:20:13 -0400
Received: by mail-qk0-x22c.google.com with SMTP id h123so14339702qke.0
	for <bug-bash@gnu.org>; Sun, 23 Apr 2017 06:20:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=DFTsffTJMci0Hr6eBuW2cyKrBBnqhYHm61k4iJ2z7qQ=;
	b=ijI76r+UPt1PfG8CKF9BW6JEjxJxHeFgzRVdKX9yIMZQnfct4xoOWhky/V1vHV2qXe
	no98yiP+EzgwXmkIKVO8cNO9oziWKDyaglhW6MyzjuL/U1SKNQCnHAPTkpf1wsxgaba/
	CMLXHXQBPJJQ7E9uRo2eLqQYU1FGSLvLVAnkY9sT9a3bCuUf7N8wrN99uJOUwuOblGvc
	bDqwrri6yUB6KuvyEC/Vz7g9j/gsGr1gzJW40fpj5p6eJZN1JtPZ59iNlFdhBtHchQsa
	GUhXcZANi8emi5d3ufCBnwdZ9ZTZ7bz0JzqUm43vQ+VS5xbRw1UsC4hLSJjhyEAOWsfA
	NR3A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=DFTsffTJMci0Hr6eBuW2cyKrBBnqhYHm61k4iJ2z7qQ=;
	b=Zn00UbO6Ud5NRNpcQ3aKjRAH1pIAUTKEiL08SHVEU0qr5Qkv3s+xxoq3G/BBBIjMNK
	QPPdiz7WlmgW9G4vHqnAwYaaC+FHu1DqrGmUfCDqASMVL0yPtufbvihLx+nyACPf3Mwz
	qsUr60wd39flGBjjJqPROovqMhAyY2zqHztt3Y4cCmbwSGAcBdWETyvTWHM0o1+YH2Q7
	2xVWbjSDF6QoZBu1xlShoC/EC0r4me9g4iT1G4jARtywWRhV0VnF9hqK3bIMDWK+lUGx
	6Cw/jAocn2GhP6D07aj77qDJrZawM2NEWCiOLL5VMgJeHrqszc/DiXI36Yg+vqdOu9e1
	N5lg==
X-Gm-Message-State: AN3rC/61Nf9mV2RQkOgmEcfpT9j74/smPwqMlitgXHUQdKWkkkQvY4h0
	Wy+WAa/4Vj4BQlPKa0m26GyIycKEtQ==
X-Received: by 10.55.12.213 with SMTP id 204mr19757496qkm.233.1492953613041;
	Sun, 23 Apr 2017 06:20:13 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.12.180.13 with HTTP; Sun, 23 Apr 2017 06:19:52 -0700 (PDT)
In-Reply-To: <78F6ACCF-B5F4-4BAF-9921-99D36BF043D2@me.com>
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<CAPSX3sQeGxmLmfmap-=C85K=7fHY4TSvkar1UNB3mpT3zbXsxw@mail.gmail.com>
	<78F6ACCF-B5F4-4BAF-9921-99D36BF043D2@me.com>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Sun, 23 Apr 2017 16:19:52 +0300
Message-ID: <CAPSX3sT_Fm9tj4j2SGmQGyZbxKf097hBixV=Zzi=4kyh7FHw=A@mail.gmail.com>
Subject: Re: Curious case of arithmetic expansion
To: Florian Mayer <mayerflorian@me.com>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a114d7a2cc58578054dd55921
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::22c
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 13:20:16 -0000

--001a114d7a2cc58578054dd55921
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sun, Apr 23, 2017 at 4:07 PM, Florian Mayer <mayerflorian@me.com> wrote:

> It does not matter, how this construct in this particular context is
> called.
> The difference between $(()) and (()) is that $(()) actually expands to
> something
> whereas (()) just executes a C-like expression. In ((<expression>))
> <expression> can also
> include assignments, as the bash manual that you properly cited, also
> elaborates on.
> You can do, for example, things like
> $ foo=3D2
> $ ((foo+=3D100)) # fo is now 102
> $ ((++(foo++)))
> or even
> $ ((foo++, foo++, foo++, foo++, foo+=3D100))
> and (oh boy why) even
> $ foo=3D(123 321)
> $ ((foo[0]++, foo[1]=E2=80=94))
>
> So I might have chosen the wrong subject text for this mail,
> but again, it does not matter whether those constructs actually *expand* =
to
> some string
> or not. The side effects are what matter here. And in my opinion those ar=
e
> not correct...
>

I understand what you want, I'm just explaining the result you get
and why it doesn't do what you want.
As it is, a variable can contain the name of another variable
but it can also contain any arbitrary string that is a correct arithmetic
expression.

So if you have:

foo=3Dbar+14+baz
baz=3D'moo*2'
moo=3D1

what shoud echo $((foo++)) do?

Your case is only really a special case, arguably having only indirection
instead of what we have
would perhaps have been a better idea, but it is this way for so long that
I doubt it will change.

PS: you can perhaps use name reference instead
moo=3D1;
declare -n foo=3Dbar bar=3Dmoo
echo $((foo++))
echo $moo

--001a114d7a2cc58578054dd55921
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Sun, Apr 23, 2017 at 4:07 PM, Florian Mayer <span dir=3D"ltr">&lt;<a=
 href=3D"mailto:mayerflorian@me.com" target=3D"_blank">mayerflorian@me.com<=
/a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">=
<div style=3D"overflow-wrap: break-word;"><div>It does not matter, how this=
 construct in this particular context is called.</div><div>The difference b=
etween $(()) and (()) is that $(()) actually expands to something</div><div=
>whereas (()) just executes a C-like expression. In ((&lt;expression&gt;)) =
&lt;expression&gt; can also</div><div>include assignments, as the bash manu=
al that you properly cited, also elaborates on.</div><div>You can do, for e=
xample, things like</div><div>$ foo=3D2</div><div>$ ((foo+=3D100)) # fo is =
now 102</div><div>$ ((++(foo++)))</div><div>or even</div><div>$ ((foo++, fo=
o++, foo++, foo++, foo+=3D100))</div><div>and (oh boy why) even</div><div>$=
 foo=3D(123 321)</div><div>$ ((foo[0]++, foo[1]=E2=80=94))</div><div><br></=
div><div>So I might have chosen the wrong subject text for this mail,</div>=
<div>but again, it does not matter whether those constructs actually <i>exp=
and</i>=C2=A0to some string</div><div>or not. The side effects are what mat=
ter here. And in my opinion those are not correct...</div></div></blockquot=
e><div><br>I understand what you want, I&#39;m just explaining the result y=
ou get <br>and why it doesn&#39;t do what you want.<br>As it is, a variable=
 can contain the name of another variable <br>but it can also contain any a=
rbitrary string that is a correct arithmetic expression.<br><br></div><div>=
So if you have: <br><br>foo=3Dbar+14+baz <br>baz=3D&#39;moo*2&#39;<br></div=
><div>moo=3D1<br><br></div><div>what shoud echo $((foo++)) do?<br></div><di=
v><br></div><div>Your case is only really a special case, arguably having o=
nly indirection instead of what we have <br>would perhaps have been a bette=
r idea, but it is this way for so long that I doubt it will change.<br><br>=
</div><div>PS: you can perhaps use name reference instead <br>moo=3D1;<br>d=
eclare -n foo=3Dbar bar=3Dmoo<br></div><div>echo $((foo++))<br></div><div>e=
cho $moo<br></div><div><br></div><div><br></div></div></div></div>

--001a114d7a2cc58578054dd55921--


From MAILER-DAEMON Sun Apr 23 09:26:21 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2HWv-0004IY-JE
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 09:26:21 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48902)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <sirjaren@gmail.com>) id 1d2AVF-0005sp-Io
	for bug-bash@gnu.org; Sun, 23 Apr 2017 01:56:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <sirjaren@gmail.com>) id 1d2AVE-0007TN-DL
	for bug-bash@gnu.org; Sun, 23 Apr 2017 01:56:09 -0400
Received: from mail-qk0-x22f.google.com ([2607:f8b0:400d:c09::22f]:34639)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <sirjaren@gmail.com>) id 1d2AVE-0007T2-7a
	for bug-bash@gnu.org; Sun, 23 Apr 2017 01:56:08 -0400
Received: by mail-qk0-x22f.google.com with SMTP id y63so67389095qkd.1
	for <bug-bash@gnu.org>; Sat, 22 Apr 2017 22:56:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=oi1Oqic2Kc3HQRQEvUqbX4NPCe5IyaQvkDZt2goIEEU=;
	b=fDuV/FOo5TFAdbZ4p0K9REc8JhkNTZyy3BtEsSYrojtyB2XV634+aG0i5LoVNTE87O
	nFHXZ+a6LH35hhnsYm4YoDkFBNWEQKvao9lRYDOts8p5frfptkII0XCiFf4USIaaU8sL
	730tomx07V5yaoRV/ZcJUuLZkauYkvhjJaaDj6EFLyTAOYpCVALewYxj9evE5wlFUoM2
	+/Qy0krZLA3CdgIqrxiGaEEctgoFsnvqM5WPReH38hrnQM3tEH2flcoTn/oPQorAGvjY
	FoFKFyLH8U8dVSfgHpag/8Ypqon2joQVGK0JfKCT3YWdJjVAb1iDduxeJQJzA6F+dEtN
	8zyw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=oi1Oqic2Kc3HQRQEvUqbX4NPCe5IyaQvkDZt2goIEEU=;
	b=c67U5NchOVdm7V3vIaKWpi0EdHaqkwKH4JQzQ5iL+ZmOF3Iq+dY9Z8tLo/uzZWJR+9
	WDo1u6SiBNPz8bbN/+Bh48eJmIyLvCTeF6XnfLS54jCtgzNUcyDEboUtwuTAWKrqIXoh
	TVmyUN1gV/K0dDif7uzkVt8JDy9aAcosM2PxkNsFlUUE7PLBkQiL018VsC6jhYK0UL8t
	J6W1xLlek/XNoPeviUt9MoeMukUU0KuXU5yAmVNlsgFrO3Yeisb1qeT8h10ybSHvtCSr
	z8Cm4EflzCB86qFftwW0c+oX/oH926fMAtA7VbyeyDlHaxgWVcxgD/N14OpX+7DHZ+gI
	YWMg==
X-Gm-Message-State: AN3rC/4diKStyMF7ax5lWKwUEsWfuxwA1jxxVpuD2OTjkka+Selj8UWY
	qSpNU1cKNhhTMLW9ehOutNC+Fvb9K8w4
X-Received: by 10.233.216.65 with SMTP id u62mr21362886qkf.234.1492926967095; 
	Sat, 22 Apr 2017 22:56:07 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.237.61.149 with HTTP; Sat, 22 Apr 2017 22:56:06 -0700 (PDT)
From: Jaren Stangret <sirjaren@gmail.com>
Date: Sun, 23 Apr 2017 00:56:06 -0500
Message-ID: <CAFtNJsFiUKA1svWjkXDVvh7OWb+b71cJo7QGNxxvh6VwqoEDsg@mail.gmail.com>
Subject: Segfault when unsetting READLINE_LINE inside 'bind -x'
To: bug-bash@gnu.org
Content-Type: multipart/alternative; boundary=94eb2c043cc68ca616054dcf2553
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::22f
X-Mailman-Approved-At: Sun, 23 Apr 2017 09:26:21 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 05:56:10 -0000

--94eb2c043cc68ca616054dcf2553
Content-Type: text/plain; charset=UTF-8

Hello,

Instead of segfaulting, BASH should ensure READELINE_LINE is unset or set
and empty.

*Configuration Information:*
Machine: x86_64
OS: linux-gnu
Compiler: x86_64-pc-linux-gnu-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H   -I. -I./include -I. -I./include -I./lib
 -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/lo
+cal/bin:/usr/sbin:/usr/bin:/sbin:/bin'
-DSTANDARD_UTILS_PATH='/bin:/usr/bin:/sbin:/usr/sbin'
-DSYS_BASHRC='/etc/bash/bashrc' -DSYS_BASH_LOGOUT='/etc/bash/bash_logout'
-DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC -march=core-avx2 -O3
-pipe -fomit-frame-pointer -mabm -floop-interchange -ftree-loop-di
+stribution -floop-strip-mine -floop-block -flto=16 -fuse-linker-plugin
-fopenmp -fno-lto -fno-use-linker-plugin -Wno-parentheses
-Wno-format-security
uname output: Linux client 4.10.8-gentoo #1 SMP Fri Mar 31 19:12:26 CDT
2017 x86_64 Intel(R) Core(TM) i7-5960X CPU @ 3.00GHz GenuineIntel GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: release

*Description:*
  Unsetting READLINE_LINE in a 'bind -x' causes segmentation fault.

*Repeat-By:*

# New shell
bash --norc --noprofile

# Can be done any emacs or vi mode
bind -x '"\C-m": unset -v READLINE_LINE'

# User hits ctrl+m
Segmentation Fault

--94eb2c043cc68ca616054dcf2553
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hello,</div><div><br></div><div>Instead of segfaultin=
g, BASH should ensure READELINE_LINE is unset or set and empty.</div><div><=
b><br></b></div><div><b>Configuration Information:</b></div><div>Machine: x=
86_64</div><div>OS: linux-gnu</div><div>Compiler: x86_64-pc-linux-gnu-gcc</=
div><div>Compilation CFLAGS: =C2=A0-DPROGRAM=3D&#39;bash&#39; -DCONF_HOSTTY=
PE=3D&#39;x86_64&#39; -DCONF_OSTYPE=3D&#39;linux-gnu&#39; -DCONF_MACHTYPE=
=3D&#39;x86_64-pc-linux-gnu&#39; -DCONF_VENDOR=3D&#39;pc&#39; -DLOCALEDIR=
=3D&#39;/usr/share/locale&#39; -DPACKAGE=3D&#39;bash&#39; -DSHELL -DHAVE_CO=
NFIG_H =C2=A0 -I. -I./include -I. -I./include -I./lib =C2=A0-DDEFAULT_PATH_=
VALUE=3D&#39;/usr/local/sbin:/usr/lo +cal/bin:/usr/sbin:/usr/bin:/sbin:/bin=
&#39; -DSTANDARD_UTILS_PATH=3D&#39;/bin:/usr/bin:/sbin:/usr/sbin&#39; -DSYS=
_BASHRC=3D&#39;/etc/bash/bashrc&#39; -DSYS_BASH_LOGOUT=3D&#39;/etc/bash/bas=
h_logout&#39; -DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC -march=3Dc=
ore-avx2 -O3 -pipe -fomit-frame-pointer -mabm -floop-interchange -ftree-loo=
p-di +stribution -floop-strip-mine -floop-block -flto=3D16 -fuse-linker-plu=
gin -fopenmp -fno-lto -fno-use-linker-plugin -Wno-parentheses -Wno-format-s=
ecurity</div><div>uname output: Linux client 4.10.8-gentoo #1 SMP Fri Mar 3=
1 19:12:26 CDT 2017 x86_64 Intel(R) Core(TM) i7-5960X CPU @ 3.00GHz Genuine=
Intel GNU/Linux</div><div>Machine Type: x86_64-pc-linux-gnu</div><div><br><=
/div><div>Bash Version: 4.4</div><div>Patch Level: 12</div><div>Release Sta=
tus: release</div><div><br></div><div><b>Description:</b></div><div>=C2=A0 =
Unsetting READLINE_LINE in a &#39;bind -x&#39; causes segmentation fault.</=
div><div><br></div><div><b>Repeat-By:</b></div><div><font face=3D"monospace=
, monospace"><br></font></div><div><font face=3D"monospace, monospace"># Ne=
w shell</font></div><div><font face=3D"monospace, monospace">bash --norc --=
noprofile</font></div><div><font face=3D"monospace, monospace"><br></font><=
/div><div><font face=3D"monospace, monospace"># Can be done any emacs or vi=
 mode</font></div><div><font face=3D"monospace, monospace">bind -x &#39;&qu=
ot;\C-m&quot;: unset -v READLINE_LINE&#39;</font></div><div><font face=3D"m=
onospace, monospace"><br></font></div><div><font face=3D"monospace, monospa=
ce"># User hits ctrl+m</font></div><div><font face=3D"monospace, monospace"=
>Segmentation Fault</font></div></div>

--94eb2c043cc68ca616054dcf2553--


From MAILER-DAEMON Sun Apr 23 09:50:27 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2HuF-0000oO-JA
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 09:50:27 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58568)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2HuC-0000oI-05
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:50:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2Hu7-0000pq-Ey
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:50:24 -0400
Received: from pv35p18im-ztdg05091101.me.com ([17.133.188.43]:35695)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d2Hu7-0000pe-1j
	for bug-bash@gnu.org; Sun, 23 Apr 2017 09:50:19 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05091101.me.com by
	pv35p18im-ztdg05091101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OOV00G007DM0H00@pv35p18im-ztdg05091101.me.com> for
	bug-bash@gnu.org; Sun, 23 Apr 2017 13:50:17 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1492955417; bh=qh52f6xt+DxXHK8Ud5khBO56Q5lW75TP4/kOh81msxo=;
	h=From:Content-type:Message-id:MIME-version:Subject:Date:To;
	b=b472NWHiHGiSNW/q28Kd/PJpt+21HF67CKoF0T5ffMN66LqDbMA+Ow9im9zSKp0XP
	bMnOU/tQMRez6qND+nM+baGd8DfaDUD3Jwq2TEhcSTaNqp05G9pAhoGO9x4h5bOLE1
	Wfr7Fk6/DyhZTpgqCcfBpGWzyVjWvgDW2sTD1cBqfSHdBraoEwxbdmKtcu1kUMeNvG
	S0gLnCpTsjV6hFOqRIfdYKeV7lSaFAE4gDsYX7LnM11soT/9RLaw7UsFDGb1dXa1dL
	7oYRIrsWxSKe88JTgXzZJvGGsxBfiLJyp88rA+YYHJ18Nusq9bgISJ8VgyzW75su9S
	95jHuHdfdLKng==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05091101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OOV00GND7RPGZ00@pv35p18im-ztdg05091101.me.com>; Sun,
	23 Apr 2017 13:50:17 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-23_12:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704230252
From: Florian Mayer <mayerflorian@me.com>
Content-type: multipart/alternative;
	boundary="Apple-Mail=_492A58DC-3B5A-4790-859B-25E603A70E0E"
Message-id: <A915A81C-66B1-4DE8-B5C4-DCFE6F6C7657@me.com>
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
Subject: Re: Curious case of arithmetic expansion
Date: Sun, 23 Apr 2017 15:50:13 +0200
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<CAPSX3sQeGxmLmfmap-=C85K=7fHY4TSvkar1UNB3mpT3zbXsxw@mail.gmail.com>
	<78F6ACCF-B5F4-4BAF-9921-99D36BF043D2@me.com>
	<CAPSX3sT_Fm9tj4j2SGmQGyZbxKf097hBixV=Zzi=4kyh7FHw=A@mail.gmail.com>
To: Pierre Gaston <pierre.gaston@gmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
In-reply-to: <CAPSX3sT_Fm9tj4j2SGmQGyZbxKf097hBixV=Zzi=4kyh7FHw=A@mail.gmail.com>
X-Mailer: Apple Mail (2.3124)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.43
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 13:50:26 -0000


--Apple-Mail=_492A58DC-3B5A-4790-859B-25E603A70E0E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

> what shoud echo $((foo++)) do?

Give out an error message hopefully (and it does), because=20
the expression (bar+14+moo*2)++ makes no semantical sense
in terms of arithmetic expressions the bash uses, because ++
only can apply to locations and (bar+14+moo*2) evaluates to a number no =
matter
the contents of bar and moo=E2=80=A6

So lets assume that bash only executes things like ((<exp>++)) if and =
only if
<exp> is a proper location (that is a string that is no number).
We know that in this case only two things can happen.
(1) <exp> refers directly to a number value
or (2) <exp> refers to another string that is a location

In case of (1) the result is obvious. In case of (2) my complain =
applies.

> Your case is only really a special case, arguably having only =
indirection instead of what we have=20
> would perhaps have been a better idea, but it is this way for so long =
that I doubt it will change.

I wouldn=E2=80=99t consider this a special case, because the syntax and =
semantics
are almost identical to those of C (with the exception of the numerous =
exceptions like
recursive expansions etc.). So bash should also implement the same =
lvalue, rvalue
semantics that C does. Of course, with the appropriate adjustments =
needed to fit in the
context of a string typed command line interpreter :)

> would perhaps have been a better idea, but it is this way for so long =
that I doubt it will change.
Mhh=E2=80=A6

> PS: you can perhaps use name reference instead=20
> moo=3D1;
> declare -n foo=3Dbar bar=3Dmoo
> echo $((foo++))
> echo $moo

Thank you.

> Am 23.04.2017 um 15:19 schrieb Pierre Gaston =
<pierre.gaston@gmail.com>:
>=20
>=20
>=20
> On Sun, Apr 23, 2017 at 4:07 PM, Florian Mayer <mayerflorian@me.com =
<mailto:mayerflorian@me.com>> wrote:
> It does not matter, how this construct in this particular context is =
called.
> The difference between $(()) and (()) is that $(()) actually expands =
to something
> whereas (()) just executes a C-like expression. In ((<expression>)) =
<expression> can also
> include assignments, as the bash manual that you properly cited, also =
elaborates on.
> You can do, for example, things like
> $ foo=3D2
> $ ((foo+=3D100)) # fo is now 102
> $ ((++(foo++)))
> or even
> $ ((foo++, foo++, foo++, foo++, foo+=3D100))
> and (oh boy why) even
> $ foo=3D(123 321)
> $ ((foo[0]++, foo[1]=E2=80=94))
>=20
> So I might have chosen the wrong subject text for this mail,
> but again, it does not matter whether those constructs actually expand =
to some string
> or not. The side effects are what matter here. And in my opinion those =
are not correct...
>=20
> I understand what you want, I'm just explaining the result you get=20
> and why it doesn't do what you want.
> As it is, a variable can contain the name of another variable=20
> but it can also contain any arbitrary string that is a correct =
arithmetic expression.
>=20
> So if you have:=20
>=20
> foo=3Dbar+14+baz=20
> baz=3D'moo*2'
> moo=3D1
>=20
> what shoud echo $((foo++)) do?
>=20
> Your case is only really a special case, arguably having only =
indirection instead of what we have=20
> would perhaps have been a better idea, but it is this way for so long =
that I doubt it will change.
>=20
> PS: you can perhaps use name reference instead=20
> moo=3D1;
> declare -n foo=3Dbar bar=3Dmoo
> echo $((foo++))
> echo $moo
>=20
>=20


--Apple-Mail=_492A58DC-3B5A-4790-859B-25E603A70E0E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D""><div class=3D""><blockquote type=3D"cite" class=3D""><div =
dir=3D"ltr" class=3D""><div class=3D"gmail_extra"><div =
class=3D"gmail_quote"><div class=3D"">what shoud echo $((foo++)) do?<br =
class=3D""></div></div></div></div></blockquote></div><div class=3D""><div=
 dir=3D"ltr" class=3D""><div class=3D"gmail_extra"><div =
class=3D"gmail_quote"><div class=3D"">Give out an error message =
hopefully (and it does), because&nbsp;</div><div class=3D"">the =
expression (bar+14+moo*2)++ <i class=3D"">makes no semantical =
sense</i></div><div class=3D"">in terms of arithmetic expressions the =
bash uses, because ++</div><div class=3D"">only can apply to locations =
and (bar+14+moo*2) evaluates to a number no matter</div><div =
class=3D"">the contents of bar and moo=E2=80=A6</div><div class=3D""><br =
class=3D""></div><div class=3D"">So lets assume that bash only executes =
things like ((&lt;exp&gt;++)) if and only if</div><div =
class=3D"">&lt;exp&gt; is a proper location (that is a string that is no =
number).</div><div class=3D"">We know that in this case only two things =
can happen.</div><div class=3D"">(1) &lt;exp&gt; refers directly to a =
number value</div><div class=3D"">or (2) &lt;exp&gt; refers to another =
string that is a location</div><div class=3D""><br class=3D""></div><div =
class=3D"">In case of (1) the result is obvious. In case of (2) my =
complain applies.</div><div class=3D""><br class=3D""></div><div =
class=3D""><blockquote type=3D"cite" class=3D""><div dir=3D"ltr" =
class=3D""><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div =
class=3D"">Your case is only really a special case, arguably having only =
indirection instead of what we have&nbsp;<br class=3D"">would perhaps =
have been a better idea, but it is this way for so long that I doubt it =
will change.</div></div></div></div></blockquote></div><div class=3D"">I =
wouldn=E2=80=99t consider this a special case, because the syntax and =
semantics</div><div class=3D"">are almost identical to those of C (with =
the exception of the numerous exceptions like</div><div =
class=3D"">recursive expansions etc.). So bash should also implement the =
same lvalue, rvalue</div><div class=3D"">semantics that C does. Of =
course, with the appropriate adjustments needed to fit in the</div><div =
class=3D"">context of a string typed command line interpreter =
:)</div><div class=3D""><br class=3D""></div><div class=3D""><blockquote =
type=3D"cite" class=3D""><div dir=3D"ltr" class=3D""><div =
class=3D"gmail_extra"><div class=3D"gmail_quote"><div class=3D"">would =
perhaps have been a better idea, but it is this way for so long that I =
doubt it will =
change.</div></div></div></div></blockquote>Mhh=E2=80=A6</div><div =
class=3D""><br class=3D""></div><div class=3D""><blockquote type=3D"cite" =
class=3D""><div dir=3D"ltr" class=3D""><div class=3D"gmail_extra"><div =
class=3D"gmail_quote"><div class=3D"">PS: you can perhaps use name =
reference instead&nbsp;<br class=3D"">moo=3D1;<br class=3D"">declare -n =
foo=3Dbar bar=3Dmoo<br class=3D""></div><div class=3D"">echo =
$((foo++))<br class=3D""></div><div class=3D"">echo =
$moo</div></div></div></div></blockquote></div><div class=3D"">Thank =
you.</div></div></div></div></div><br class=3D""><div><blockquote =
type=3D"cite" class=3D""><div class=3D"">Am 23.04.2017 um 15:19 schrieb =
Pierre Gaston &lt;<a href=3D"mailto:pierre.gaston@gmail.com" =
class=3D"">pierre.gaston@gmail.com</a>&gt;:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" =
class=3D""><br class=3D""><div class=3D"gmail_extra"><br class=3D""><div =
class=3D"gmail_quote">On Sun, Apr 23, 2017 at 4:07 PM, Florian Mayer =
<span dir=3D"ltr" class=3D"">&lt;<a href=3D"mailto:mayerflorian@me.com" =
target=3D"_blank" class=3D"">mayerflorian@me.com</a>&gt;</span> =
wrote:<br class=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex"><div style=3D"overflow-wrap: =
break-word;" class=3D""><div class=3D"">It does not matter, how this =
construct in this particular context is called.</div><div class=3D"">The =
difference between $(()) and (()) is that $(()) actually expands to =
something</div><div class=3D"">whereas (()) just executes a C-like =
expression. In ((&lt;expression&gt;)) &lt;expression&gt; can =
also</div><div class=3D"">include assignments, as the bash manual that =
you properly cited, also elaborates on.</div><div class=3D"">You can do, =
for example, things like</div><div class=3D"">$ foo=3D2</div><div =
class=3D"">$ ((foo+=3D100)) # fo is now 102</div><div class=3D"">$ =
((++(foo++)))</div><div class=3D"">or even</div><div class=3D"">$ =
((foo++, foo++, foo++, foo++, foo+=3D100))</div><div class=3D"">and (oh =
boy why) even</div><div class=3D"">$ foo=3D(123 321)</div><div =
class=3D"">$ ((foo[0]++, foo[1]=E2=80=94))</div><div class=3D""><br =
class=3D""></div><div class=3D"">So I might have chosen the wrong =
subject text for this mail,</div><div class=3D"">but again, it does not =
matter whether those constructs actually <i class=3D"">expand</i>&nbsp;to =
some string</div><div class=3D"">or not. The side effects are what =
matter here. And in my opinion those are not =
correct...</div></div></blockquote><div class=3D""><br class=3D"">I =
understand what you want, I'm just explaining the result you get <br =
class=3D"">and why it doesn't do what you want.<br class=3D"">As it is, =
a variable can contain the name of another variable <br class=3D"">but =
it can also contain any arbitrary string that is a correct arithmetic =
expression.<br class=3D""><br class=3D""></div><div class=3D"">So if you =
have: <br class=3D""><br class=3D"">foo=3Dbar+14+baz <br =
class=3D"">baz=3D'moo*2'<br class=3D""></div><div class=3D"">moo=3D1<br =
class=3D""><br class=3D""></div><div class=3D"">what shoud echo =
$((foo++)) do?<br class=3D""></div><div class=3D""><br =
class=3D""></div><div class=3D"">Your case is only really a special =
case, arguably having only indirection instead of what we have <br =
class=3D"">would perhaps have been a better idea, but it is this way for =
so long that I doubt it will change.<br class=3D""><br =
class=3D""></div><div class=3D"">PS: you can perhaps use name reference =
instead <br class=3D"">moo=3D1;<br class=3D"">declare -n foo=3Dbar =
bar=3Dmoo<br class=3D""></div><div class=3D"">echo $((foo++))<br =
class=3D""></div><div class=3D"">echo $moo<br class=3D""></div><div =
class=3D""><br class=3D""></div><div class=3D""><br =
class=3D""></div></div></div></div>
</div></blockquote></div><br class=3D""></body></html>=

--Apple-Mail=_492A58DC-3B5A-4790-859B-25E603A70E0E--


From MAILER-DAEMON Sun Apr 23 12:15:02 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2KA9-0000GF-S0
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 12:15:02 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53233)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d2KA8-0000Fw-Bn
	for bug-bash@gnu.org; Sun, 23 Apr 2017 12:15:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d2KA7-0003zt-Fe
	for bug-bash@gnu.org; Sun, 23 Apr 2017 12:15:00 -0400
Received: from mail-io0-x230.google.com ([2607:f8b0:4001:c06::230]:33991)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d2KA7-0003zl-Ag
	for bug-bash@gnu.org; Sun, 23 Apr 2017 12:14:59 -0400
Received: by mail-io0-x230.google.com with SMTP id a103so159596562ioj.1
	for <bug-bash@gnu.org>; Sun, 23 Apr 2017 09:14:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=GIV08irVsYLOoYJzbxqro4rpmp2nQuWJCV0kHsSPlm4=;
	b=bPTtj6BNHhkVO749JHY6qefl8WrIoIr4hIl6pM6l2JXCGgj1H182/6jAQNCQ7f0PWx
	iKOErpA2icffnyERlWKYXNOlM939Ly93iOFwPVsuMeMhCA196+BVoR+hJkZsf7wQrRp9
	Y8QzQ2schcEXdR5icNqj1sQ95Hab5WGfUtfpsVR+41tmggwZS6KkARE2VVlz8ue/ZBVR
	Y1RyFP0gem9qYk+OL2Ew+bSmwh4AdYDWB37iCAss9nBAo3RgDzSKS5QG1zQFJEPR8ywG
	n457waCeIRFYKPj4SeOfPN39qz9/a9Xp/zAxK1QNpXFou+TfHBe58CubGzoe1jq7YCfX
	jcKA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=GIV08irVsYLOoYJzbxqro4rpmp2nQuWJCV0kHsSPlm4=;
	b=tjCBI2OJx2UvA0mkhXzBHmchOgucwXSbmnIv5/J69JVGkrl1uUMVzMcQV3kZkLx31V
	0+DR6XRumeuhjBBDYuly+nJJg6pqSF67irzJLvZzk8xg4ZZaIs4xV4wZSeganvXtt4Xg
	cQYcrfcKdBaCwiTlJB6evB5483PMvSMIVKsBt0nButLc9TZDKuIODLY5AsbAr8Fj/bSA
	ldIIOQhzkVfLd09fBIzKWhaBOMkdVXCySmXYrJPEE4wj0WmY4psOMzdxcOvKmnppBKP5
	tm6dAqtkhgpOnw7BJeyBH3aO32idM6Sem5PTqqPJGrzh1atX7EmzbnojDZVjgy/A9nfr
	4Q0w==
X-Gm-Message-State: AN3rC/6SbbJQ/LVx8BX0llGSfe7/22REol+JfrTSEw2lcRQJNkxmO2VX
	vN+9zKSxy6+nmhdPB/ZmRd+RTIWoTg==
X-Received: by 10.107.7.18 with SMTP id 18mr2369695ioh.218.1492964095377; Sun,
	23 Apr 2017 09:14:55 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Sun, 23 Apr 2017 09:14:35 -0700 (PDT)
In-Reply-To: <CAFtNJsFiUKA1svWjkXDVvh7OWb+b71cJo7QGNxxvh6VwqoEDsg@mail.gmail.com>
References: <CAFtNJsFiUKA1svWjkXDVvh7OWb+b71cJo7QGNxxvh6VwqoEDsg@mail.gmail.com>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Sun, 23 Apr 2017 11:14:35 -0500
Message-ID: <CAOSMAustnZq8CW2kVk+HiKw=4Aw5p7KPF=48QXiok9M5NWeVxw@mail.gmail.com>
Subject: Re: Segfault when unsetting READLINE_LINE inside 'bind -x'
To: Jaren Stangret <sirjaren@gmail.com>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::230
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 16:15:01 -0000

On Sun, Apr 23, 2017 at 12:56 AM, Jaren Stangret <sirjaren@gmail.com> wrote:
> Hello,
>
> Instead of segfaulting, BASH should ensure READELINE_LINE is unset or set
> and empty.

I am able to reproduce this with the latest devel branch. Here's the
stack trace:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6e827cc in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.3
(gdb) bt
#0  0x00007ffff6e827cc in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.3
#1  0x00005555556c88bb in maybe_make_readline_line (new_line=0x0) at
bashline.c:2548
#2  0x00005555556cec8a in bash_execute_unix_command (count=1, key=13)
at bashline.c:4142
#3  0x000055555574e9f9 in _rl_dispatch_subseq (key=13,
map=0x555555a56c80 <emacs_standard_keymap>, got_subseq=0) at
readline.c:851
#4  0x000055555574e5d4 in _rl_dispatch (key=0, map=0x555555a56c80
<emacs_standard_keymap>) at readline.c:797
#5  0x000055555574de13 in readline_internal_char () at readline.c:629
#6  0x000055555574dea5 in readline_internal_charloop () at readline.c:656
#7  0x000055555574dec9 in readline_internal () at readline.c:670
#8  0x000055555574d57f in readline (prompt=0x602000003630 "bash-4.4$
") at readline.c:374
#9  0x00005555555e2695 in yy_readline_get () at ./parse.y:1451
#10 0x00005555555e286d in yy_readline_get () at ./parse.y:1482
#11 0x00005555555e24f8 in yy_getc () at ./parse.y:1384
#12 0x00005555555e4842 in shell_getc (remove_quoted_newline=1) at ./parse.y:2284
#13 0x00005555555e72d4 in read_token (command=0) at ./parse.y:3133
#14 0x00005555555e5cb1 in yylex () at ./parse.y:2670
#15 0x00005555555daa62 in yyparse () at y.tab.c:1824
#16 0x00005555555d9c33 in parse_command () at eval.c:294
#17 0x00005555555d9e88 in read_command () at eval.c:338
#18 0x00005555555d90c4 in reader_loop () at eval.c:140
#19 0x00005555555d486e in main (argc=3, argv=0x7fffffffe478,
env=0x7fffffffe498) at shell.c:794

(gdb) frame 1
#1  0x00005555556c88bb in maybe_make_readline_line (new_line=0x0) at
bashline.c:2548
2548      if (strcmp (new_line, rl_line_buffer) != 0)
(gdb) frame 2
#2  0x00005555556cec8a in bash_execute_unix_command (count=1, key=13)
at bashline.c:4142
4142      maybe_make_readline_line (v ? value_cell (v) : 0);

I tried the following patch:

dualbus@debian:~/src/gnu/bash$ git diff -- bashline.c
diff --git a/bashline.c b/bashline.c
index 129714aa..7884416a 100644
--- a/bashline.c
+++ b/bashline.c
@@ -2545,7 +2545,7 @@ static void
 maybe_make_readline_line (new_line)
      char *new_line;
 {
-  if (strcmp (new_line, rl_line_buffer) != 0)
+  if (new_line && strcmp (new_line, rl_line_buffer) != 0)
     {
       rl_point = rl_end;

Which gets rid of the null pointer deference, but it seems to leave
the terminal in a bad state, so the patch is not complete and I have
no clue why.


From MAILER-DAEMON Sun Apr 23 13:34:38 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2LPC-0005mn-5Z
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 13:34:38 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:37052)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2LP7-0005ky-KH
	for bug-bash@gnu.org; Sun, 23 Apr 2017 13:34:34 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2LP4-0008Ja-Id
	for bug-bash@gnu.org; Sun, 23 Apr 2017 13:34:33 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:7233
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d2LP4-0008JR-CV
	for bug-bash@gnu.org; Sun, 23 Apr 2017 13:34:30 -0400
Received: from mpv8-2015.CWRU.Edu (EHLO mpv8-2015.case.edu) ([129.22.103.210])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALK55843; Sun, 23 Apr 2017 13:34:28 -0400 (EDT)
Received: from h251.66.130.174.dynamic.ip.windstream.net (EHLO
	_192.168.254.3_) ([174.130.66.251])
	by mpv8-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id HAY70575 (AUTH cpr);
	Sun, 23 Apr 2017 13:34:28 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu, "bug-bash@gnu.org" <bug-bash@gnu.org>
Subject: Re: Segfault when unsetting READLINE_LINE inside 'bind -x'
To: Eduardo Bustamante <dualbus@gmail.com>, Jaren Stangret <sirjaren@gmail.com>
References: <CAFtNJsFiUKA1svWjkXDVvh7OWb+b71cJo7QGNxxvh6VwqoEDsg@mail.gmail.com>
	<CAOSMAustnZq8CW2kVk+HiKw=4Aw5p7KPF=48QXiok9M5NWeVxw@mail.gmail.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <f6229748-17ee-a41b-7bf6-75b01da7a03b@case.edu>
Date: Sun, 23 Apr 2017 13:34:26 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0.1
MIME-Version: 1.0
In-Reply-To: <CAOSMAustnZq8CW2kVk+HiKw=4Aw5p7KPF=48QXiok9M5NWeVxw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.23.162116:17:8.317, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2,
	__CC_NAME, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __TO_MALFORMED_2, __TO_NAME,
	__TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR,
	__SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG,
	__FORWARDED_MSG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_1000_1099,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 17:34:34 -0000

On 4/23/17 12:14 PM, Eduardo Bustamante wrote:

> I tried the following patch:
> 
> dualbus@debian:~/src/gnu/bash$ git diff -- bashline.c
> diff --git a/bashline.c b/bashline.c
> index 129714aa..7884416a 100644
> --- a/bashline.c
> +++ b/bashline.c
> @@ -2545,7 +2545,7 @@ static void
>  maybe_make_readline_line (new_line)
>       char *new_line;
>  {
> -  if (strcmp (new_line, rl_line_buffer) != 0)
> +  if (new_line && strcmp (new_line, rl_line_buffer) != 0)
>      {
>        rl_point = rl_end;
> 
> Which gets rid of the null pointer deference, but it seems to leave
> the terminal in a bad state, so the patch is not complete and I have
> no clue why.

It's a good fix, and it doesn't do anything to the terminal.  Your return
key doesn't work any more since you've rebound ^M, but that's intentional.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sun Apr 23 14:02:29 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2Lq9-0002WD-23
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 14:02:29 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:41309)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2Lq6-0002VQ-MI
	for bug-bash@gnu.org; Sun, 23 Apr 2017 14:02:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2Lq2-0008Di-Jg
	for bug-bash@gnu.org; Sun, 23 Apr 2017 14:02:26 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:29961
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d2Lq2-0008Dd-Dp
	for bug-bash@gnu.org; Sun, 23 Apr 2017 14:02:22 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMU54931; Sun, 23 Apr 2017 14:02:18 -0400 (EDT)
Received: from h251.66.130.174.dynamic.ip.windstream.net (EHLO
	_192.168.254.3_) ([174.130.66.251])
	by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id HAO05119 (AUTH cpr);
	Sun, 23 Apr 2017 14:02:17 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: Curious case of arithmetic expansion
To: Florian Mayer <mayerflorian@me.com>,
	Pierre Gaston <pierre.gaston@gmail.com>, bug-bash@gnu.org
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <ce1bad7e-858e-1fe9-943f-aafbe8eb8f71@case.edu>
Date: Sun, 23 Apr 2017 14:02:16 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0.1
MIME-Version: 1.0
In-Reply-To: <7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Junkmail-Status: score=7/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.23.170017:17:7.944, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME,
	__TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY,
	__URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW,
	BODY_SIZE_1900_1999, BODYTEXTP_SIZE_3000_LESS,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, __SINGLE_URI_TEXT,
	SINGLE_URI_IN_BODY, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 18:02:28 -0000

On 4/23/17 8:28 AM, Florian Mayer wrote:
> What Iâ€™m saying is, that if bash does recursively apply expansion
> mechanisms on the identifiers until it can retrieve a number, 
> it should do it symmetrically. 

That's not a reasonable expectation.

Here's how it works. When bash reads a token, such as `foo', it reads
it as a string.  In contexts where it needs a variable name, such as
the left side of an assignment, it remains a string. When it needs to
be treated as a value, such as on the right side of an assignment, its
value is expanded as an expression until it results in a number (unset
variables evaluate to 0).

So, foo++ is essentially equivalent to

	ofoo=foo, foo=ofoo+1, ofoo

When foo's value is needed, it is evaluated. When foo needs to be assigned
a value, it is assigned a value.  You're arguing for non-determinism when
assigning a value based on whether or not a variable happens to contain a
string. Unless you specifically indicate you want something like that, like
when using namerefs, it's not reasonable.


> That is,
> it should remember what chain of expansion had been necessary for
> a particular number to appear at the end of the expansion.
> 
> So instead of 
> 124 moo 123
> The echo command should produce
> bar moo 124
> 
> (The expansion chain here was foo->bar->moo->123)
> 
>> It's because it's not really indirection, rather the content of the
>> variable is evaluated:
> No it is really indirection. Bash even has a special (and very limited)
> syntax for that.

It's not indirection, and I am not sure why you show the completely
different variable indirection syntax.  The mental model you're using
may equate the two, but they are not the same.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sun Apr 23 16:25:39 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2O4h-0003jM-AR
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 16:25:39 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35142)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2O4e-0003jD-Mh
	for bug-bash@gnu.org; Sun, 23 Apr 2017 16:25:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2O4b-0000SY-EG
	for bug-bash@gnu.org; Sun, 23 Apr 2017 16:25:36 -0400
Received: from pv35p18im-ztdg05091101.me.com ([17.133.188.43]:17256)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d2O4a-0000SM-VN
	for bug-bash@gnu.org; Sun, 23 Apr 2017 16:25:33 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05091101.me.com by
	pv35p18im-ztdg05091101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OOV00500PM8OK00@pv35p18im-ztdg05091101.me.com> for
	bug-bash@gnu.org; Sun, 23 Apr 2017 20:25:31 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1492979131; bh=Q6agALWrZerHSPxYb2HOQ7kSHL3zM3RI7JsURrROa4Q=;
	h=From:Content-type:Message-id:MIME-version:Subject:Date:To;
	b=id1Y5ZHm9dLQ5bNY+6rkVSxtPDu8pyLvkrjWgx9C/CmRX0D12Ggy/bBHPQy03yvvm
	Pee1KNJFFud4epTHCTQq0HFteV3WdEc/VUg4OiKD1tMz0BbpwkzoDiPrq4Oy7dU6Zf
	ZJJ0luU58fR3rVW6wpD//Fc0mC0mPxx6hUscRQeLJFyaFLa36mhFO3t/YG4t6Fu553
	Qoev8E7bLPA3DN8BI9XB0Qv4tVEVgYrb71tvFlvyfqSHYqiM+oeYisoQXZ/T9+onXY
	9nVZMX2n/DqxvnZ/wjsXWNCfq4aw9Mxav6uL6JmFUr/Kc3jX6D9QQJdkyS5gGUiPvF
	CQQv/qeCDqMyA==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05091101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OOV001ANQ2E1010@pv35p18im-ztdg05091101.me.com>; Sun,
	23 Apr 2017 20:25:30 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-23_17:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704230374
From: Florian Mayer <mayerflorian@me.com>
Content-type: multipart/alternative;
	boundary="Apple-Mail=_4CDE7BB8-EA3C-4E3D-9D91-1F1A60C14A1A"
Message-id: <FFF2A9D7-6890-4715-8DE0-BA0A53C15BFD@me.com>
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
Subject: Re: Curious case of arithmetic expansion
Date: Sun, 23 Apr 2017 22:25:26 +0200
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<ce1bad7e-858e-1fe9-943f-aafbe8eb8f71@case.edu>
To: chet.ramey@case.edu, "bug-bash@gnu.org" <bug-bash@gnu.org>
In-reply-to: <ce1bad7e-858e-1fe9-943f-aafbe8eb8f71@case.edu>
X-Mailer: Apple Mail (2.3124)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.43
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 20:25:38 -0000


--Apple-Mail=_4CDE7BB8-EA3C-4E3D-9D91-1F1A60C14A1A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

> That's not a reasonable expectation.
Why not? Why is it not reasonable to expect an intuitive
result from (())? The most intuitive thing, in my opinion,
would be to use nameref for side effects by default, because in order
to get a value from an id, (()) already follows namerefs.

So if you have another opinion, or don=E2=80=99t want to change that
behaviour, that is totally understandable. But I think that this
surely is a reasonable expectation.

> It's not indirection, and I am not sure why you show the completely
I was mentioning that, not because I use =E2=80=9Ea mental model=E2=80=9C =
that falsely unifies
both things, but because I wanted to point out that there exists =
something
with a similar behavior.

And if ${!<varid>} does not portray some kind of indirection, what do =
you call it then?
I am aware of the ${!<prefix>*} form, what it does and that the =
following probably
does not internally do what I think it does, but on my system
$ foo=3Dbar; bar=3Dmoo; echo ${!foo}
really produces the string moo. Therefore, I referred to it as =
indirection.

> Am 23.04.2017 um 20:02 schrieb Chet Ramey <chet.ramey@case.edu>:
>=20
> On 4/23/17 8:28 AM, Florian Mayer wrote:
>> What I=E2=80=99m saying is, that if bash does recursively apply =
expansion
>> mechanisms on the identifiers until it can retrieve a number,=20
>> it should do it symmetrically.=20
>=20
> That's not a reasonable expectation.
>=20
> Here's how it works. When bash reads a token, such as `foo', it reads
> it as a string.  In contexts where it needs a variable name, such as
> the left side of an assignment, it remains a string. When it needs to
> be treated as a value, such as on the right side of an assignment, its
> value is expanded as an expression until it results in a number (unset
> variables evaluate to 0).
>=20
> So, foo++ is essentially equivalent to
>=20
> 	ofoo=3Dfoo, foo=3Dofoo+1, ofoo
>=20
> When foo's value is needed, it is evaluated. When foo needs to be =
assigned
> a value, it is assigned a value.  You're arguing for non-determinism =
when
> assigning a value based on whether or not a variable happens to =
contain a
> string. Unless you specifically indicate you want something like that, =
like
> when using namerefs, it's not reasonable.
>=20
>=20
>> That is,
>> it should remember what chain of expansion had been necessary for
>> a particular number to appear at the end of the expansion.
>>=20
>> So instead of=20
>> 124 moo 123
>> The echo command should produce
>> bar moo 124
>>=20
>> (The expansion chain here was foo->bar->moo->123)
>>=20
>>> It's because it's not really indirection, rather the content of the
>>> variable is evaluated:
>> No it is really indirection. Bash even has a special (and very =
limited)
>> syntax for that.
>=20
> It's not indirection, and I am not sure why you show the completely
> different variable indirection syntax.  The mental model you're using
> may equate the two, but they are not the same.
>=20
> --=20
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> 		 ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu <mailto:chet@case.edu>    =
http://cnswww.cns.cwru.edu/~chet/ <http://cnswww.cns.cwru.edu/~chet/>

--Apple-Mail=_4CDE7BB8-EA3C-4E3D-9D91-1F1A60C14A1A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D""><div class=3D""><blockquote type=3D"cite" class=3D""><span =
class=3D"" style=3D"float: none; display: inline !important;">That's not =
a reasonable expectation.</span><br class=3D""></blockquote>Why not? Why =
is it not reasonable to expect an intuitive</div><div class=3D"">result =
from (())? The most intuitive thing, in my opinion,</div><div =
class=3D"">would be to use nameref for side effects by default, because =
in order</div><div class=3D"">to get a value from an id, (()) already =
follows namerefs.</div><div class=3D""><br class=3D""></div><div =
class=3D"">So if you have another opinion, or don=E2=80=99t want to =
change that</div><div class=3D"">behaviour, that is totally =
understandable. But I think that this</div><div class=3D"">surely <i =
class=3D"">is</i> a reasonable expectation.</div><div class=3D""><br =
class=3D""></div><div class=3D""><blockquote type=3D"cite" =
class=3D""><span class=3D"" style=3D"float: none; display: inline =
!important;">It's not indirection, and I am not sure why you show the =
completely</span><br class=3D""></blockquote>I was mentioning that, not =
because I use =E2=80=9Ea mental model=E2=80=9C that falsely =
unifies</div><div class=3D"">both things, but because I wanted to point =
out that there exists something</div><div class=3D"">with a similar =
behavior.</div><div class=3D""><br class=3D""></div><div class=3D"">And =
if ${!&lt;varid&gt;} does not portray some kind of indirection, what do =
you call it then?</div><div class=3D"">I am aware of the =
${!&lt;prefix&gt;*} form, what it does and that the following =
probably</div><div class=3D"">does not internally do what I think it =
does, but on my system</div><div class=3D"">$ foo=3Dbar; bar=3Dmoo; echo =
${!foo}</div><div class=3D"">really produces the string moo. Therefore, =
I referred to it as indirection.</div><br class=3D""><div><blockquote =
type=3D"cite" class=3D""><div class=3D"">Am 23.04.2017 um 20:02 schrieb =
Chet Ramey &lt;<a href=3D"mailto:chet.ramey@case.edu" =
class=3D"">chet.ramey@case.edu</a>&gt;:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><span =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; float: none; display: inline =
!important;" class=3D"">On 4/23/17 8:28 AM, Florian Mayer =
wrote:</span><br style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><blockquote=
 type=3D"cite" style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D"">What =
I=E2=80=99m saying is, that if bash does recursively apply expansion<br =
class=3D"">mechanisms on the identifiers until it can retrieve a =
number,<span class=3D"Apple-converted-space">&nbsp;</span><br =
class=3D"">it should do it symmetrically.<span =
class=3D"Apple-converted-space">&nbsp;</span><br =
class=3D""></blockquote><br style=3D"font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: =
normal; letter-spacing: normal; orphans: auto; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; widows: =
auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><span=
 style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; float: none; display: inline =
!important;" class=3D"">That's not a reasonable expectation.</span><br =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;" class=3D""><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">Here's how it works. When bash reads a =
token, such as `foo', it reads</span><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">it as a string. &nbsp;In contexts where =
it needs a variable name, such as</span><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">the left side of an assignment, it =
remains a string. When it needs to</span><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">be treated as a value, such as on the =
right side of an assignment, its</span><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">value is expanded as an expression until =
it results in a number (unset</span><br style=3D"font-family: Helvetica; =
font-size: 12px; font-style: normal; font-variant-caps: normal; =
font-weight: normal; letter-spacing: normal; orphans: auto; text-align: =
start; text-indent: 0px; text-transform: none; white-space: normal; =
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" =
class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">variables evaluate to 0).</span><br =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;" class=3D""><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">So, foo++ is essentially equivalent =
to</span><br style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><br =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;" class=3D""><span class=3D"Apple-tab-span"=
 style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: pre; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;">	</span><span style=3D"font-family:=
 Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
float: none; display: inline !important;" class=3D"">ofoo=3Dfoo, =
foo=3Dofoo+1, ofoo</span><br style=3D"font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: =
normal; letter-spacing: normal; orphans: auto; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; widows: =
auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><br =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;" class=3D""><span style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
float: none; display: inline !important;" class=3D"">When foo's value is =
needed, it is evaluated. When foo needs to be assigned</span><br =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;" class=3D""><span style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
float: none; display: inline !important;" class=3D"">a value, it is =
assigned a value. &nbsp;You're arguing for non-determinism =
when</span><br style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><span =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; float: none; display: inline =
!important;" class=3D"">assigning a value based on whether or not a =
variable happens to contain a</span><br style=3D"font-family: Helvetica; =
font-size: 12px; font-style: normal; font-variant-caps: normal; =
font-weight: normal; letter-spacing: normal; orphans: auto; text-align: =
start; text-indent: 0px; text-transform: none; white-space: normal; =
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" =
class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">string. Unless you specifically indicate =
you want something like that, like</span><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">when using namerefs, it's not =
reasonable.</span><br style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><br =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;" class=3D""><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><blockquote type=3D"cite" style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D"">That is,<br class=3D"">it should remember what chain of =
expansion had been necessary for<br class=3D"">a particular number to =
appear at the end of the expansion.<br class=3D""><br class=3D"">So =
instead of<span class=3D"Apple-converted-space">&nbsp;</span><br =
class=3D"">124 moo 123<br class=3D"">The echo command should produce<br =
class=3D"">bar moo 124<br class=3D""><br class=3D"">(The expansion chain =
here was foo-&gt;bar-&gt;moo-&gt;123)<br class=3D""><br =
class=3D""><blockquote type=3D"cite" class=3D"">It's because it's not =
really indirection, rather the content of the<br class=3D"">variable is =
evaluated:<br class=3D""></blockquote>No it is really indirection. Bash =
even has a special (and very limited)<br class=3D"">syntax for that.<br =
class=3D""></blockquote><br style=3D"font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: =
normal; letter-spacing: normal; orphans: auto; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; widows: =
auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><span=
 style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; float: none; display: inline =
!important;" class=3D"">It's not indirection, and I am not sure why you =
show the completely</span><br style=3D"font-family: Helvetica; =
font-size: 12px; font-style: normal; font-variant-caps: normal; =
font-weight: normal; letter-spacing: normal; orphans: auto; text-align: =
start; text-indent: 0px; text-transform: none; white-space: normal; =
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" =
class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">different variable indirection syntax. =
&nbsp;The mental model you're using</span><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">may equate the two, but they are not the =
same.</span><br style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><br =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;" class=3D""><span style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
float: none; display: inline !important;" class=3D"">--<span =
class=3D"Apple-converted-space">&nbsp;</span></span><br =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;" class=3D""><span style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
float: none; display: inline !important;" class=3D"">``The lyf so short, =
the craft so long to lerne.'' - Chaucer</span><br style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" class=3D""><span class=3D"Apple-tab-span" style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">	=
</span><span class=3D"Apple-tab-span" style=3D"font-family: Helvetica; =
font-size: 12px; font-style: normal; font-variant-caps: normal; =
font-weight: normal; letter-spacing: normal; orphans: auto; text-align: =
start; text-indent: 0px; text-transform: none; white-space: pre; widows: =
auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">	=
</span><span style=3D"font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D""><span =
class=3D"Apple-converted-space">&nbsp;</span>``Ars longa, vita brevis'' =
- Hippocrates</span><br style=3D"font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: =
normal; letter-spacing: normal; orphans: auto; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; widows: =
auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><span=
 style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; float: none; display: inline =
!important;" class=3D"">Chet Ramey, UTech, CWRU =
&nbsp;&nbsp;&nbsp;</span><a href=3D"mailto:chet@case.edu" =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px;" class=3D"">chet@case.edu</a><span =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; float: none; display: inline =
!important;" class=3D""><span =
class=3D"Apple-converted-space">&nbsp;</span>&nbsp;&nbsp;&nbsp;</span><a =
href=3D"http://cnswww.cns.cwru.edu/~chet/" style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;" =
class=3D"">http://cnswww.cns.cwru.edu/~chet/</a></div></blockquote></div><=
br class=3D""></body></html>=

--Apple-Mail=_4CDE7BB8-EA3C-4E3D-9D91-1F1A60C14A1A--


From MAILER-DAEMON Sun Apr 23 16:31:10 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2OA2-0004O7-T7
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 16:31:10 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:44636)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lingochinko@hotmail.com>) id 1d2MCW-0004ps-3Q
	for bug-bash@gnu.org; Sun, 23 Apr 2017 14:25:37 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lingochinko@hotmail.com>) id 1d2MCS-0006EJ-Uk
	for bug-bash@gnu.org; Sun, 23 Apr 2017 14:25:36 -0400
Received: from mail-oln040092254103.outbound.protection.outlook.com
	([40.92.254.103]:50624
	helo=APC01-PU1-obe.outbound.protection.outlook.com)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <lingochinko@hotmail.com>)
	id 1d2MCS-0006Dx-4j
	for bug-bash@gnu.org; Sun, 23 Apr 2017 14:25:32 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com;
	s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; 
	bh=YRTNiLeAk07scsm/Se7kV82Xhb5Ks2Y26sFD7NNj4cQ=;
	b=t1DMWxBNbrlUKUHIIE8vbdFPGSrGsiTrcctgih3gvJVAu0i6ysJkAETwOOTyhYU5uX39IExK5bcPutS495TBAQhEJfmQxGNy7kpew62RNmxl3jrJTG1jb5GtXTwr09+hNAFlw3WVozEtEAwV6m42G5JdCx8xHfgACd8UtLGindeeNi2kINady5BeoNaTFAU63Ts2qp7jqVRLHC8R6NoL6XaQwLHIW17UKTnRlG/gf87Z0AsgNJR210R9xiZz/bWb7DxQS73oTKsOcYGtMnTLSBa6c6R4HwBsbrO5PGf4RHmSGWyROyIvsrNzKPMx3oJ1hw1CPGn7aGeNy81FF3nkCg==
Received: from SG2APC01FT057.eop-APC01.prod.protection.outlook.com
	(10.152.250.53) by SG2APC01HT100.eop-APC01.prod.protection.outlook.com
	(10.152.251.20) with Microsoft SMTP Server (version=TLS1_2,
	cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1019.14;
	Sun, 23 Apr 2017 06:52:24 +0000
Received: from TY1PR0301MB1248.apcprd03.prod.outlook.com (10.152.250.57) by
	SG2APC01FT057.mail.protection.outlook.com (10.152.251.133) with
	Microsoft SMTP Server (version=TLS1_2,
	cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.9 via
	Frontend Transport; Sun, 23 Apr 2017 06:52:24 +0000
Received: from TY1PR0301MB1248.apcprd03.prod.outlook.com ([10.164.98.147]) by
	TY1PR0301MB1248.apcprd03.prod.outlook.com ([10.164.98.147]) with
	mapi id 15.01.1061.010; Sun, 23 Apr 2017 06:52:24 +0000
From: Noneofthebusiness Ofsomehere <lingochinko@hotmail.com>
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
Subject: I Don't think it; 's a Bash bug in the classical sense but it is still
	very important for me to share with you
Thread-Topic: I Don't think it; 's a Bash bug in the classical sense but it is
	still very important for me to share with you
Thread-Index: AQHSu/399jJvJaqpHUW+lPnPCfYCOg==
Date: Sun, 23 Apr 2017 06:52:24 +0000
Message-ID: <TY1PR0301MB1248BAB8B8D149226C489DD0A41C0@TY1PR0301MB1248.apcprd03.prod.outlook.com>
Accept-Language: he-IL, en-US
Content-Language: he-IL
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: gnu.org; dkim=none (message not signed)
	header.d=none; gnu.org; dmarc=none action=none header.from=hotmail.com; 
x-incomingtopheadermarker: OriginalChecksum:0C39FF7D843ABC5105863A333FD1CF43B615F2DA6D7CD7869D62806FABA759B0;
	UpperCasedChecksum:99C9C1058E2F716FB625C2E4BA89A35270281949120D6A056B9149D1599CA4AA;
	SizeAsReceived:8075; Count:40
x-ms-exchange-messagesentrepresentingtype: 1
x-tmn: [XojTZKc2Nn6U6fGqicjXkuyno0WhMI9i]
x-microsoft-exchange-diagnostics: 1; SG2APC01HT100;
	5:kjTOSRrupUuYvwH50xhSa2xDWi0qW5jhweFqk/tkieZhJ/yOVXRXQM9vs9ox0aErpyXD6j4MaxszjOWQihpov+uuEU6CBpJzBwBGA+pin3+mZMvcjhKPe1pMY9GN7EPqbzg2PBJGZ8o6tDz6MN6S8w==;
	24:n4Y+FWolJxLBPw3gGPtWeNoxDeCuKAt1anEm3VEa8PD21k2rF1bqgkWxu2yb6B3P2FRtx6YsiHsfPGfrjwJyEG+/uPGwvTI1/zzTn+tXObs=;
	7:p93a7z6X4rtI4RPpIWY8wem+cJXzZeJ6I4hM38NsbffROnsAIKYzPJ0Hy5qlkixsT1VqC1Ffk8+Z70rc3f1Vc9T4ulb8bWw0sX4md5ELuc6jADVVM13AOLL4Tp9pY6lYKGuvqpYwl7ttoZKcFxK0jV5bBYKjRTTdJUKQFqq4VpIuHQTgodXpXLQsNKaDOB/ETOqwIvnQOiq7oC3dVM+X5w5jY7bspKCy91TVDETT++K+ET9BwUcEAFIfpgiXHxnLMo9McQdhPGj/hqBO56kuuMB8WRV+WP2u+a2tTZy8Cj0R++xq7BX+8vzPdNJOpAje
x-incomingheadercount: 40
x-eopattributedmessage: 0
x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(7070007)(98901004);
	DIR:OUT; SFP:1901; SCL:1; SRVR:SG2APC01HT100;
	H:TY1PR0301MB1248.apcprd03.prod.outlook.com; FPR:; SPF:None;
	LANG:en; 
x-ms-office365-filtering-correlation-id: b6a225d9-abb3-478d-44cd-08d48a154c16
x-microsoft-antispam: UriScan:; BCL:0; PCL:0;
	RULEID:(22001)(201702061074)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322274)(1603101448)(1601125374)(1701031045);
	SRVR:SG2APC01HT100; 
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031);
	SRVR:SG2APC01HT100; BCL:0; PCL:0; RULEID:; SRVR:SG2APC01HT100; 
x-forefront-prvs: 0286D7B531
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/alternative;
	boundary="_000_TY1PR0301MB1248BAB8B8D149226C489DD0A41C0TY1PR0301MB1248_"
MIME-Version: 1.0
X-OriginatorOrg: hotmail.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Apr 2017 06:52:24.0175 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Internet
X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2APC01HT100
X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy]
X-Received-From: 40.92.254.103
X-Mailman-Approved-At: Sun, 23 Apr 2017 16:31:09 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 18:25:37 -0000

--_000_TY1PR0301MB1248BAB8B8D149226C489DD0A41C0TY1PR0301MB1248_
Content-Type: text/plain; charset="windows-1255"
Content-Transfer-Encoding: quoted-printable

There is an annoying problem I struggle with that might be associated with =
tab completion. I would like to share it with you. It might be a bug. I rea=
lly don't know and I'm new to Linux and programming, hence I am being extra=
 careful in naming this a bug:


https://unix.stackexchange.com/questions/359910/heredocument-error-i-cant-u=
nderstand-delimited-by-end-of-file

[https://cdn.sstatic.net/Sites/unix/img/apple-touch-icon@2.png?v=3D32fb07f7=
ce26]<https://unix.stackexchange.com/questions/359910/heredocument-error-i-=
cant-understand-delimited-by-end-of-file>

Heredocument error I can't understand ("delimited by end of file")<https://=
unix.stackexchange.com/questions/359910/heredocument-error-i-cant-understan=
d-delimited-by-end-of-file>
unix.stackexchange.com
I execute the following code in Bash: bash /dev/fd/10 10<<-'SES' cat <> /et=
c/apache2/apache2.conf # Options Indexes





--_000_TY1PR0301MB1248BAB8B8D149226C489DD0A41C0TY1PR0301MB1248_
Content-Type: text/html; charset="windows-1255"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dwindows-1=
255">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"rtl">
<div id=3D"divtagdefaultwrapper" dir=3D"rtl" style=3D"font-size:12pt; color=
:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>There is an annoying problem I struggle with that might be associated wi=
th tab completion. I would like to share it with you. It might be a bug. I =
really don't know and I'm new to Linux and programming, hence I am being ex=
tra careful in naming this a bug:</p>
<p><br>
</p>
<p><a href=3D"https://unix.stackexchange.com/questions/359910/heredocument-=
error-i-cant-understand-delimited-by-end-of-file" class=3D"OWAAutoLink" id=
=3D"LPlnk805498" previewremoved=3D"true">https://unix.stackexchange.com/que=
stions/359910/heredocument-error-i-cant-understand-delimited-by-end-of-file=
</a></p>
<div id=3D"LPBorder_GT_14929301224750.21499980243626338" style=3D"margin-bo=
ttom:20px; overflow:auto; width:100%; text-indent:0px">
<table id=3D"LPContainer_14929301224710.606485860713512" cellspacing=3D"0" =
style=3D"width:90%; background-color:rgb(255,255,255); overflow:auto; paddi=
ng-top:20px; padding-bottom:20px; margin-top:20px; border-top:1px dotted rg=
b(200,200,200); border-bottom:1px dotted rgb(200,200,200)">
<tbody>
<tr valign=3D"top" style=3D"border-spacing:0px">
<td id=3D"ImageCell_14929301224720.11193411633406258" colspan=3D"1" style=
=3D"width:250px; display:table-cell; padding-right:20px">
<div id=3D"LPImageContainer_14929301224720.1819753412840699" style=3D"backg=
round-color:rgb(255,255,255); height:250px; margin:auto; display:table; wid=
th:250px">
<a id=3D"LPImageAnchor_14929301224720.47496516608307693" href=3D"https://un=
ix.stackexchange.com/questions/359910/heredocument-error-i-cant-understand-=
delimited-by-end-of-file" target=3D"_blank" style=3D"display:table-cell; te=
xt-align:center"><img id=3D"LPThumbnailImageID_14929301224720.4017643758202=
1385" width=3D"250" height=3D"250" style=3D"display:inline-block; max-width=
:250px; max-height:250px; height:250px; width:250px; border-width:0px; vert=
ical-align:bottom" src=3D"https://cdn.sstatic.net/Sites/unix/img/apple-touc=
h-icon@2.png?v=3D32fb07f7ce26"></a></div>
</td>
<td id=3D"TextCell_14929301224730.9108079766674841" colspan=3D"2" style=3D"=
vertical-align: top; padding: 0px; display: table-cell; position: relative;=
">
<div id=3D"LPRemovePreviewContainer_14929301224730.07242133345420543"></div=
>
<div id=3D"LPTitle_14929301224730.764388396810697" style=3D"top:0px; color:=
rgb(0,120,215); font-weight:normal; font-size:21px; font-family:wf_segoe-ui=
_light,&quot;Segoe UI Light&quot;,&quot;Segoe WP Light&quot;,&quot;Segoe UI=
&quot;,&quot;Segoe WP&quot;,Tahoma,Arial,sans-serif; line-height:21px">
<a id=3D"LPUrlAnchor_14929301224730.11450951090500672" href=3D"https://unix=
.stackexchange.com/questions/359910/heredocument-error-i-cant-understand-de=
limited-by-end-of-file" target=3D"_blank" style=3D"text-decoration:none">He=
redocument error I can't understand (&quot;delimited
 by end of file&quot;)</a></div>
<div id=3D"LPMetadata_14929301224730.8843532463187904" style=3D"margin:10px=
 0px 16px; color:rgb(102,102,102); font-weight:normal; font-family:wf_segoe=
-ui_normal,&quot;Segoe UI&quot;,&quot;Segoe WP&quot;,Tahoma,Arial,sans-seri=
f; font-size:14px; line-height:14px">
unix.stackexchange.com</div>
<div id=3D"LPDescription_14929301224740.037145315412220326" style=3D"displa=
y:block; color:rgb(102,102,102); font-weight:normal; font-family:wf_segoe-u=
i_normal,&quot;Segoe UI&quot;,&quot;Segoe WP&quot;,Tahoma,Arial,sans-serif;=
 font-size:14px; line-height:20px; max-height:100px; overflow:hidden">
I execute the following code in Bash: bash /dev/fd/10 10&lt;&lt;-'SES' cat =
&lt;&gt; /etc/apache2/apache2.conf # Options Indexes</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
<p></p>
<p><br>
</p>
</div>
</body>
</html>

--_000_TY1PR0301MB1248BAB8B8D149226C489DD0A41C0TY1PR0301MB1248_--


From MAILER-DAEMON Sun Apr 23 19:26:51 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2Qu3-0003Fa-AB
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 19:26:51 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35555)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d2Qu0-0003FT-Sm
	for bug-bash@gnu.org; Sun, 23 Apr 2017 19:26:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d2Qtz-0000LI-N4
	for bug-bash@gnu.org; Sun, 23 Apr 2017 19:26:48 -0400
Received: from mail-it0-x22a.google.com ([2607:f8b0:4001:c0b::22a]:37244)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d2Qtz-0000Kl-Gt
	for bug-bash@gnu.org; Sun, 23 Apr 2017 19:26:47 -0400
Received: by mail-it0-x22a.google.com with SMTP id x188so31727185itb.0
	for <bug-bash@gnu.org>; Sun, 23 Apr 2017 16:26:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-transfer-encoding;
	bh=rJ9FUgpY3iIk38EKaR+cknUbIC5XLmA8zC5/IldUaP0=;
	b=ApwWbhQzN4AS8APmZdE0FDMboLAKAox0HbhFE9FirdP4x6dWBcYMiRM7FpinFbb5pf
	BHwjFD1KBEsNjA5ndnLkbq7450kwGi/COQGalIkJW6LWLOGtNxErRdbclUymGSLqNhN8
	hM/8CKbcD0E25HK+5A7MneoBnvmfuw3WLzZLNPiuZMFhWgHNoG8JBqJbPqo+8veC5Xad
	iLZB4kK43kyKOdxqOmnhpm2Ib5bACutTNrNR3HeblCH4NLf+mk2OMW3oLfmHlfx4cT1P
	kHVgW9j6UJ7JJPvRLqFk/4hFcv3FaeRCuVGTf1mrUJhX7Dm83gFdJaPl4Xc8HhFgMbrE
	orBA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc:content-transfer-encoding;
	bh=rJ9FUgpY3iIk38EKaR+cknUbIC5XLmA8zC5/IldUaP0=;
	b=XVQSsa9CZcSvr4njYscXz2m3r06OWP0RygdfIpoT295pXStw4/ATBrW3Hz5k6qYRem
	xThP+KmkEBRJGbaXxB3HPLZmSQwIhnU79gTqSnUTZIDKeRetyNQQqfdvNKZJ4/WbWfCV
	yqMOX5r/HszZZXWgMcfwD4VfRC8SOc1WQkyaqtUTjUJUbSanDd0iGdinQ32CP5PuckhP
	b4knYgzozveAf+vbjrOk6XJXm0LDZTHnxpxgsquLziqq1/0BbciQnKHyZQCkQmtzyMgM
	+WdzrAXAb2s6GRA6HcrqpMoYPOcpxGEr4LdNho3PkLaJpXUT6hHQlATJJBY+sfQxfn0J
	jL4A==
X-Gm-Message-State: AN3rC/5YVvtKUGJUQ/j1WRiHl8UtFyS5tGh6W8P4CMUf9Svzj8QPPk7j
	QLKw3GOVB08aS93ZfV0SHf7bdnQnqmTx
X-Received: by 10.36.32.138 with SMTP id t132mr10590513itt.89.1492990006843;
	Sun, 23 Apr 2017 16:26:46 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Sun, 23 Apr 2017 16:26:26 -0700 (PDT)
In-Reply-To: <FFF2A9D7-6890-4715-8DE0-BA0A53C15BFD@me.com>
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<ce1bad7e-858e-1fe9-943f-aafbe8eb8f71@case.edu>
	<FFF2A9D7-6890-4715-8DE0-BA0A53C15BFD@me.com>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Sun, 23 Apr 2017 18:26:26 -0500
Message-ID: <CAOSMAusUSkh8JrBauRETTuzEugLVYLBjXrZsYSW2fxZiWG6jiw@mail.gmail.com>
Subject: Re: Curious case of arithmetic expansion
To: Florian Mayer <mayerflorian@me.com>
Cc: Chet Ramey <chet.ramey@case.edu>, "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c0b::22a
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 23:26:50 -0000

On Sun, Apr 23, 2017 at 3:25 PM, Florian Mayer <mayerflorian@me.com> wrote:
[...]
> Why not? Why is it not reasonable to expect an intuitive
> result from (())? The most intuitive thing, in my opinion,
> would be to use nameref for side effects by default, because in order
> to get a value from an id, (()) already follows namerefs.

First, the documented behavior
(https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#S=
hell-Arithmetic)
is this:

| The *value* of a variable is evaluated as an arithmetic expression
when it is referenced,
| or when a variable which has been given the integer attribute using
=E2=80=98declare -i=E2=80=99 is
| assigned a value

(emphasis is mine)

Second, every other major shell that implements recursive evaluation
of arithmetical expressions behaves the same way as bash:

| dualbus@debian:~$ for sh in dash mksh zsh ksh93 posh 'busybox sh'
bash; do $sh -c 'a=3Db b=3D2; echo $((a++)) $a $b'; done
| dash: 1: Illegal number: b
| 2 3 2
| 2 3 2
| 2 3 2
| 2 3 2
| 2 3 2
| 2 3 2
|
| dualbus@debian:~$ dpkg -l dash mksh zsh ksh posh busybox bash
| Desired=3DUnknown/Install/Remove/Purge/Hold
| | Status=3DNot/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Tr=
ig-pend
| |/ Err?=3D(none)/Reinst-required (Status,Err: uppercase=3Dbad)
| ||/ Name                        Version            Architecture
 Description
| +++-=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D-=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
| ii  bash                        4.4-4+b1           amd64
 GNU Bourne Again SHell
| ii  busybox                     1:1.22.0-19+b2     amd64
 Tiny utilities for small and embedded systems
| ii  dash                        0.5.8-2.4          amd64
 POSIX-compliant shell
| ii  ksh                         93u+20120801-2+b1  amd64
 Real, AT&T version of the Korn shell
| ii  mksh                        54-2+b2            amd64
 MirBSD Korn Shell
| ii  posh                        0.12.6+b1          amd64
 Policy-compliant Ordinary SHell
| ii  zsh                         5.3.1-4            amd64
 shell with lots of features

And third, you haven't really made a compelling argument to change
this behavior. Doing so will break backwards compatibility,
compatibility with other shells that implement this feature, and in my
opinion, doesn't help much in making recursive expansion of
arithmetical expressions more "intuitive".

Why is it so important that this be changed?


From MAILER-DAEMON Sun Apr 23 19:33:48 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2R0m-0004DX-38
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 19:33:48 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36307)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2R0j-0004D4-Pv
	for bug-bash@gnu.org; Sun, 23 Apr 2017 19:33:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2R0g-0001o8-Gg
	for bug-bash@gnu.org; Sun, 23 Apr 2017 19:33:45 -0400
Received: from mpv3-2015.cwru.edu ([129.22.103.194]:49185
	helo=mpv3-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d2R0g-0001o0-B7
	for bug-bash@gnu.org; Sun, 23 Apr 2017 19:33:42 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv3-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALP58526; Sun, 23 Apr 2017 19:33:40 -0400 (EDT)
Received: from h251.66.130.174.dynamic.ip.windstream.net (EHLO
	_192.168.254.3_) ([174.130.66.251])
	by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id HAP04650 (AUTH cpr);
	Sun, 23 Apr 2017 19:33:39 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: I Don't think it; 's a Bash bug in the classical sense but it is
	still very important for me to share with you
To: Noneofthebusiness Ofsomehere <lingochinko@hotmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
References: <TY1PR0301MB1248BAB8B8D149226C489DD0A41C0@TY1PR0301MB1248.apcprd03.prod.outlook.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <89c7f2b9-52d5-1fd7-0679-cb7305d7538a@case.edu>
Date: Sun, 23 Apr 2017 19:33:38 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0.1
MIME-Version: 1.0
In-Reply-To: <TY1PR0301MB1248BAB8B8D149226C489DD0A41C0@TY1PR0301MB1248.apcprd03.prod.outlook.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv3-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.23.224816:17:7.944, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR, __FRAUD_SUBJ_A,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME,
	__TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY,
	__URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW,
	BODY_SIZE_700_799, BODYTEXTP_SIZE_3000_LESS,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, __SINGLE_URI_TEXT,
	[TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.194
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 23:33:46 -0000

On 4/23/17 2:52 AM, Noneofthebusiness Ofsomehere wrote:
> There is an annoying problem I struggle with that might be associated with
> tab completion. I would like to share it with you. It might be a bug. I
> really don't know and I'm new to Linux and programming, hence I am being
> extra careful in naming this a bug:

I have a hard time seeing this as a bug.  I can run it without error after
taking your script from the link to stackexchange and making sure the
leading whitespace is tabs and there are no stray characters following the
here-document delimiters.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sun Apr 23 19:43:58 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2RAc-0005Xf-ER
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 19:43:58 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:37749)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2RAa-0005XX-41
	for bug-bash@gnu.org; Sun, 23 Apr 2017 19:43:57 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2RAS-0003pJ-K6
	for bug-bash@gnu.org; Sun, 23 Apr 2017 19:43:51 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:30844
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d2RAS-0003p7-Ds
	for bug-bash@gnu.org; Sun, 23 Apr 2017 19:43:48 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALK61138; Sun, 23 Apr 2017 19:43:45 -0400 (EDT)
Received: from h251.66.130.174.dynamic.ip.windstream.net (EHLO
	_192.168.254.3_) ([174.130.66.251])
	by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id HAP07415 (AUTH cpr);
	Sun, 23 Apr 2017 19:43:44 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: Curious case of arithmetic expansion
To: Florian Mayer <mayerflorian@me.com>, "bug-bash@gnu.org" <bug-bash@gnu.org>
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<ce1bad7e-858e-1fe9-943f-aafbe8eb8f71@case.edu>
	<FFF2A9D7-6890-4715-8DE0-BA0A53C15BFD@me.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <48927d81-da3a-a69f-662a-ccbd7dbc352a@case.edu>
Date: Sun, 23 Apr 2017 19:43:43 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0.1
MIME-Version: 1.0
In-Reply-To: <FFF2A9D7-6890-4715-8DE0-BA0A53C15BFD@me.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Junkmail-Status: score=7/60, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.23.223016:17:7.944, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME,
	__TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR,
	__SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG,
	__FORWARDED_MSG, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_1600_1699, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY,
	BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 23 Apr 2017 23:43:57 -0000

On 4/23/17 4:25 PM, Florian Mayer wrote:
>> That's not a reasonable expectation.
> Why not? Why is it not reasonable to expect an intuitive
> result from (())? The most intuitive thing, in my opinion,
> would be to use nameref for side effects by default, because in order
> to get a value from an id, (()) already follows namerefs.

The thing that makes that result intuitive for you is your opinion about
how things should work.  That's fine. I don't happen to share your opinion
of what is "intuitive" in this case.

However, it is unreasonable to expect

	var=bar
	(( var=7 ))

to do anything but assign a value to `var'.  Very few people, when asked,
would say that it were more intuitive to cause a variable named `bar' to
spring into existence with the value 7. If you want nameref behavior, you
have to explicitly declare it.


>> It's not indirection, and I am not sure why you show the completely
> I was mentioning that, not because I use â€ža mental modelâ€œ that falsely unifies
> both things, but because I wanted to point out that there exists something
> with a similar behavior.
> 
> And if ${!<varid>} does not portray some kind of indirection, what do you
> call it then?

That is variable indirection. It has superficially similar effects to what
we are discussing, which is arithmetic expansion; however, it has nothing
to do with the behavior of (( )) or $(( )).

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sun Apr 23 21:03:01 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2SP7-00055b-SA
	for mharc-bug-bash@gnu.org; Sun, 23 Apr 2017 21:03:01 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49149)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d2SP6-00055U-2n
	for bug-bash@gnu.org; Sun, 23 Apr 2017 21:03:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d2SP5-0008M5-5V
	for bug-bash@gnu.org; Sun, 23 Apr 2017 21:03:00 -0400
Received: from mail-io0-x22c.google.com ([2607:f8b0:4001:c06::22c]:32962)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d2SP5-0008Lr-0I
	for bug-bash@gnu.org; Sun, 23 Apr 2017 21:02:59 -0400
Received: by mail-io0-x22c.google.com with SMTP id k87so172588325ioi.0
	for <bug-bash@gnu.org>; Sun, 23 Apr 2017 18:02:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=vkC0nEHhd8EHcdkP1TTNXHcdLzTq1CXCkxTVcCekbn8=;
	b=TgDNc7Zz97TE/SPQqswaTsxLfFIvc0CqODy4CyJLcQ3aVW1dzz1U6uG1XB0fHcoM1h
	V2YCRP6OEniOxMSJrbqRK536QumJZ/ta179la1FTgT+SObH96mxGK243LglENOJKDD4f
	ta/bPVAbjXtz92BjfqOjeNJajem1CoAErdctdixCfOESJRhwDcwXIJI/mKkSnENSw8/B
	ffXh68SUa4SS5zj6h5f6vzql2/l2Xc4COKqmeGMfQ5muRQ3111QyjmWnH3hKmMJIUmhA
	AaxgU1Mr25Jld3aTFn923RAHlow4ReM9zdK6z1XYe9v24J17fDoIFblPXafVWf1w2IQt
	bkZg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=vkC0nEHhd8EHcdkP1TTNXHcdLzTq1CXCkxTVcCekbn8=;
	b=o/AECM9WXK7HCmG0//xIWps42UkZu/8gb+S4zacRudvwNIQQEsxvgFesrEKWnByNKJ
	g8N4JC3TvQWdUNMLi9xqpWuupc91ek/x1wjyN5eW30YxCEtr5LsdFUiCdCarsBJG86cw
	gY4fv6qAmQG/ATmIuvO6qzyJv5ogj4hr4fJfW3XkP6jRmMLXUb2KYf83FBczyvxuLY3D
	LvQKIMqLG616mUtrLIj1+mG4ZQC9QhHLptoa5PRn35ql2iZJ0+s1FGYq07TbZm0t6iKR
	6arjuyzBRuPEZvf2kcM0weQiG+dFTK553odqasfOqLQ3m3DzXTIbjVF5BwoYOeavOqgf
	sfuw==
X-Gm-Message-State: AN3rC/5dnMAENp23rqggyWMpbLdrknw2vlKbGBjPRNa5rO/VI4YAaE3f
	EBwnpF94EFISIFkwpwNv56mDEmCTMlCu
X-Received: by 10.107.18.84 with SMTP id a81mr4756987ioj.111.1492995778072;
	Sun, 23 Apr 2017 18:02:58 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Sun, 23 Apr 2017 18:02:37 -0700 (PDT)
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Sun, 23 Apr 2017 20:02:37 -0500
Message-ID: <CAOSMAuvABhAm=6M6nk=0v+bXvV6+MgzytVcgbu18J7pp48TKVQ@mail.gmail.com>
Subject: Using Clang's static analyzer on bash
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::22c
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 01:03:01 -0000

I built bash using scan-build
(https://clang-analyzer.llvm.org/scan-build.html) and I noticed that
it was able to detect the null pointer dereference reported earlier by
Jaren (https://lists.gnu.org/archive/html/bug-bash/2017-04/msg00100.html).

dualbus@debian:~/src/gnu/bash$ scan-build-3.9 make
scan-build: Using '/usr/lib/llvm-3.9/bin/clang' for static analysis

[...]

bashline.c:2548:7: warning: Null pointer argument in call to string
comparison function
  if (strcmp (new_line, rl_line_buffer) != 0)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string2.h:125:15: note: expanded
from macro 'strcmp'
            : __builtin_strcmp (s1, s2)))); })
              ^~~~~~~~~~~~~~~~~~~~~~~~~

scan-build currently picks up 263 "bugs" from the devel branch. Maybe
there's value in reducing that number to 0. I think it could be useful
to uncover new bugs.


From MAILER-DAEMON Mon Apr 24 03:59:34 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2YuE-0004oy-7h
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 03:59:34 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33189)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2YuC-0004ni-AJ
	for bug-bash@gnu.org; Mon, 24 Apr 2017 03:59:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d2Yu9-0006VZ-3s
	for bug-bash@gnu.org; Mon, 24 Apr 2017 03:59:32 -0400
Received: from pv35p18im-ztdg05101101.me.com ([17.133.188.44]:64597)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d2Yu8-0006VU-Ne
	for bug-bash@gnu.org; Mon, 24 Apr 2017 03:59:29 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05101101.me.com by
	pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OOW00000M6BFQ00@pv35p18im-ztdg05101101.me.com> for
	bug-bash@gnu.org; Mon, 24 Apr 2017 07:59:12 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1493020752; bh=T3UXQkS03u7EMuRtTdnHbXeO7mXXyppBlckHFvBlGMQ=;
	h=From:Content-type:Message-id:MIME-version:Subject:Date:To;
	b=jTTvTEoLWq3h39uVIDl6us86zqXQMtoEhb/g4xZzp/SzS3QwxLKOAQylnJuyBVIbd
	VlzRGKLQ9nc9VC5TOhRXkImEd8x5jk+Fcv61fs/w6zSFfKP6sMtSExeYOSjvC2FUj4
	bm0e9g8054+12tkD4kKPoE2KAV8KVJ3gwr3BkUlpJtH44enulT4oz7aqQ3e+Ry45rW
	hCfjfmz1iB3yoNynGThoMTNTxqu2rwXxbd2s8ycCUKnBdq+L9cOIw/2KlygTcbZ3a8
	rYEXYhL+2DkMJ8lm1E6TLkV9GkBIOV+u8WvcW+PSM8I6OaGxH+lbRfcH5udecmGDVy
	GJRauQtwAWxdA==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OOW00C59M6KPA10@pv35p18im-ztdg05101101.me.com>; Mon,
	24 Apr 2017 07:59:11 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-24_06:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704240138
From: Florian Mayer <mayerflorian@me.com>
Content-type: multipart/alternative;
	boundary="Apple-Mail=_54F9F86D-C049-4BAD-9E4E-6F209AFEA21A"
Message-id: <BC4FED5C-8914-463F-948F-F59EF136E440@me.com>
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
Subject: Re: Curious case of arithmetic expansion
Date: Mon, 24 Apr 2017 09:59:07 +0200
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<ce1bad7e-858e-1fe9-943f-aafbe8eb8f71@case.edu>
	<FFF2A9D7-6890-4715-8DE0-BA0A53C15BFD@me.com>
	<48927d81-da3a-a69f-662a-ccbd7dbc352a@case.edu>
To: chet.ramey@case.edu, "bug-bash@gnu.org" <bug-bash@gnu.org>
In-reply-to: <48927d81-da3a-a69f-662a-ccbd7dbc352a@case.edu>
X-Mailer: Apple Mail (2.3124)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.44
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 07:59:33 -0000


--Apple-Mail=_54F9F86D-C049-4BAD-9E4E-6F209AFEA21A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

Ok, I accept your points, but please read on and decide after that.

> to do anything but assign a value to `var'.  Very few people, when =
asked,
> would say that it were more intuitive to cause a variable named `bar' =
to
> spring into existence with the value 7. If you want nameref behavior, =
you
> have to explicitly declare it.

But why is nameref behavior in the evaluation part activated by default
and not for the assignments? I think that one should
either make nameref behavior the default case for both,=20
assignment and evaluation, or the non-default case for both.

In the latter case, where namerefs are off for both things, the lines =
(1) and (2)
1) var=3Dbar; bar=3D3; echo ((var))
2) var=3Dbar; ((var=3D3))   or var=3Dbar; bar=3D0; ((var++))
should lead to an error message!
However the current status quo is, that bash happily does (1) as you=E2=80=
=99d=20
expect but gives out no error in (2) and overwrites (1).

> That is variable indirection. It has superficially similar effects to =
what
> we are discussing, which is arithmetic expansion; however, it has =
nothing
> to do with the behavior of (( )) or $(( )).

Again, I never wrote, that, from a technical point of view, it has =
something to do
with (()) or $(()). Merely the visible behavior is similar in the cases =
I showed.

> Am 24.04.2017 um 01:43 schrieb Chet Ramey <chet.ramey@case.edu>:
>=20
> On 4/23/17 4:25 PM, Florian Mayer wrote:
>>> That's not a reasonable expectation.
>> Why not? Why is it not reasonable to expect an intuitive
>> result from (())? The most intuitive thing, in my opinion,
>> would be to use nameref for side effects by default, because in order
>> to get a value from an id, (()) already follows namerefs.
>=20
> The thing that makes that result intuitive for you is your opinion =
about
> how things should work.  That's fine. I don't happen to share your =
opinion
> of what is "intuitive" in this case.
>=20
> However, it is unreasonable to expect
>=20
> 	var=3Dbar
> 	(( var=3D7 ))
>=20
> to do anything but assign a value to `var'.  Very few people, when =
asked,
> would say that it were more intuitive to cause a variable named `bar' =
to
> spring into existence with the value 7. If you want nameref behavior, =
you
> have to explicitly declare it.
>=20
>=20
>>> It's not indirection, and I am not sure why you show the completely
>> I was mentioning that, not because I use =E2=80=9Ea mental model=E2=80=9C=
 that falsely unifies
>> both things, but because I wanted to point out that there exists =
something
>> with a similar behavior.
>>=20
>> And if ${!<varid>} does not portray some kind of indirection, what do =
you
>> call it then?
>=20
> That is variable indirection. It has superficially similar effects to =
what
> we are discussing, which is arithmetic expansion; however, it has =
nothing
> to do with the behavior of (( )) or $(( )).

--Apple-Mail=_54F9F86D-C049-4BAD-9E4E-6F209AFEA21A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D""><div class=3D"">Ok, I accept your points, but please read on =
and decide after that.</div><div class=3D""><br class=3D""><blockquote =
type=3D"cite" class=3D"">to do anything but assign a value to `var'. =
&nbsp;Very few people, when asked,<br class=3D"">would say that it were =
more intuitive to cause a variable named `bar' to<br class=3D"">spring =
into existence with the value 7. If you want nameref behavior, you<br =
class=3D"">have to explicitly declare it.</blockquote></div><div =
class=3D"">But why<i class=3D"">&nbsp;</i>is nameref behavior in the =
evaluation part activated by default</div><div class=3D"">and not for =
the assignments? I think that one should</div><div class=3D"">either =
make nameref behavior the default case for both,&nbsp;</div><div =
class=3D"">assignment and evaluation, or the non-default case for =
both.</div><div class=3D""><br class=3D""></div><div class=3D"">In the =
latter case, where namerefs are off for both things, the lines (1) and =
(2)</div><div class=3D"">1) var=3Dbar; bar=3D3; echo ((var))</div><div =
class=3D"">2) var=3Dbar; ((var=3D3)) &nbsp; or var=3Dbar; bar=3D0; =
((var++))</div><div class=3D"">should lead to an error =
message!</div><div class=3D"">However the current status quo is, that =
bash happily does (1) as you=E2=80=99d&nbsp;</div><div class=3D"">expect =
but gives out no error in (2) and overwrites (1).</div><div class=3D""><br=
 class=3D""></div><div class=3D""><blockquote type=3D"cite" =
class=3D"">That is variable indirection. It has superficially similar =
effects to what<br class=3D"">we are discussing, which is arithmetic =
expansion; however, it has nothing<br class=3D"">to do with the behavior =
of (( )) or $(( )).</blockquote></div><div class=3D"">Again, I never =
wrote, that, from a technical point of view, it has something to =
do</div><div class=3D"">with (()) or $(()). Merely the visible behavior =
is similar in the cases I showed.</div><div class=3D""><br =
class=3D""></div><div><blockquote type=3D"cite" class=3D""><div =
class=3D"">Am 24.04.2017 um 01:43 schrieb Chet Ramey &lt;<a =
href=3D"mailto:chet.ramey@case.edu" =
class=3D"">chet.ramey@case.edu</a>&gt;:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div class=3D"">On =
4/23/17 4:25 PM, Florian Mayer wrote:<br class=3D""><blockquote =
type=3D"cite" class=3D""><blockquote type=3D"cite" class=3D"">That's not =
a reasonable expectation.<br class=3D""></blockquote>Why not? Why is it =
not reasonable to expect an intuitive<br class=3D"">result from (())? =
The most intuitive thing, in my opinion,<br class=3D"">would be to use =
nameref for side effects by default, because in order<br class=3D"">to =
get a value from an id, (()) already follows namerefs.<br =
class=3D""></blockquote><br class=3D"">The thing that makes that result =
intuitive for you is your opinion about<br class=3D"">how things should =
work. &nbsp;That's fine. I don't happen to share your opinion<br =
class=3D"">of what is "intuitive" in this case.<br class=3D""><br =
class=3D"">However, it is unreasonable to expect<br class=3D""><br =
class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre">	=
</span>var=3Dbar<br class=3D""><span class=3D"Apple-tab-span" =
style=3D"white-space:pre">	</span>(( var=3D7 ))<br class=3D""><br =
class=3D"">to do anything but assign a value to `var'. &nbsp;Very few =
people, when asked,<br class=3D"">would say that it were more intuitive =
to cause a variable named `bar' to<br class=3D"">spring into existence =
with the value 7. If you want nameref behavior, you<br class=3D"">have =
to explicitly declare it.<br class=3D""><br class=3D""><br =
class=3D""><blockquote type=3D"cite" class=3D""><blockquote type=3D"cite" =
class=3D"">It's not indirection, and I am not sure why you show the =
completely<br class=3D""></blockquote>I was mentioning that, not because =
I use =E2=80=9Ea mental model=E2=80=9C that falsely unifies<br =
class=3D"">both things, but because I wanted to point out that there =
exists something<br class=3D"">with a similar behavior.<br class=3D""><br =
class=3D"">And if ${!&lt;varid&gt;} does not portray some kind of =
indirection, what do you<br class=3D"">call it then?<br =
class=3D""></blockquote><br class=3D"">That is variable indirection. It =
has superficially similar effects to what<br class=3D"">we are =
discussing, which is arithmetic expansion; however, it has nothing<br =
class=3D"">to do with the behavior of (( )) or $(( =
)).</div></div></blockquote></div></body></html>=

--Apple-Mail=_54F9F86D-C049-4BAD-9E4E-6F209AFEA21A--


From MAILER-DAEMON Mon Apr 24 06:59:13 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2bi5-0004mM-B1
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 06:59:13 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52859)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <werner@suse.de>) id 1d2bi3-0004lh-R1
	for bug-bash@gnu.org; Mon, 24 Apr 2017 06:59:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <werner@suse.de>) id 1d2bhz-0008Dg-Vh
	for bug-bash@gnu.org; Mon, 24 Apr 2017 06:59:11 -0400
Received: from mx2.suse.de ([195.135.220.15]:43143 helo=mx1.suse.de)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <werner@suse.de>) id 1d2bhz-0008Ct-P7
	for bug-bash@gnu.org; Mon, 24 Apr 2017 06:59:07 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx1.suse.de (Postfix) with ESMTP id 1029DAC65
	for <bug-bash@gnu.org>; Mon, 24 Apr 2017 10:59:05 +0000 (UTC)
Date: Mon, 24 Apr 2017 12:59:01 +0200
Message-Id: <201704241059.v3OAx1cL012497@noether.suse.de>
From: werner@suse.de
To: bug-bash@gnu.org
Subject: Syntax error near unexpected token `newline' within loops
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 195.135.220.15
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 10:59:13 -0000

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.4 -L/home/abuild/rpmbuild/BUILD/bash-4.4/../readline-7.0
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu' -DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -g  -D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g -Wuninitialized -Wextra -Wno-switch-enum -Wno-unused-variable -Wno-unused-parameter -Wno-parentheses -ftree-loop-linear -pipe -DBNC382214=0 -DIMPORT_FUNCTIONS_DEF=0 -fprofile-use -fprofile-correction
uname output: Linux noether 4.4.57-18.3-default #1 SMP Thu Mar 30 06:39:47 UTC 2017 (39c8557) x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: release

Description:
	Since 4.3 including 4.4 bash shows a bug in loops using nested ((...)), $((..)), and $(...)

Repeat-By:
The bash code

	V_NAME=Friday
	for (( INDEX=0; INDEX<$((10-$(expr length $V_NAME))); INDEX++ ))
	do
	    echo $INDEX
	done

leads to

        bash: syntax error near unexpected token `newline'

whereas using backticks simply works

	V_NAME=Friday
	for (( INDEX=0; INDEX<$((10-`expr length $V_NAME`)); INDEX++ ))
	do
	    echo $INDEX
	done

and yes

	V_NAME=Friday
	for (( INDEX=0; INDEX<$((10-${#V_NAME})) ; INDEX++ ))
	do
	    echo $INDEX
	done

does also work, nevertheless using $(...) in the very first example is allowed


From MAILER-DAEMON Mon Apr 24 07:26:05 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2c85-0008Rj-E2
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 07:26:05 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58070)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d2c83-0008RT-Ag
	for bug-bash@gnu.org; Mon, 24 Apr 2017 07:26:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d2c82-0000vt-Es
	for bug-bash@gnu.org; Mon, 24 Apr 2017 07:26:03 -0400
Received: from mail-qk0-x236.google.com ([2607:f8b0:400d:c09::236]:34089)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <pierre.gaston@gmail.com>)
	id 1d2c82-0000vk-5K
	for bug-bash@gnu.org; Mon, 24 Apr 2017 07:26:02 -0400
Received: by mail-qk0-x236.google.com with SMTP id y63so84366537qkd.1
	for <bug-bash@gnu.org>; Mon, 24 Apr 2017 04:26:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=bSQXXupVY4GlMixcw8uOYMzGUNPGpp/JEe+kfol2fWU=;
	b=J4HfR/bNT9RY1h+VxxNhSiT2M4aBk6ANjmNjL9pQJQFQ1pIvxZwo5vDOstFmAGuvJk
	lGH3oG24eUdsdN9srKhVQioUqzGLgfzZ+/Y3XYF5cR7ueFxVYm6BhpPrkuKKs/VeJRhS
	4H1zzK87hPhvWHxQENncofjNMIXi/vOvGrWFSysIpZuTB3rIzLqOQCTnxgXd48Brxi41
	snyC+tobCGBeWjSsNWGOY9+PJ233WI7+UGZrNb8OIOePSvpI047I8XaOTWt6fg3uvps+
	/vMo9RP/+BZABlX7jiDO6IybmhKLZxRZXQEJTj2WoL3vv/Eja7WTxzabKMPeYj6sJOv9
	e9Hw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=bSQXXupVY4GlMixcw8uOYMzGUNPGpp/JEe+kfol2fWU=;
	b=Ckzzs6DR03Ards68jFFjEKoFBDx/kZ1zVXDTUjrOAKBcBGk0vmJKU2eoN068eWCwXk
	bbYHp+cdctq0jHnx/Bd6ipog9WNyFhHMkmiNbSzVk9EMGodMQFZ3Eml7DALAa7+4m2/e
	oxoucWAZr0Al5zsTNlXDxlgbNsGSUIO1LYxfdSRuEmotg4Rs/Vd0BxCYsw5B83wF11cS
	OwyVUdKRJinqnkeGHucTcUAf63PP9HrcGPX0zkDpeNXv0++nBFTZeZcK1wSM3kVtJlO4
	FUFEhI1MOrhHSBlwYbBi38MBPVrr3hHBDPZSMO+VD3HMolMnU1Ut5kGQPUq2fhldLKVc
	2MOg==
X-Gm-Message-State: AN3rC/59ps0Fpz/ILJfAxazHYG02gXJvS6OthErqH6Tck5bkPh4vt0bH
	PbpRT0LNi3BhpfIlZbsO2+s7qUrf4Q==
X-Received: by 10.55.23.84 with SMTP id i81mr5102359qkh.153.1493033161651;
	Mon, 24 Apr 2017 04:26:01 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.12.180.13 with HTTP; Mon, 24 Apr 2017 04:25:41 -0700 (PDT)
In-Reply-To: <201704241059.v3OAx1cL012497@noether.suse.de>
References: <201704241059.v3OAx1cL012497@noether.suse.de>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Mon, 24 Apr 2017 14:25:41 +0300
Message-ID: <CAPSX3sRjiMcqTiKXwSp0aN4qLW5a_6dw3YS4n5SfmkSCMC24Zg@mail.gmail.com>
Subject: Re: Syntax error near unexpected token `newline' within loops
To: werner@suse.de
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: multipart/alternative; boundary=001a1146fe623cfc87054de7df77
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::236
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 11:26:04 -0000

--001a1146fe623cfc87054de7df77
Content-Type: text/plain; charset=UTF-8

On Mon, Apr 24, 2017 at 1:59 PM, <werner@suse.de> wrote:

> (...)
>
> and yes
>
>         V_NAME=Friday
>         for (( INDEX=0; INDEX<$((10-${#V_NAME})) ; INDEX++ ))
>         do
>             echo $INDEX
>         done
>
> does also work, nevertheless using $(...) in the very first example is
> allowed
>
>
or even  for (( INDEX=0; INDEX<(10-${#V_NAME}) ; INDEX++ ))
but otherwise yes, syntax looks ok

--001a1146fe623cfc87054de7df77
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Mon, Apr 24, 2017 at 1:59 PM,  <span dir=3D"ltr">&lt;<a href=3D"mail=
to:werner@suse.de" target=3D"_blank">werner@suse.de</a>&gt;</span> wrote:<b=
r><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;borde=
r-left:1px solid rgb(204,204,204);padding-left:1ex">(...)<br>
<br>
and yes<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 V_NAME=3DFriday<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (( INDEX=3D0; INDEX&lt;$((10-${#V_NAME})) ;=
 INDEX++ ))<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 do<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo $INDEX<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 done<br>
<br>
does also work, nevertheless using $(...) in the very first example is allo=
wed<br>
<br>
</blockquote></div><br><div>or even=C2=A0 for (( INDEX=3D0; INDEX&lt;(10-${=
#V_NAME}) ; INDEX++ )) <br></div>but otherwise yes, syntax looks ok</div></=
div>

--001a1146fe623cfc87054de7df77--


From MAILER-DAEMON Mon Apr 24 07:41:37 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2cN7-0003OI-8c
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 07:41:37 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60564)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <werner@suse.de>) id 1d2cN4-0003LS-Uj
	for bug-bash@gnu.org; Mon, 24 Apr 2017 07:41:35 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <werner@suse.de>) id 1d2cMz-00050D-VI
	for bug-bash@gnu.org; Mon, 24 Apr 2017 07:41:34 -0400
Received: from mx2.suse.de ([195.135.220.15]:49160 helo=mx1.suse.de)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <werner@suse.de>) id 1d2cMz-0004zB-OV
	for bug-bash@gnu.org; Mon, 24 Apr 2017 07:41:29 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx1.suse.de (Postfix) with ESMTP id 20659AC81;
	Mon, 24 Apr 2017 11:41:28 +0000 (UTC)
Date: Mon, 24 Apr 2017 13:41:15 +0200
From: "Dr. Werner Fink" <werner@suse.de>
To: Pierre Gaston <pierre.gaston@gmail.com>
Cc: bug-bash@gnu.org
Subject: Re: Syntax error near unexpected token `newline' within loops
Message-ID: <20170424114115.zrwsvtyjf7vvtzi7@boole.suse.de>
References: <201704241059.v3OAx1cL012497@noether.suse.de>
	<CAPSX3sRjiMcqTiKXwSp0aN4qLW5a_6dw3YS4n5SfmkSCMC24Zg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="uvwc4b6cgv43gvqc"
Content-Disposition: inline
In-Reply-To: <CAPSX3sRjiMcqTiKXwSp0aN4qLW5a_6dw3YS4n5SfmkSCMC24Zg@mail.gmail.com>
User-Agent: Mutt/1.6.2 (2016-07-01)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 195.135.220.15
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 11:41:35 -0000


--uvwc4b6cgv43gvqc
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Apr 24, 2017 at 02:25:41PM +0300, Pierre Gaston wrote:
> On Mon, Apr 24, 2017 at 1:59 PM, <werner@suse.de> wrote:
>=20
> > (...)
> >
> > and yes
> >
> >         V_NAME=3DFriday
> >         for (( INDEX=3D0; INDEX<$((10-${#V_NAME})) ; INDEX++ ))
> >         do
> >             echo $INDEX
> >         done
> >
> > does also work, nevertheless using $(...) in the very first example is
> > allowed
> >
> >
> or even  for (( INDEX=3D0; INDEX<(10-${#V_NAME}) ; INDEX++ ))
> but otherwise yes, syntax looks ok

Yep ... the code could be more efficiently like

 V_NAME=3DFriday
 typeset -i len=3D$((10 - ${#V_NAME}))
 for (( INDEX=3D0; INDEX < len; INDEX++ )); do   echo $INDEX; done

=2E.. nevertheless even the intricate code should not cause an error I gues=
s :)

--=20
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

--uvwc4b6cgv43gvqc
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAABAgAGBQJY/eRbAAoJEFDpDVUdwWsuBCwP/RpiwIgLEN5MzjioWSBgRg1W
ntBQXpHg2hdu1x29teDGMyGb0bIcyoNJSw09SEc2g46XKaNSKJ1ThR+uOe4WxbDq
uDZDkJJ7qTlMMwP3koAT5oFggZzg91ghMP0Uib53EPKi6GEU6oIhJRY6qYKsc17E
ZcS5uoJb2xi/pO7RDxoNRItgZH7FM6bLaVYPweHrciaWvQKKDBJxZ4G2Gnz1jdNu
zIBNwCxrH1Ee6oaQ3M7KoOQUbSLefd9TPE3tplcwIQE5WmLMdLX/mRncAhr6nnRE
hJ/qu/NSqgyw8RgIIpbx1DOj8x9Tmi453Gy2pB9sK8Io1ClMI++09jOMgjwSOVi7
bWcV9oX6kL3OlaPKKqVztwNEsToZn1joiWreNW/DzUUBXKP1wdjgqB0W9MX3qz/l
WwXK9E7kExaFP/V/n3Xr1vN4yAqKR6TK8n6VbGUAw6PumpBJPvYDvgW+kuXY1DIe
67Q9cTBW3LhAlFN+tXZZDviPqjFrUHs5ydoM3DsydwJz3FVg34+BP8FB3T0ffLK7
NJ5YtkjjzSGUkZuGh1YLR5rBB9j3UCzrgK6wZST94q3CHUgx9Kjkslu5R/gFkqwR
mx4R2RR69wG8IT1m6Am/muZIPpziCyB7QsQBsa6xXxah1w9gUK7TPvX5kvicmrsE
ih16+gwZk1FhxrBX0FE0
=837Q
-----END PGP SIGNATURE-----

--uvwc4b6cgv43gvqc--


From MAILER-DAEMON Mon Apr 24 07:52:58 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2cY6-0005vc-9g
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 07:52:58 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34424)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@eggsh.com>) id 1d2cY3-0005vR-4J
	for bug-bash@gnu.org; Mon, 24 Apr 2017 07:52:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@eggsh.com>) id 1d2cXu-000828-NI
	for bug-bash@gnu.org; Mon, 24 Apr 2017 07:52:50 -0400
Received: from mail-bn3nam01on0066.outbound.protection.outlook.com
	([104.47.33.66]:6604
	helo=NAM01-BN3-obe.outbound.protection.outlook.com)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <bash@eggsh.com>) id 1d2cXu-00081q-Bp
	for bug-bash@gnu.org; Mon, 24 Apr 2017 07:52:46 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=SASOffice365.onmicrosoft.com; s=selector1-SASOffice365-onmicrosoft-com;
	h=From:Date:Subject:Message-ID:Content-Type:MIME-Version;
	bh=AUUTIffdy5IF6SGaIDxViXNRLwqBBgM2K0qqM0t6+io=;
	b=rvYj234ZYROmZMmLBv3T56bEDLXrf2p4gRgSo70xWXv0kUL+VGLzUKEIeU/E6u/lC8JNcBt/ipGDSBQlvFQslTMonNLrH+GBJPagrc6Cd6AVxvBE4C8pX+TOJzhRzaV1miy0jliKzBpmei28NjjyawGDHcfoxUzKEVXb5yhswsE=
Received: from CO2PR05CA043.namprd05.prod.outlook.com (10.141.241.171) by
	DM5PR05MB2857.namprd05.prod.outlook.com (10.168.175.149) with Microsoft
	SMTP Server (version=TLS1_2,
	cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id
	15.1.1047.6; Mon, 24 Apr 2017 08:18:22 +0000
Received: from SN1NAM02FT012.eop-nam02.prod.protection.outlook.com
	(2a01:111:f400:7e44::200) by CO2PR05CA043.outlook.office365.com
	(2a01:111:e400:1429::43) with Microsoft SMTP Server (version=TLS1_2,
	cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.6 via
	Frontend Transport; Mon, 24 Apr 2017 08:18:22 +0000
Authentication-Results: spf=none (sender IP is 149.173.1.110)
	smtp.mailfrom=eggsh.com; gnu.org; dkim=none (message not signed)
	header.d=none;gnu.org; dmarc=none action=none header.from=eggsh.com;
Received-SPF: None (protection.outlook.com: eggsh.com does not designate
	permitted sender hosts)
Received: from mail.sas.com (149.173.1.110) by
	SN1NAM02FT012.mail.protection.outlook.com (10.152.72.95) with Microsoft
	SMTP Server (version=TLS1_2,
	cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id
	15.1.1019.14 via Frontend Transport; Mon, 24 Apr 2017 08:18:21 +0000
Received: from [10.48.17.145] (10.48.17.145) by mercedge04d.na.sas.com
	(10.13.5.6) with Microsoft SMTP Server id 15.0.1263.5; Mon, 24 Apr 2017
	04:18:20 -0400
Subject: Re: Curious case of arithmetic expansion
To: <bug-bash@gnu.org>
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<ce1bad7e-858e-1fe9-943f-aafbe8eb8f71@case.edu>
	<FFF2A9D7-6890-4715-8DE0-BA0A53C15BFD@me.com>
	<48927d81-da3a-a69f-662a-ccbd7dbc352a@case.edu>
	<BC4FED5C-8914-463F-948F-F59EF136E440@me.com>
From: Steve Amerige <bash@eggsh.com>
Message-ID: <c7d4de8b-6d04-292c-ee1c-2aa85bc21b44@eggsh.com>
Date: Mon, 24 Apr 2017 04:18:20 -0400
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101
	Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <BC4FED5C-8914-463F-948F-F59EF136E440@me.com>
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-EOPAttributedMessage: 0
X-MS-Office365-Filtering-HT: Tenant
X-Forefront-Antispam-Report: CIP:149.173.1.110; IPV:NLI; CTRY:US; EFV:NLI;
	SFV:NSPM;
	SFS:(10009020)(39860400002)(39850400002)(39400400002)(39410400002)(39840400002)(39450400003)(2980300002)(428002)(45074003)(377454003)(51444003)(199003)(24454002)(189002)(50466002)(2351001)(4001350100001)(561944003)(189998001)(104016004)(101416001)(33646002)(106466001)(76176999)(54356999)(38730400002)(110136004)(105586002)(50986999)(8936002)(31686004)(83506001)(5660300001)(8676002)(606005)(229853002)(7906003)(54896002)(65956001)(77096006)(2870700001)(6246003)(236005)(6306002)(23676002)(65806001)(53546009)(65826007)(86362001)(31696002)(93886004)(23846002)(356003)(2950100002)(36756003)(2906002)(6916009)(3940600001)(42262002);
	DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR05MB2857; H:mail.sas.com;
	FPR:; SPF:None; MLV:sfv; A:1; MX:1; LANG:en; 
X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT012;
	1:13OS246O2gZFIcgfEIPhaOPhX4MLZ5PGDbmqjlszusvSknDYtYnVCjuVJkngL2Ta+bZJmEtlnqHEJnsfcP+Sm8XzQd3hbeBeLVFxZ+A57AF4afLUi24N1GuMQXhSMnnno5Ds7+0nYup8sMXfhQHtb7R47KHzYMlLxsNM9i5luMYlz9Utx/GvcHPmqzXIYYr8xCXluAbdhKylr1RmESz8KIgZfQzzI0c8gsqe/Hi0EaVhr5FOjRtqDRmqlIofjYmbd4wRORd80/alP5uizGZ88XHDcx9QZYm2NhqeXxrC9C/anDV4LBhe2xFo1odfiMv1j1mP1NGywzJ7epCK3xBHNZ2B485p9QYVeqUbcrlWfMacCYBrFtwNYEyK5UbwIRxaO9KHRus4VO7OLfPkMSI5z/z9+HyavyY7Vs8TaqHmex3E4RVS9QrXncZmQGE71+BXvkGDHSSCcM/jlgk44zKGOc1d2iYFd9H8CBB1kbWAOr1Jhvo1Dw5e59NIObjBtxxeVO6d1VCB+i08OD2gpVBW9eaNVDZFVMktnfVeBOlzNFXhNH9gS3DrSk7dfgZKSt22
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: 688e3486-d64e-49bb-55a2-08d48aea78ac
X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0;
	RULEID:(22001)(2017030254075)(201703131423075)(201703031133081);
	SRVR:DM5PR05MB2857; 
X-Microsoft-Exchange-Diagnostics: 1; DM5PR05MB2857;
	3:MBXxpPSVd/KnaHrfz6jY9PnV9Tws8cLAlsQZWH9mKhQOnRi49KB5B0iQon33VkY/GGZDbBSwEZXr2mFkwXpABiPvdnXdUKx98ZLXvkukWK7jYMNszT0dxe07el3AoUOd8lEqLvyiTTj83RWS38qCIM9nuVNiE9Dcbf3qbk7d1wbjOa6a11m75ViRjDIVDeEM73SF50UgJeG6vlp2p+o7hiCjlr5hqGVcAdYXbzj3TU7M5LeKjhydet7iu4lTR7//UDy73n7YQP1G66jBJuFzeWF9Fgm5QUTJmMUA3KnPg7Ce7H9GeMPK7DqqOAy6t7MqQZJf7UsqFJPNjcq7rSJQlp5e8em4FdTXH4fesf2x1TlbAXQpHgVdb8qUUcpbxcWwHqJJSzJg/OzXbjNqo1YQap1IxAU0Ja0UNZgD2FEQLEZlGzb+H1mSfxKbHqBJoMbrWjXV+PxJo6jPhB9thE4ytg==
X-Microsoft-Exchange-Diagnostics: 1; DM5PR05MB2857;
	25:G3ORwGZdqnLqGH3qQpSFqiETLjg+2ZbXfY0Q0Z7sGwupNF8Zajd9BGXlPk/670uJZEzO0xZsRXRoHCTovz554MXE/9I/Ed7UynyyuuYPZv2RsNTaiF8GyPGVqopzBzJEIA08WSCh8ebwCLHbRU3MDeEyOR3xlJ4dW5bbBTH7zV3j2VKiSMrZuOXjF8LTUHQ6hJwj91IvIjaELYMuXaGYMFL6ZMq7rwUmIHVtTQTeBqsDNAj3DW1jqQ7Hnc/QAP+Q4nQXtw90UGrydPELZb+k8/qm3hWKoiGCqHzHb3ANPldOPBIV3ya1sN+TFRvAMm6YYnoDsV0U9Psc/p6I0H85dcoJnuOoqNPcPi9Qz36AEa2lmS+NO9Py8Mv2ZL0XRymCH8aSVvtFDSaa7GuRYx2RYJife3YcJoevW46jb3tv46pV95qXG/+kRowuMqnUvHUfBEvYBPonVPXezmyUTP9Xa0svcsJ4VaOrFmhMPUdBObo=;
	31:wsRJR51wb5u2x5aYk0+w5epc9iTuF8idTX7ct8aDCBrrt2f9T2pk6VmOiXBvl963tfGP3PEUZs++A5Woe/FWjJQogsJ3UqIj3yoz/LgGT5Cv927m24T3plMazISgKRE9uAbjZEbVmjJIqLccl71BXq11Ri7LiJWXYhWGWpjn5LfO4Izx82AIlR9prCUFqHJwsosQI+wTpaHR+aauzJMD/SWM70uPT11OZg4mgMnpdPWCO249AseR71mQVNRp+B0FjJcqtuL0Jo+g3qV9i6avnofXvkRSJXqPnIlz2STIec8=
X-Microsoft-Exchange-Diagnostics: 1; DM5PR05MB2857;
	20:wTj6et0KB7gypKwlAQh1Vvu4IwID0HrVLYHnvXZkT7Ug8mzB7DGL9rL2kGHTD3WILCvw62PrBbd5Cii0AfeerQtq4MSa5/NeB//ZHy+F/ObtYNtEVfbnjw67QVc1jeZrJTNn+GA0uY7RP2j7NS05JTXPGUXiWDKkHGjtXylH5FV3VkF+RzEAB3I2eawfWyiHw/djWKeWGzh8jfOJlWszqW5DboLVOxG6/B23uuZFbj+Lb/N01USN65hCXvTATOQbOC9L8g7c1kP/G8LgUtDnxs2XNdyeDOAgMxAOrGrWp+z8/p+R+0CkgJFvDquq2O/D/aS4r9CWPKLulpNFo1PgxrxOB+fxf+quD4anQzw9yw+0lXCJq1cPtdCPPpUroKEsCbiaE4rbyZMDt/Zb1Bbn09Jz7APwdTe/5xqPsxcSPAB2bcT9NOBxxwP2TqRHSDHrBvVGiaReMDsesii/jk/qWBcbvWGqOsQsWXx6pgAsxWFsfInosCoikzDF7I7tBcdCfMwIZTksacaLl3PnFj6prsODrfOz1Kza+eKxkjZc021eEbBFTXMx5tj6EscHZjK72KpHLdGmilyo23N7wToI8eecWdfaMTENYmlxyYxV8kQ=
X-Microsoft-Antispam-PRVS: <DM5PR05MB2857584A5ABE6FB4A7B56711D31F0@DM5PR05MB2857.namprd05.prod.outlook.com>
X-Exchange-Antispam-Report-Test: UriScan:(188474585043545);
X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0;
	RULEID:(6040450)(601004)(2401047)(13023025)(13024025)(13018025)(13015025)(13017025)(8121501046)(5005006)(10201501046)(93006095)(93003095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(6072148);
	SRVR:DM5PR05MB2857; BCL:0; PCL:0; RULEID:; SRVR:DM5PR05MB2857; 
X-Microsoft-Exchange-Diagnostics: 1; DM5PR05MB2857;
	4:c1Q3PEKAWqGiAA854/x/Xh2NRvn6il3PRjs5RUQykqDnUxCbAIMQIH678GY2vHlBD5cjeEwMLpSYJL9IbBAdOU6kW14Wf1jjsW9BGIHmlTtxe7nphwWxcdZlO6t7Of+GTmFrrkWp8YBAjlSY0BFYkPT4IYDGA65xgoSjRXnvkiFf82CSWTNUWmLempUIN8QB3LNfhzPQ+Xjtd+MRXGl2HvxpMRy/gtCXyTLYMhGtnzfnr4PgT8VNShcFEhC4hAo83vi6wJnzJYoLJY9kw8gv5F46OkagGuxsSurUi9P08+ImxcKULNuvP8hami7PK4abAF/UpePaVtSS//TAC1umDQxzv1Tp58z7LKAO5vGVAqCH6HuF7+7OI0AvMnTuBpu5AHHiChR/j5Fohaw8dCjYWbmt5MvJoZEQ7EJvW1jAZBRIXXxsCAW5YGU1dvefDh5hVNVFVlS9ylLZQHnclocbu+QGXM8TQY0BNnYZloy+OdMt03drvvHqUrGHP55iEX6sYRYmwAm/L6TVJ0o+nLo6CtbV89GC3s68asOjV7IZ8KHsrzS5dHo0vkJSUw1/rDm30YN3EViOYdrndK6RHKeiquQQtQ5feeEj6k3VsW/drG5jJw3C8ktvV8PMnQghEVKys03NTTBK6IUpKBbMngZLQhKAWiAafOqeh1A5tzw56LhC+qVcXpMAoHh7DmOVXVtxkLyk00Yde4gSSpgIlvbsvmgrgiESV148cL2B8UrjhrBRNTSiUiyhkRhhf6tm1ftz0zBjMgEtUdGSrSkfPv4ndsILVBy9P3CIGy0v3r3d99/tSZZ9/iLQZFi0oUPAlAkaHrXcBuWXQcUcWDuF/XkVkrFDi7NJvydZ/zti3AAMbP/rGG42B782nJAvj7LnBYqp
X-Forefront-PRVS: 0287BBA78D
X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR05MB2857;
	23:PRPJAi1phWL9isKfAOGZtW2AcdtyOZrX0YAkAfVJT?=
	=?us-ascii?Q?8g88gZinZczUKGCJNwx3zkZRGPnnrS/zv4UxuoaMO9FT42J0MFZuw8zdEVuy?=
	=?us-ascii?Q?GuyaKT/KIxdznns1PE/QQ9nSzYIe7Boe1F7XzDrQ9AyIxqlGM6rD0ZFFyZQ0?=
	=?us-ascii?Q?NDP6oFtakvgh6Akn8XKnn+bkD+nvFiOAbhiY4aQ+qWK1ItvLuzBPFG25f0Ty?=
	=?us-ascii?Q?zWdiCnLRnAEax0pG3vniu+NCrATi0IvqLN0IHVrXS1Vmu5Ev8eSIBDmzEYyf?=
	=?us-ascii?Q?K1XMZ62LW4e+WYthbOE09y+Ee7U5iP35fC4lterbpdoeK2wS2roupZRqIzM0?=
	=?us-ascii?Q?tMELed8ZziwIZtlRyF7/3cL69QAln1kMaBVcVP4DLzs0qr/PfMRhv7rlCKUE?=
	=?us-ascii?Q?lFg44suz4meocPRo1OlBElxH/WRYfMN4dPCv+Jhd19vTvKG/eq20py9+PWRT?=
	=?us-ascii?Q?Gbf+1t7YdLUVxlUbnERWnsMiOHrku4WLK7BO3wv5FbA1seg71bWhexgC87dP?=
	=?us-ascii?Q?tSz+kFOYQHXqSLvRauMjOinY6AWwfwyAoH2bwWVLGP5TCMoJCHvHvyrWZqWq?=
	=?us-ascii?Q?h3++wyd8mc7fQE7LyFE9IYhXWdbF4qgMEEqdoc2bT5ZHfbtFD2A1U2bY6VQ3?=
	=?us-ascii?Q?onPOA+5hsiwkWvAp+KHD+qgeFAMXeFDWLy5sgBmP/GvcjbsvjHZDwG74Q+LT?=
	=?us-ascii?Q?bhOvbSgwGRVeEinm8UqTkYUJz1QK+NQCc6IMG7rqzRwlJL1pw9dxwemL3JRl?=
	=?us-ascii?Q?7L+waLliu0t1jRyaCnNrHhCOF7EECptSdlBqpoxfRTz/qaM71b5IYSK1ZVyQ?=
	=?us-ascii?Q?riR6HBp9kYEqzRhbL0CtxqsBtwfZXJ/Mnm2UZl1Vy1x8WP235/IovOY1UnXt?=
	=?us-ascii?Q?fI1WgjddbvLOtWXGhGE3oS2Dl11dKmRbVnTSWw4OX0pQroaFxkmUzolGHqgF?=
	=?us-ascii?Q?9ywTrTOGo2q4t7ijJ68vuPAW9SgHErPpYliNjPI923xADlI1Syw6EmlYADyq?=
	=?us-ascii?Q?1bq1byy+COy9eUCXRHSegQ7xnEbbwFsg2hSyTOlbaNDvkCTqdcRxleZQuOX6?=
	=?us-ascii?Q?g40LfHNZDKFZnNezIx0i7ML2j4PJdEh7HLF4sbUxwfhsw/lbVGiEf1si49C1?=
	=?us-ascii?Q?lHRkaikYHcjB8Gakp8eJ+rdf/BVFPSPkeCuMzMh7pEoguMWVK5rq74KXKYJJ?=
	=?us-ascii?Q?daPovLKnijPTSeWyjk5iesQuWyM6u34ywh5a2cF3R1qBMKWOiYdpRaGCX0AF?=
	=?us-ascii?Q?nx99bYNTCGOoM7eLbZncfRWPsVKnoJtDspq9Zi1EdyjtxlykFjdpMPk629/j?=
	=?us-ascii?Q?JS29cm5YHxbkX+cr/ittW4plnN3xIeVknUsoApolPVJrskbZ89016TN4c3tm?=
	=?us-ascii?Q?UaCk3gK5ABBND+NwIbZwOrUd+Dg8pQJBcqRCQFU6gA4vLp4m0DnC0Xc6ujWk?=
	=?us-ascii?Q?f09jYKQjA=3D=3D?=
X-Microsoft-Exchange-Diagnostics: 1; DM5PR05MB2857;
	6:HVbkIWQW/uR1N57kOXDWoUgAbpLJhGi2YEyrUKg3PTUxIfHT/akUbhMS//kIVHBiDu4Kk8C0wudAuVwL4osNZfpK9T3FlAM2OWcZMecRr+vxhLI4YROtiZJ5wxfDCgElyHhUVq+vsg2Y2mKDFKf+VHD9d5ibHYJJnBDwKn8mjy1AYEWvaYcF0QS3kQz4cMxEJwVFqloXJAjKdxtvJ+vYo8XdX0VaxCpaNpmPb62T+oKnhp3rK2qooUygrV1ga5BUGuqK7V9cb37l0E2slyaG4WgVcekZ3x3TYjrBO8ckg7r81sV9Il0ethmMiLTk6bBwaLRK8nwjeiYE2P00teCfHXpksPI1S5N6MEtG9I7i2X+W3Zpg6y44UwZyvBD1SV3FkAOUgnlRHQ3Ipsn5uYUzPbFWa7dfHbk9fUMGIosSJgekrOps7rudETHdbO9D7B1jSzv3tHZXjXsyBdd14+v+E46gzIEQ/GRIHAKR5gO0Qn+sOtsh+oOuE++Cp/bKL1jY9SM7MUHn8doBaadQ+VeUN5IjPhYfE7kGcuLjAcpxJHY=;
	5:qhLC7qYtoLk7AGa1mzyQynVNQdt4MKWOzSkvkxksNYXUF68pP8qie0SaT/94PfL5rjLNdajxhubgkinSV8iL3ijXmv8idxI76hVBHWWQ+csSh0Zl3aulgrbFFiV/xcviBduodusWrGPUaD+nHW8MgA==;
	24:JvSSVKvwowjJ1d1XfJIu4tsWwhK3qi+jc0WEzNb4fDR3r554Ud14rXZ12JtqKKfYRr3fcHtcnUg6AWlbi5V1yOu5NbQvHQsJBhXy3qHIgcw=
SpamDiagnosticOutput: 1:99
SpamDiagnosticMetadata: NSPM
X-Microsoft-Exchange-Diagnostics: 1; DM5PR05MB2857;
	7:2A/RBjh0u1jYted/VHfY+Ery7sTBfaH1M4AywENg9SVq6vSftWFL+uD5XDfCrIN4rIfhLwRzd8bmq98bduW3ebA2POrVhz3YkyivoyC8il4RcV0eqpxJ0wSqo0FF6scYrLV0svVn4LZ2vObgbmX2rxgDrnqW6n5n78tgDY6Je3I0jDYCq2YInxAAn7L2MtyZKiKDG9JqPAlXUh0GRtLQnP78xPvwsY9sLX//HYXfcb1vsZucOKl2GcGvEWkWFbppiP2qVmoQpHci+0dd9DSTmTRqSdIV6qCRXX5Qo6hgNbBAhF9rS4sxR5n9P1o7mm1bzdBc/ch6eNSEkA/FEaDxBw==
X-OriginatorOrg: SASOffice365.onmicrosoft.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2017 08:18:21.6529 (UTC)
X-MS-Exchange-CrossTenant-Id: b1c14d5c-3625-45b3-a430-9552373a0c2f
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=b1c14d5c-3625-45b3-a430-9552373a0c2f;
	Ip=[149.173.1.110]; Helo=[mail.sas.com]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR05MB2857
X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy]
X-Received-From: 104.47.33.66
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 11:52:56 -0000

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">It is essential to not break backward
      compatibility. Imagine the huge number of scripts that would be
      impacted by the semantic shift you're suggesting. If a proposal
      were to be made that would cause backward incompatibility, then
      any such proposal should be rejected unless there are truly
      compelling reasons for the proposal. Now, if you're proposing some
      new shopt (Bash-specific) or set -o (a broader set of sh shells)
      that would deliver some alternative behavior, then at least you
      wouldn't be breaking backward compatibility. However, any such
      addition would complicate the test matrix for shell behavior and
      should again be subject to very strong scrutiny and strong
      community desire for such a feature. I'm not sensing that this is
      the case for what you're describing.<br>
      <br>
      Best regards,<br>
      Steve Amerige<br>
      Eggsh: A Bash-Scripting Platform<br>
      <a class=3D"moz-txt-link-freetext" href=3D"https://eggsh.com">https:/=
/eggsh.com</a><br>
      <br>
      On 4/24/2017 3:59 AM, Florian Mayer wrote:<br>
    </div>
    <blockquote cite=3D"mid:BC4FED5C-8914-463F-948F-F59EF136E440@me.com"
      type=3D"cite">
      <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf=
-8">
      <div class=3D"">Ok, I accept your points, but please read on and
        decide after that.</div>
      <div class=3D""><br class=3D"">
        <blockquote type=3D"cite" class=3D"">to do anything but assign a
          value to `var'. =C2=A0Very few people, when asked,<br class=3D"">
          would say that it were more intuitive to cause a variable
          named `bar' to<br class=3D"">
          spring into existence with the value 7. If you want nameref
          behavior, you<br class=3D"">
          have to explicitly declare it.</blockquote>
      </div>
      <div class=3D"">But why<i class=3D"">=C2=A0</i>is nameref behavior in=
 the
        evaluation part activated by default</div>
      <div class=3D"">and not for the assignments? I think that one should<=
/div>
      <div class=3D"">either make nameref behavior the default case for
        both,=C2=A0</div>
      <div class=3D"">assignment and evaluation, or the non-default case
        for both.</div>
      <div class=3D""><br class=3D"">
      </div>
      <div class=3D"">In the latter case, where namerefs are off for both
        things, the lines (1) and (2)</div>
      <div class=3D"">1) var=3Dbar; bar=3D3; echo ((var))</div>
      <div class=3D"">2) var=3Dbar; ((var=3D3)) =C2=A0 or var=3Dbar; bar=3D=
0; ((var++))</div>
      <div class=3D"">should lead to an error message!</div>
      <div class=3D"">However the current status quo is, that bash happily
        does (1) as you=E2=80=99d=C2=A0</div>
      <div class=3D"">expect but gives out no error in (2) and overwrites
        (1).</div>
      <div class=3D""><br class=3D"">
      </div>
      <div class=3D"">
        <blockquote type=3D"cite" class=3D"">That is variable indirection.
          It has superficially similar effects to what<br class=3D"">
          we are discussing, which is arithmetic expansion; however, it
          has nothing<br class=3D"">
          to do with the behavior of (( )) or $(( )).</blockquote>
      </div>
      <div class=3D"">Again, I never wrote, that, from a technical point
        of view, it has something to do</div>
      <div class=3D"">with (()) or $(()). Merely the visible behavior is
        similar in the cases I showed.</div>
      <div class=3D""><br class=3D"">
      </div>
      <div>
        <blockquote type=3D"cite" class=3D"">
          <div class=3D"">Am 24.04.2017 um 01:43 schrieb Chet Ramey &lt;<a
              moz-do-not-send=3D"true" href=3D"mailto:chet.ramey@case.edu"
              class=3D"">chet.ramey@case.edu</a>&gt;:</div>
          <br class=3D"Apple-interchange-newline">
          <div class=3D"">
            <div class=3D"">On 4/23/17 4:25 PM, Florian Mayer wrote:<br
                class=3D"">
              <blockquote type=3D"cite" class=3D"">
                <blockquote type=3D"cite" class=3D"">That's not a reasonabl=
e
                  expectation.<br class=3D"">
                </blockquote>
                Why not? Why is it not reasonable to expect an intuitive<br
                  class=3D"">
                result from (())? The most intuitive thing, in my
                opinion,<br class=3D"">
                would be to use nameref for side effects by default,
                because in order<br class=3D"">
                to get a value from an id, (()) already follows
                namerefs.<br class=3D"">
              </blockquote>
              <br class=3D"">
              The thing that makes that result intuitive for you is your
              opinion about<br class=3D"">
              how things should work. =C2=A0That's fine. I don't happen to
              share your opinion<br class=3D"">
              of what is "intuitive" in this case.<br class=3D"">
              <br class=3D"">
              However, it is unreasonable to expect<br class=3D"">
              <br class=3D"">
              <span class=3D"Apple-tab-span" style=3D"white-space:pre">	</s=
pan>var=3Dbar<br
                class=3D"">
              <span class=3D"Apple-tab-span" style=3D"white-space:pre">	</s=
pan>((
              var=3D7 ))<br class=3D"">
              <br class=3D"">
              to do anything but assign a value to `var'. =C2=A0Very few
              people, when asked,<br class=3D"">
              would say that it were more intuitive to cause a variable
              named `bar' to<br class=3D"">
              spring into existence with the value 7. If you want
              nameref behavior, you<br class=3D"">
              have to explicitly declare it.<br class=3D"">
              <br class=3D"">
              <br class=3D"">
              <blockquote type=3D"cite" class=3D"">
                <blockquote type=3D"cite" class=3D"">It's not indirection,
                  and I am not sure why you show the completely<br
                    class=3D"">
                </blockquote>
                I was mentioning that, not because I use =E2=80=9Ea mental
                model=E2=80=9C that falsely unifies<br class=3D"">
                both things, but because I wanted to point out that
                there exists something<br class=3D"">
                with a similar behavior.<br class=3D"">
                <br class=3D"">
                And if ${!&lt;varid&gt;} does not portray some kind of
                indirection, what do you<br class=3D"">
                call it then?<br class=3D"">
              </blockquote>
              <br class=3D"">
              That is variable indirection. It has superficially similar
              effects to what<br class=3D"">
              we are discussing, which is arithmetic expansion; however,
              it has nothing<br class=3D"">
              to do with the behavior of (( )) or $(( )).</div>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>


From MAILER-DAEMON Mon Apr 24 08:44:46 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2dME-0005cz-86
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 08:44:46 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51264)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1d2dMC-0005bx-9D
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:44:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1d2dM8-00084g-Vw
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:44:44 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:47252 helo=svr4.eeg.ccf.org)
	by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1d2dM8-0007yt-O2
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:44:40 -0400
Received: (qmail 7427 invoked from network); 24 Apr 2017 12:44:11 -0000
Received: from imadev.eeg.ccf.org (qmailr@10.76.173.78)
	by gateway.eeg.ccf.org with SMTP; Mon, 24 Apr 2017 08:44:11 -0400
Received: (qmail 9908 invoked by uid 563); 24 Apr 2017 12:44:11 -0000
Date: Mon, 24 Apr 2017 08:44:11 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: werner@suse.de
Cc: bug-bash@gnu.org
Subject: Re: Syntax error near unexpected token `newline' within loops
Message-ID: <20170424124411.GX20910@eeg.ccf.org>
References: <201704241059.v3OAx1cL012497@noether.suse.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201704241059.v3OAx1cL012497@noether.suse.de>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 139.137.100.1
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 12:44:45 -0000

On Mon, Apr 24, 2017 at 12:59:01PM +0200, werner@suse.de wrote:
> 	V_NAME=Friday
> 	for (( INDEX=0; INDEX<$((10-$(expr length $V_NAME))); INDEX++ ))

The outer (( )) in the C-style for loop already create an arithmetic
expression context.  You don't need to use $(( )) inside them.  You can
simply write:

for (( INDEX=0; INDEX<10-${#V_NAME};; INDEX++ ))

By the way, the [ ] index syntax in an indexed (not associative) array
expansion works the same way.  You can simply write:

"${a[x+1]}"

instead of

"${a[$((x+1))]}"


From MAILER-DAEMON Mon Apr 24 08:50:06 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2dRO-0007SY-FF
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 08:50:06 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52703)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d2dRH-0007Rw-MB
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:50:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d2dRG-0001MI-HG
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:49:59 -0400
Received: from mail-it0-x233.google.com ([2607:f8b0:4001:c0b::233]:35376)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d2dRG-0001M6-Br
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:49:58 -0400
Received: by mail-it0-x233.google.com with SMTP id 70so56404814ita.0
	for <bug-bash@gnu.org>; Mon, 24 Apr 2017 05:49:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=uiaeZnL/C+/F0FZK7l8sblcZBDH1bXIVfdR6+LMDYqc=;
	b=McMV98slR7YywkVB3XkV2/ONcbAzzJ2HHz7lQG2EbL3GHtVehvFLfllTFfgopAqSJW
	8ahMYSIxWkayH14c69YaNv9Uhf6c5Tgp/rz76LwM5too8ROU68NYSVGkegqm757APOoD
	EIgsrrFLB9tdwIJH9WsKaVGILYmdQLba1SaqlqP4f50P3JC6tm2jxozpLTHKN0V2kA/1
	IdyHUB13dUeH+TeS48omp0Nk9Ljs/xRKFSdoAS5c3JguwJm+TklN+8dKzMiLddUAmqh1
	dhYZseY4ad+jE4pX5PpOD/VdDJG8QOmss4pCC5n582gztvgJNqSAVwSFYDA1Zipz4clh
	2DuA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=uiaeZnL/C+/F0FZK7l8sblcZBDH1bXIVfdR6+LMDYqc=;
	b=I7VB4gyJQxjeI7mggHqRDhVMbPOzFEMI4v/StXexxOUltkRVsbJrauQjGghpXlOWz3
	sb/8p1H9X61/wF7I3L27i55bcZQYVOUjxWjYw1D6MqV3mwa9InALGkvveyTHqBZ3Jy3X
	5xI4raYSUdmk+5ocLmPsyUBOJAzz1mpKT+SRrBOva39f5hGJQdoGXPecMxfYCVB7pUWX
	WL01cNjJHWysyKQ7O0YPNim4KiXhLOBg8Ev6FkxhGi2UBJqMV9/Sk5OuXYERoZySGd5G
	bjiuhxG+NaUDnaEJvEttgDKu7jkqvieCtd0fpWdasmszh+SJlXRKYK4U+UtCLv1w2mEr
	Kp+A==
X-Gm-Message-State: AN3rC/7nvs0CObHQuPwzXoi+tVzngOVSZ+jnHnVJ7q1Jjrb5dYV9frK5
	mnl3proixnS7vnbjn1HVSq+fK/+25fsO
X-Received: by 10.36.73.155 with SMTP id e27mr13847375itd.6.1493038196591;
	Mon, 24 Apr 2017 05:49:56 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Mon, 24 Apr 2017 05:49:36 -0700 (PDT)
In-Reply-To: <20170424124411.GX20910@eeg.ccf.org>
References: <201704241059.v3OAx1cL012497@noether.suse.de>
	<20170424124411.GX20910@eeg.ccf.org>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Mon, 24 Apr 2017 07:49:36 -0500
Message-ID: <CAOSMAutioLyJ0qodrDrWdyfR2+riyZGLDkrUQMt4JY+KSBv7XQ@mail.gmail.com>
Subject: Re: Syntax error near unexpected token `newline' within loops
To: Greg Wooledge <wooledg@eeg.ccf.org>
Cc: werner@suse.de, "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c0b::233
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 12:50:05 -0000

On Mon, Apr 24, 2017 at 7:44 AM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
[...]
> The outer (( )) in the C-style for loop already create an arithmetic
> expression context.  You don't need to use $(( )) inside them.  You can
> simply write:
>
> for (( INDEX=0; INDEX<10-${#V_NAME};; INDEX++ ))

I think this is just to show the bug. i.e. these two should do the same:

dualbus@debian:~$ bash -c 'for (( ; $(($(:))); )); do :; done'
bash: -c: line 0: syntax error near unexpected token `newline'
bash: -c: line 0: `for (( ; $(($(:))); )); do :; done'

dualbus@debian:~$ bash -c 'for (( ; $((`:`)); )); do :; done'


From MAILER-DAEMON Mon Apr 24 08:56:19 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2dXP-0000ew-1C
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 08:56:19 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53988)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <werner@suse.de>) id 1d2dXM-0000ep-Nz
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:56:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <werner@suse.de>) id 1d2dXJ-0002uK-LG
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:56:16 -0400
Received: from mx2.suse.de ([195.135.220.15]:33371 helo=mx1.suse.de)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <werner@suse.de>) id 1d2dXJ-0002tH-Dq
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:56:13 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx1.suse.de (Postfix) with ESMTP id E15E4ACE7;
	Mon, 24 Apr 2017 12:56:11 +0000 (UTC)
Date: Mon, 24 Apr 2017 14:56:09 +0200
From: "Dr. Werner Fink" <werner@suse.de>
To: Greg Wooledge <wooledg@eeg.ccf.org>
Cc: bug-bash@gnu.org
Subject: Re: Syntax error near unexpected token `newline' within loops
Message-ID: <20170424125609.mutmntkbf3erliug@boole.suse.de>
References: <201704241059.v3OAx1cL012497@noether.suse.de>
	<20170424124411.GX20910@eeg.ccf.org>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="2jucpdb4l6q3cjdu"
Content-Disposition: inline
In-Reply-To: <20170424124411.GX20910@eeg.ccf.org>
User-Agent: Mutt/1.6.2 (2016-07-01)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 195.135.220.15
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 12:56:17 -0000


--2jucpdb4l6q3cjdu
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Apr 24, 2017 at 08:44:11AM -0400, Greg Wooledge wrote:
> On Mon, Apr 24, 2017 at 12:59:01PM +0200, werner@suse.de wrote:
> > 	V_NAME=3DFriday
> > 	for (( INDEX=3D0; INDEX<$((10-$(expr length $V_NAME))); INDEX++ ))
>=20
> The outer (( )) in the C-style for loop already create an arithmetic
> expression context.  You don't need to use $(( )) inside them.  You can
> simply write:
>=20
> for (( INDEX=3D0; INDEX<10-${#V_NAME};; INDEX++ ))
>=20
> By the way, the [ ] index syntax in an indexed (not associative) array
> expansion works the same way.  You can simply write:
>=20
> "${a[x+1]}"
>=20
> instead of
>=20
> "${a[$((x+1))]}"

Yes I know ... nevertheless, the initial code should not trigger an error
=2E.. to make it sure, the initial example was given by a user asking me
why this triggers an error, which IMHO it should not.

--=20
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

--2jucpdb4l6q3cjdu
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAABAgAGBQJY/fXpAAoJEFDpDVUdwWsuy1oP/2GvoXoFFd7StooEldHDlatH
aPAv8b4QbiZNR9TDQR3dS7+Ph9lEwWpR/kneExpuaDYXpYpiCnE/MRpkhSsKfPGo
Kjjzm7tcBaCEQsCN4pEDxcD86oiDooIZ539LcYY0rW5sfT9SeT6Ek3+cs9q/EYJt
r/a4OX5k5necrnJgu/a0iOwlR6EcwTl2krdUcxnfMImKgWb8+i6OCBTI/TsjEOoq
WhMrjtJ/vVE8ZKRS7dXDRCmvKTVnteIXQVTS1FrlQ3DuX3cuyGQze2gaB9BJxjNt
HWJspY02D8ersPc+QnbrJ8YC84ct7BIhA3j2QPPh6s5i5j8H6Y2eDuAXjd2o6rVw
zBhrA4tAesrz38rfashZlJWnCDrGKNlIV4hMn/fCCuKbV9qof2RB8W03O0QdhQif
nH8ctQhsPr4fI/g/DZuFT4KE33kiz18LwYxVupUzcrDtOQSj3bP8rn+1An6hi3OO
3orDOOj8z3hUVYSj+Rm0nTZxqCU/oVz9rVjK3Vt+w4vC8zwVgoeDyJyWF/iZD/ba
upRWUU4TFMDbyS6kQzq/KFNglCaQc0rIOa6Ye/DzAOOeUBzHZfHHDHlnhUrILpse
fA8DyMeLXGKlT9rnuMY9F00/393MOMk2aA2lDX/vH8/9rsctIccFV8zzZquhBwxl
ld6KY9YRLkByRUApIPWg
=Johe
-----END PGP SIGNATURE-----

--2jucpdb4l6q3cjdu--


From MAILER-DAEMON Mon Apr 24 08:58:15 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2dZH-00017E-F7
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 08:58:15 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:54257)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1d2dZF-00015h-QM
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:58:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1d2dZA-0003GQ-MR
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:58:13 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:47264 helo=svr4.eeg.ccf.org)
	by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1d2dZA-0003GK-F9
	for bug-bash@gnu.org; Mon, 24 Apr 2017 08:58:08 -0400
Received: (qmail 7590 invoked from network); 24 Apr 2017 12:58:07 -0000
Received: from imadev.eeg.ccf.org (qmailr@10.76.173.78)
	by gateway.eeg.ccf.org with SMTP; Mon, 24 Apr 2017 08:58:07 -0400
Received: (qmail 9980 invoked by uid 563); 24 Apr 2017 12:58:07 -0000
Date: Mon, 24 Apr 2017 08:58:07 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
Subject: Re: Syntax error near unexpected token `newline' within loops
Message-ID: <20170424125807.GZ20910@eeg.ccf.org>
References: <201704241059.v3OAx1cL012497@noether.suse.de>
	<20170424124411.GX20910@eeg.ccf.org>
	<CAOSMAutioLyJ0qodrDrWdyfR2+riyZGLDkrUQMt4JY+KSBv7XQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAOSMAutioLyJ0qodrDrWdyfR2+riyZGLDkrUQMt4JY+KSBv7XQ@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 139.137.100.1
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 12:58:14 -0000

On Mon, Apr 24, 2017 at 07:49:36AM -0500, Eduardo Bustamante wrote:
> On Mon, Apr 24, 2017 at 7:44 AM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> [...]
> > The outer (( )) in the C-style for loop already create an arithmetic
> > expression context.  You don't need to use $(( )) inside them.  You can
> > simply write:
> >
> > for (( INDEX=0; INDEX<10-${#V_NAME};; INDEX++ ))
> 
> I think this is just to show the bug. i.e. these two should do the same:
> 
> dualbus@debian:~$ bash -c 'for (( ; $(($(:))); )); do :; done'
> bash: -c: line 0: syntax error near unexpected token `newline'
> bash: -c: line 0: `for (( ; $(($(:))); )); do :; done'
> 
> dualbus@debian:~$ bash -c 'for (( ; $((`:`)); )); do :; done'

Yeah, I'm not disputing whether there's actually a bug here, just
pointing out that the code can be simplified to avoid it.  The fact that
no sane person should write code this way is probably why the bug went
undiscovered for so long.

Seriously, "expr length"?!  In a script that is already using bashisms?


From MAILER-DAEMON Mon Apr 24 09:02:05 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2dcz-0002My-AL
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 09:02:05 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:54953)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <reuti@staff.uni-marburg.de>) id 1d2dcw-0002MG-9i
	for bug-bash@gnu.org; Mon, 24 Apr 2017 09:02:03 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <reuti@staff.uni-marburg.de>) id 1d2dcr-0004Up-BV
	for bug-bash@gnu.org; Mon, 24 Apr 2017 09:02:02 -0400
Received: from vhrz24.hrz.uni-marburg.de ([137.248.1.34]:58502)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <reuti@staff.uni-marburg.de>)
	id 1d2dcr-0004RP-4N
	for bug-bash@gnu.org; Mon, 24 Apr 2017 09:01:57 -0400
Received: from ma15106.chemie.uni-marburg.de (ma15106.Chemie.Uni-Marburg.DE
	[137.248.150.142]) (authenticated bits=0)
	by vhrz24.HRZ.Uni-Marburg.DE (8.14.4/8.14.4/Debian-8+deb8u1) with ESMTP
	id v3OD1gW5056472
	(version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); 
	Mon, 24 Apr 2017 15:01:42 +0200
Subject: Re: Syntax error near unexpected token `newline' within loops
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
Content-Type: multipart/signed;
	boundary="Apple-Mail=_F55B57F1-C1B5-4F9B-87D8-05E77C8113BE";
	protocol="application/pgp-signature"; micalg=pgp-sha1
X-Pgp-Agent: GPGMail
From: Reuti <reuti@staff.uni-marburg.de>
In-Reply-To: <20170424125807.GZ20910@eeg.ccf.org>
Date: Mon, 24 Apr 2017 15:01:41 +0200
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Message-Id: <909678DB-00A0-482E-B464-3AF1861F7A56@staff.uni-marburg.de>
References: <201704241059.v3OAx1cL012497@noether.suse.de>
	<20170424124411.GX20910@eeg.ccf.org>
	<CAOSMAutioLyJ0qodrDrWdyfR2+riyZGLDkrUQMt4JY+KSBv7XQ@mail.gmail.com>
	<20170424125807.GZ20910@eeg.ccf.org>
To: Greg Wooledge <wooledg@eeg.ccf.org>
X-Mailer: Apple Mail (2.2104)
X-Null-Tag: 455f68dca4acb3d4ecdc0401a7d61ea4
X-UniMR-MailScanner-Information: see
	http://www.uni-marburg.de/hrz/internet/mail/spam/
X-UniMR-MailScanner-ID: v3OD1gW5056472
X-UniMR-MailScanner: Found to be clean
X-UniMR-MailScanner-From: reuti@staff.uni-marburg.de
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 137.248.1.34
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 13:02:03 -0000


--Apple-Mail=_F55B57F1-C1B5-4F9B-87D8-05E77C8113BE
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii


> Am 24.04.2017 um 14:58 schrieb Greg Wooledge <wooledg@eeg.ccf.org>:
>=20
> On Mon, Apr 24, 2017 at 07:49:36AM -0500, Eduardo Bustamante wrote:
>> On Mon, Apr 24, 2017 at 7:44 AM, Greg Wooledge <wooledg@eeg.ccf.org> =
wrote:
>> [...]
>>> The outer (( )) in the C-style for loop already create an arithmetic
>>> expression context.  You don't need to use $(( )) inside them.  You =
can
>>> simply write:
>>>=20
>>> for (( INDEX=3D0; INDEX<10-${#V_NAME};; INDEX++ ))
>>=20
>> I think this is just to show the bug. i.e. these two should do the =
same:
>>=20
>> dualbus@debian:~$ bash -c 'for (( ; $(($(:))); )); do :; done'
>> bash: -c: line 0: syntax error near unexpected token `newline'
>> bash: -c: line 0: `for (( ; $(($(:))); )); do :; done'
>>=20
>> dualbus@debian:~$ bash -c 'for (( ; $((`:`)); )); do :; done'
>=20
> Yeah, I'm not disputing whether there's actually a bug here, just
> pointing out that the code can be simplified to avoid it.  The fact =
that
> no sane person should write code this way is probably why the bug went
> undiscovered for so long.

AFAICS in version 4.2.45(1) it works as expected.

-- Reuti


> Seriously, "expr length"?!  In a script that is already using =
bashisms?


--Apple-Mail=_F55B57F1-C1B5-4F9B-87D8-05E77C8113BE
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAlj99zYACgkQo/GbGkBRnRp8IQCfV4p+3R74u6Pkq36iR5DOP0cJ
DpYAnR1urSuruDcwedlfP7MrYpEe7Bn6
=rY73
-----END PGP SIGNATURE-----

--Apple-Mail=_F55B57F1-C1B5-4F9B-87D8-05E77C8113BE--


From MAILER-DAEMON Mon Apr 24 11:13:45 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2fgP-0002gd-AS
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 11:13:45 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33900)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2fgN-0002fF-3t
	for bug-bash@gnu.org; Mon, 24 Apr 2017 11:13:44 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2fgJ-0001bT-Nf
	for bug-bash@gnu.org; Mon, 24 Apr 2017 11:13:43 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:51861
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d2fgJ-0001b7-Ha
	for bug-bash@gnu.org; Mon, 24 Apr 2017 11:13:39 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMU79175; Mon, 24 Apr 2017 11:13:37 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDF97749 (AUTH cpr);
	Mon, 24 Apr 2017 11:13:37 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Using Clang's static analyzer on bash
References: <CAOSMAuvABhAm=6M6nk=0v+bXvV6+MgzytVcgbu18J7pp48TKVQ@mail.gmail.com>
To: Eduardo Bustamante <dualbus@gmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <4ce71a35-881e-52ed-33c1-056a8ea5d763@case.edu>
Date: Mon, 24 Apr 2017 11:13:37 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOSMAuvABhAm=6M6nk=0v+bXvV6+MgzytVcgbu18J7pp48TKVQ@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.24.135717:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __HTTPS_URI,
	__URI_WITH_PATH, URI_ENDS_IN_HTML, __URI_NO_WWW,
	__CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR,
	__SUBJ_ALPHA_NEGATE, __MULTIPLE_URI_TEXT, __URI_IN_BODY,
	__URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW,
	BODY_SIZE_700_799, BODYTEXTP_SIZE_3000_LESS,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 15:13:44 -0000

On 4/23/17 9:02 PM, Eduardo Bustamante wrote:
> I built bash using scan-build
> (https://clang-analyzer.llvm.org/scan-build.html) and I noticed that
> it was able to detect the null pointer dereference reported earlier by
> Jaren (https://lists.gnu.org/archive/html/bug-bash/2017-04/msg00100.html).
> 
> dualbus@debian:~/src/gnu/bash$ scan-build-3.9 make
> scan-build: Using '/usr/lib/llvm-3.9/bin/clang' for static analysis

I'd be interested in seeing the results.  In my experience with similar
tools, the false positive ratio is very high.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Mon Apr 24 11:28:37 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2fum-0005Vi-Uy
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 11:28:36 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:37790)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2fuk-0005UH-Hh
	for bug-bash@gnu.org; Mon, 24 Apr 2017 11:28:35 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2fuh-0006fE-DJ
	for bug-bash@gnu.org; Mon, 24 Apr 2017 11:28:34 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:58286
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d2fuh-0006f6-7m
	for bug-bash@gnu.org; Mon, 24 Apr 2017 11:28:31 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMP60291; Mon, 24 Apr 2017 11:28:27 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDG01903 (AUTH cpr);
	Mon, 24 Apr 2017 11:28:26 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Curious case of arithmetic expansion
References: <EED9AE82-3A2E-43B0-B060-14362AC0A289@me.com>
	<CAPSX3sQVZh1C=OnV-cddAmJpONmHN7tbKnfWHKVCxAt7UU3fmA@mail.gmail.com>
	<7AF3F4DF-D7A6-490C-B2C1-365FFB1960D9@me.com>
	<ce1bad7e-858e-1fe9-943f-aafbe8eb8f71@case.edu>
	<FFF2A9D7-6890-4715-8DE0-BA0A53C15BFD@me.com>
	<48927d81-da3a-a69f-662a-ccbd7dbc352a@case.edu>
	<BC4FED5C-8914-463F-948F-F59EF136E440@me.com>
To: Florian Mayer <mayerflorian@me.com>, "bug-bash@gnu.org" <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <13830804-acd7-c18a-f536-6d90ad85d79e@case.edu>
Date: Mon, 24 Apr 2017 11:28:26 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <BC4FED5C-8914-463F-948F-F59EF136E440@me.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Status: score=7/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.24.141816:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_2000_2999, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY,
	BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 15:28:35 -0000

On 4/24/17 3:59 AM, Florian Mayer wrote:
> Ok, I accept your points, but please read on and decide after that.
> 
>> to do anything but assign a value to `var'.  Very few people, when asked,
>> would say that it were more intuitive to cause a variable named `bar' to
>> spring into existence with the value 7. If you want nameref behavior, you
>> have to explicitly declare it.
> But why/ /is nameref behavior in the evaluation part activated by default
> and not for the assignments? I think that one should
> either make nameref behavior the default case for both, 
> assignment and evaluation, or the non-default case for both.

OK, you can certainly have whatever opinion you want.  However, 27 years
ago when I put this into bash, there was considerable benefit from
supporting running variable values through the expression evaluator instead
of simply coercing their value to an integer.  That allowed, in the most
basic use case, a simple arithmetic macro facility.  You could also
do more complicated things like compose complex expressions.

There was no similar benefit from recursively expanding variable names.
There still isn't.  And there is no compelling reason for such a radical
break with existing behavior.  Nobody besides you has ever requested it.

> In the latter case, where namerefs are off for both things, the lines (1)
> and (2)
> 1) var=bar; bar=3; echo ((var))
> 2) var=bar; ((var=3))   or var=bar; bar=0; ((var++))
> should lead to an error message!
> However the current status quo is, that bash happily does (1) as youâ€™d 
> expect but gives out no error in (2) and overwrites (1).

You're saying that something like ((var=3)) should produce an error
instead of assign `3' to `var'? Really? Or that var++ should not behave
identically to `ovar=$var, var=$(( ovar + 1 )), ovar'?

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Mon Apr 24 16:42:18 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2koL-0007RL-VO
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 16:42:17 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57486)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2koJ-0007QM-DP
	for bug-bash@gnu.org; Mon, 24 Apr 2017 16:42:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2koF-0006T8-Uj
	for bug-bash@gnu.org; Mon, 24 Apr 2017 16:42:15 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:50956
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d2koF-0006Q3-OD
	for bug-bash@gnu.org; Mon, 24 Apr 2017 16:42:11 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMU99826; Mon, 24 Apr 2017 16:42:08 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDG73166 (AUTH cpr);
	Mon, 24 Apr 2017 16:42:08 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Syntax error near unexpected token `newline' within loops
References: <201704241059.v3OAx1cL012497@noether.suse.de>
To: werner@suse.de, bug-bash@gnu.org
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <047f553e-fc7a-5ac0-1355-4eee8077ab5d@case.edu>
Date: Mon, 24 Apr 2017 16:42:07 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <201704241059.v3OAx1cL012497@noether.suse.de>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.24.200016:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NO_NAME, __HAS_CC_HDR, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR,
	__SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG,
	__FORWARDED_MSG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_900_999,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, __SINGLE_URI_TEXT,
	[TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 20:42:16 -0000

On 4/24/17 6:59 AM, werner@suse.de wrote:

> Bash Version: 4.4
> Patch Level: 12
> Release Status: release
> 
> Description:
> 	Since 4.3 including 4.4 bash shows a bug in loops using nested ((...)), $((..)), and $(...)
> 
> Repeat-By:
> The bash code
> 
> 	V_NAME=Friday
> 	for (( INDEX=0; INDEX<$((10-$(expr length $V_NAME))); INDEX++ ))
> 	do
> 	    echo $INDEX
> 	done
> 
> leads to
> 
>         bash: syntax error near unexpected token `newline'

Thanks for the report.  It's a consequence of recursively invoking the
parser for the command substitution, which bash-4.3 and later do.  There's
more and more yacc/bison internal state I find out about as these semi-
obscure reports come in.  I'll fix it.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Mon Apr 24 16:48:36 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d2kuS-00018R-7n
	for mharc-bug-bash@gnu.org; Mon, 24 Apr 2017 16:48:36 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:32974)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2kuQ-00018C-3q
	for bug-bash@gnu.org; Mon, 24 Apr 2017 16:48:35 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d2kuN-0004Gp-HW
	for bug-bash@gnu.org; Mon, 24 Apr 2017 16:48:34 -0400
Received: from mpv3-2015.cwru.edu ([129.22.103.194]:55379
	helo=mpv3-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d2kuN-0004GJ-Au
	for bug-bash@gnu.org; Mon, 24 Apr 2017 16:48:31 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv3-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALP99575; Mon, 24 Apr 2017 16:48:28 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDG73959 (AUTH cpr);
	Mon, 24 Apr 2017 16:48:27 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Syntax error near unexpected token `newline' within loops
References: <201704241059.v3OAx1cL012497@noether.suse.de>
	<20170424124411.GX20910@eeg.ccf.org>
	<CAOSMAutioLyJ0qodrDrWdyfR2+riyZGLDkrUQMt4JY+KSBv7XQ@mail.gmail.com>
	<20170424125807.GZ20910@eeg.ccf.org>
To: Greg Wooledge <wooledg@eeg.ccf.org>, "bug-bash@gnu.org" <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <2ec653de-2def-d2eb-3da6-e2df13d79121@case.edu>
Date: Mon, 24 Apr 2017 16:48:27 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <20170424125807.GZ20910@eeg.ccf.org>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv3-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.24.194216:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_400_LESS, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_300_399, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS,
	__SINGLE_URI_TEXT, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.194
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Mon, 24 Apr 2017 20:48:35 -0000

On 4/24/17 8:58 AM, Greg Wooledge wrote:

> Seriously, "expr length"?!  In a script that is already using bashisms?

That works on Linux, but not on the BSDs, since Posix says it doesn't
have to.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Tue Apr 25 11:29:39 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d32PL-0003dY-S5
	for mharc-bug-bash@gnu.org; Tue, 25 Apr 2017 11:29:39 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34190)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <llord@dnwks49>) id 1d31c2-0003GU-0L
	for bug-bash@gnu.org; Tue, 25 Apr 2017 10:38:42 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <llord@dnwks49>) id 1d31bx-00006I-1D
	for bug-bash@gnu.org; Tue, 25 Apr 2017 10:38:42 -0400
Received: from 188-39-136-34.static.enta.net ([188.39.136.34]:48512
	helo=dnwks49)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <llord@dnwks49>) id 1d31bw-000068-R0
	for bug-bash@gnu.org; Tue, 25 Apr 2017 10:38:36 -0400
Received: from dnwks49 (localhost [127.0.0.1])
	by dnwks49 (8.15.2/8.15.2/Debian-3) with ESMTP id v3PEAXEv029576;
	Tue, 25 Apr 2017 15:10:33 +0100
Received: (from llord@localhost)
	by dnwks49 (8.15.2/8.15.2/Submit) id v3PEAXGW029562;
	Tue, 25 Apr 2017 15:10:33 +0100
Date: Tue, 25 Apr 2017 15:10:33 +0100
Message-Id: <201704251410.v3PEAXGW029562@dnwks49>
From: scragar@gmail.com
To: bug-bash@gnu.org, bash@packages.debian.org
Subject: shquote.c incorrectly escapes comma, but not tilde
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 188.39.136.34
X-Mailman-Approved-At: Tue, 25 Apr 2017 11:29:38 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 25 Apr 2017 14:38:42 -0000

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall
uname output: Linux dnwks49 4.4.0-72-generic #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.3
Patch Level: 46
Release Status: release

Description:
	When using any functionality that triggers shquote the
	comma character is escaped with a backslash which bash
	doesn't strip when the quoted text is reused, while
	tilde isn't despite it causing home directory expansion.

Repeat-By:
	Run
		echo $(printf "%q" "~" "a,b")
	Expected output:
		~ a,b
	Given output
		/home/scragar a\,b

Fix:
	patching /lib/sh/shquote.c to have the bstab to have zero
	for comma and a 1 for the tilde fixes this issue locally



From MAILER-DAEMON Tue Apr 25 15:00:13 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d35h6-0007wI-TL
	for mharc-bug-bash@gnu.org; Tue, 25 Apr 2017 15:00:12 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33386)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d35gy-0007mf-6F
	for bug-bash@gnu.org; Tue, 25 Apr 2017 15:00:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d35gv-0000DP-Lo
	for bug-bash@gnu.org; Tue, 25 Apr 2017 15:00:04 -0400
Received: from mpv3-2015.cwru.edu ([129.22.103.194]:6366
	helo=mpv3-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d35gv-0000Cd-HC
	for bug-bash@gnu.org; Tue, 25 Apr 2017 15:00:01 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv3-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALQ40417; Tue, 25 Apr 2017 14:59:59 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDI28644 (AUTH cpr);
	Tue, 25 Apr 2017 14:59:58 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: shquote.c incorrectly escapes comma, but not tilde
References: <201704251410.v3PEAXGW029562@dnwks49>
To: scragar@gmail.com, bug-bash@gnu.org, bash@packages.debian.org
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <fdca5b21-d5a3-45db-295d-5208dad1a19c@case.edu>
Date: Tue, 25 Apr 2017 14:59:58 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <201704251410.v3PEAXGW029562@dnwks49>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv3-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.25.174216:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NO_NAME, __HAS_CC_HDR, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __FRAUD_BODY_WEBMAIL,
	__URI_NO_WWW, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_1000_1099, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY,
	BODY_SIZE_5000_LESS, __FRAUD_WEBMAIL, IN_REP_TO,
	MSG_THREAD, __FROM_DOMAIN_IN_RCPT, MULTIPLE_REAL_RCPTS,
	[TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.194
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Tue, 25 Apr 2017 19:00:10 -0000

On 4/25/17 10:10 AM, scragar@gmail.com wrote:

> Bash Version: 4.3
> Patch Level: 46
> Release Status: release
> 
> Description:
> 	When using any functionality that triggers shquote the
> 	comma character is escaped with a backslash which bash
> 	doesn't strip when the quoted text is reused, while
> 	tilde isn't despite it causing home directory expansion.

The documentation states "reused as shell input", which isn't quite the
same as the output of a word expansion.  The backslash quoting the comma,
which serves to inhibit brace expansion, is removed just fine if the
string is used as shell input.

As for the tilde:

$ echo $(printf "%q\n" "~" "a,b")
\~ a\,b
$ eval echo $(printf "%q\n" "~" "a,b")
~ a,b
$ echo $BASH_VERSION
4.3.48(30)-release

The same explanation suffices for why the tilde is quoted with a backslash.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Wed Apr 26 06:13:44 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3JxA-0007YH-74
	for mharc-bug-bash@gnu.org; Wed, 26 Apr 2017 06:13:44 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48096)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d3Jx8-0007Wz-0w
	for bug-bash@gnu.org; Wed, 26 Apr 2017 06:13:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d3Jx4-0005Nn-SA
	for bug-bash@gnu.org; Wed, 26 Apr 2017 06:13:41 -0400
Received: from pv35p18im-ztdg05101101.me.com ([17.133.188.44]:20705)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d3Jx4-0005Ld-Id
	for bug-bash@gnu.org; Wed, 26 Apr 2017 06:13:38 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05101101.me.com by
	pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OP000D00HGX7U00@pv35p18im-ztdg05101101.me.com> for
	bug-bash@gnu.org; Wed, 26 Apr 2017 10:13:30 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1493201610; bh=Rz3WLZzfJJOeStoSPnd/2+sL6HB4vsYO6v44BeMTi2U=;
	h=From:Content-type:Subject:Message-id:Date:To:MIME-version;
	b=gTlPLqIxqmmKh+3QaL4tH7qJMTDivzoJuXK87E0lh5BEqtWFTVHdwcsZFlFsJJ69K
	BqfG4eYYG5bT7zRSOTk8XumIXPie9yxiBRdDdoUvBA+KNUuy7UhVbfTbZE/pjudHZn
	/VNtlpj5cbfQ25w4pdJTnX+sL1T4anuEnldYqrIU6m86Fn1H1DYFML/CAkBYidQgJ9
	8Og5Iks3CKSXq2MkRGYEl9d7a7wmn6vIMaDY7311Ek+ju02RLUAn3a4BPHAOCT8J6b
	5K1s9+o/lU0NIFaxrYoV2zPCBg+FVgKGTjTIjN1o5FH9e1eFqnWWBUcYTXLz7b1+ka
	8PebYIG6IJXaQ==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OP00035ZHQFXC10@pv35p18im-ztdg05101101.me.com> for
	bug-bash@gnu.org; Wed, 26 Apr 2017 10:13:30 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-26_07:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704260183
From: Florian Mayer <mayerflorian@me.com>
Subject: Brace expansion fail compilation
Message-id: <727B131F-4C9C-484B-A087-DA0EACE327A6@me.com>
Date: Wed, 26 Apr 2017 12:13:27 +0200
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
X-Mailer: Apple Mail (2.3124)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.44
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Content-Filtered-By: Mailman/MimeDel 2.1.21
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 26 Apr 2017 10:13:43 -0000

$ echo $BASH_VERSION
4.4.12(1)-release
$ echo $BASH_VERSION{nobraceexpansion}
4.4.12(1)-release{nobraceexpansion}
$ echo ${BASH_VERSION}{brace,expansion}
4.4.12(1)-releasebrace 4.4.12(1)-releaseexpansion
$ echo $BASH_VERSION{brace,expansion}
=3D> no output. Unexpected
$ echo $BASH_VERSIONfoo
=3D> no output as expected

Why does
$ echo $BASH_VERSION{brace,expansion}
produce no output?

Comment from braces.c:

/* Basic idea:
   Segregate the text into 3 sections: preamble (stuff before an open =
brace),
   postamble (stuff after the matching close brace) and amble (stuff =
after
   preamble, and before postamble).  Expand amble, and then tack on the
   expansions to preamble.  Expand postamble, and tack on the expansions =
to
   the result so far.
 */

"Expand amble, and then tack on the expansions to preamble.=E2=80=9C =
made me expect two things:=20
- No expansion of $BASH_VERSION is performed and $BASH_VERSION is used =
to append the pieces from the expansion of amble
- Expansion will be performed like it should be the case, because =
=E2=80=9E{=E2=80=9E is obviously a parameter expansion terminal =
character as the line
$ echo $BASH_VERSION{nobraceexpansion}
shows, because this line really does expand $BASH_VERSION


From MAILER-DAEMON Wed Apr 26 06:18:20 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3K1c-0000Nz-Ox
	for mharc-bug-bash@gnu.org; Wed, 26 Apr 2017 06:18:20 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49128)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d3K1a-0000Lv-36
	for bug-bash@gnu.org; Wed, 26 Apr 2017 06:18:19 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1d3K1Z-0007Wf-4L
	for bug-bash@gnu.org; Wed, 26 Apr 2017 06:18:18 -0400
Received: from mail-qt0-x236.google.com ([2607:f8b0:400d:c0d::236]:36821)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <pierre.gaston@gmail.com>)
	id 1d3K1Y-0007WV-Vm
	for bug-bash@gnu.org; Wed, 26 Apr 2017 06:18:17 -0400
Received: by mail-qt0-x236.google.com with SMTP id g60so162139409qtd.3
	for <bug-bash@gnu.org>; Wed, 26 Apr 2017 03:18:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=VZchVhBIiSt3SelWRDTKqYejWwOFA+YPI0FL4bFAHK4=;
	b=b/2roHwf2x5Z34xD9G7LxZObCvrp3/RmYTlQUNiXVmkoGf++cCl76qBfnr527dwEXw
	aanHgulcR11gF45l29QnDiqftzE/3Y6JkIKnxXcmKWAtkehmJb1p5G0NRN0Fe9FeSO1j
	V+9m07ONejXVeEE4S8TzQdFKieUGkFw7hhkRyT+f9zhNf53+9h+6rtOLOfUGWKTa0p98
	B0jnfLkR53/SvkRJE5Ty2ZS3Wddk1O3f4NF4REMlUFEkg8D5uhYgqN/eVc1TBBMElxkd
	5ENo7lyCxBkQWYbgrgqiMrpAc0lIk6aVYSC/hoAdqlhy2GgWY+SFjFK3jBFn2ND9/JtR
	mr8A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=VZchVhBIiSt3SelWRDTKqYejWwOFA+YPI0FL4bFAHK4=;
	b=Hqgh3rDsjfFG/9YvzkZCOZnC+PBXrmJfxNfi2TlhDtIII8aU10W3MFULYT2ZYIRFKw
	HTNGkJ1nriVoCpPcI53YZuBcc5vL4LsQaAMcA4oXw8Ci5s9QrRfTctwX0qGTYDc6nZ1S
	qO8l4FvGxs6M98tseGRK+m0SO91JyjqisS8/W2Y8qB11lREy/ParN+vJZS4KyYKbrBMM
	JoMbkgodo0ld1S9oFdH2oeOV5oaGxRNP0x3VB/J0MEpEuuFHjh+iLDZ/Tgp4fVYUijtb
	IuYa56ifHmkDXety5gQeo/+WvKnzI7ouqqcn6XPphoFlmyY2dj2iy8PNKNFQRiPK/6Hi
	i77Q==
X-Gm-Message-State: AN3rC/5P0pNiafAhDKq6MTuqSOLed8YCY0LUuijQXdiKqdCiWZZET/Wb
	JCcivtwCNqu2KHoZtTfcTrcDYixpFQ==
X-Received: by 10.237.53.124 with SMTP id b57mr34014045qte.240.1493201896437; 
	Wed, 26 Apr 2017 03:18:16 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.12.180.13 with HTTP; Wed, 26 Apr 2017 03:17:56 -0700 (PDT)
In-Reply-To: <727B131F-4C9C-484B-A087-DA0EACE327A6@me.com>
References: <727B131F-4C9C-484B-A087-DA0EACE327A6@me.com>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Wed, 26 Apr 2017 13:17:56 +0300
Message-ID: <CAPSX3sSRwf4UMcJ9rWnKVE7x1AGh09RME6cTj4y4_K4KaZJp9w@mail.gmail.com>
Subject: Re: Brace expansion fail compilation
To: Florian Mayer <mayerflorian@me.com>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c0d::236
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.21
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 26 Apr 2017 10:18:19 -0000

On Wed, Apr 26, 2017 at 1:13 PM, Florian Mayer <mayerflorian@me.com> wrote:

> $ echo $BASH_VERSION
> 4.4.12(1)-release
> $ echo $BASH_VERSION{nobraceexpansion}
> 4.4.12(1)-release{nobraceexpansion}
> $ echo ${BASH_VERSION}{brace,expansion}
> 4.4.12(1)-releasebrace 4.4.12(1)-releaseexpansion
> $ echo $BASH_VERSION{brace,expansion}
> => no output. Unexpected
> $ echo $BASH_VERSIONfoo
> => no output as expected
>
> Why does
> $ echo $BASH_VERSION{brace,expansion}
> produce no output?
>
> it's because brace expansion occurs before parameter expansion
so first
  echo $BASH_VERSION{brace,expansion}
is expanded to
  echo $BASH_VERSIONbrace $BASH_VERSIONexpansion
and these 2 variables are not set.

you can verify with:
$ BASH_VERSIONbrace=foo BASH_VERSIONexpansion=bar; echo
$BASH_VERSION{brace,expansion}
foo bar

From MAILER-DAEMON Wed Apr 26 06:25:31 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3K8Y-0003zg-Ov
	for mharc-bug-bash@gnu.org; Wed, 26 Apr 2017 06:25:30 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50979)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d3K8V-0003we-JH
	for bug-bash@gnu.org; Wed, 26 Apr 2017 06:25:28 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d3K8R-0002xZ-2a
	for bug-bash@gnu.org; Wed, 26 Apr 2017 06:25:27 -0400
Received: from pv35p18im-ztdg05101101.me.com ([17.133.188.44]:38010)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d3K8Q-0002x8-Oy
	for bug-bash@gnu.org; Wed, 26 Apr 2017 06:25:22 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05101101.me.com by
	pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OP000M00I0X6V00@pv35p18im-ztdg05101101.me.com> for
	bug-bash@gnu.org; Wed, 26 Apr 2017 10:25:21 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1493202321; bh=JO0t5CgL6SWAZoiEVxikZikqQ/ImmOITnadq/JzwpFY=;
	h=From:Content-type:MIME-version:Date:Subject:Message-id:To;
	b=eGyg44nhv2cCAtyvFVxq+PoVUKh60w/8w1z+hnm/y04m2bsodGlNNk92w2iskUfGl
	32ziZ3FPMirBNvSVMuFNeWAoW79Jbwoyn8v+oVlh0Sk6MMEhannNYJvKDGchKb0dLo
	PgZjwQqytA7440hDXMUu5/j4vhMDNXckBss/lYhcQw4FWxYCykHRHPE7s84Pwjyqar
	xIqItH3oetE9igoEUduj6jgX25QCIelFu6DY7/VYeLfYp2ilQCknDZjYNfa7eLcPwX
	1FE4sfDo3cF0aFNWg766pyYLuYkUW+R2bahNgFPrA/IUqPatj0KKjiF8kLjUTOG9aU
	u7hUIGWegWIsg==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OP000ALUIA65Q30@pv35p18im-ztdg05101101.me.com>; Wed,
	26 Apr 2017 10:25:21 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-26_07:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704260187
From: Florian Mayer <mayerflorian@me.com>
MIME-version: 1.0 (1.0)
Date: Wed, 26 Apr 2017 12:25:18 +0200
Subject: Re: Brace expansion fail compilation
Message-id: <DD5A5102-30E2-428E-805E-BB2024648E1E@me.com>
References: <727B131F-4C9C-484B-A087-DA0EACE327A6@me.com>
	<CAPSX3sSRwf4UMcJ9rWnKVE7x1AGh09RME6cTj4y4_K4KaZJp9w@mail.gmail.com>
In-reply-to: <CAPSX3sSRwf4UMcJ9rWnKVE7x1AGh09RME6cTj4y4_K4KaZJp9w@mail.gmail.com>
To: Pierre Gaston <pierre.gaston@gmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
X-Mailer: iPhone Mail (14D27)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.44
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Content-Filtered-By: Mailman/MimeDel 2.1.21
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 26 Apr 2017 10:25:28 -0000

wow..., ok thanks for the quick reply

> On 26 Apr 2017, at 12:17, Pierre Gaston <pierre.gaston@gmail.com> wrote:
>=20
>=20
>=20
>> On Wed, Apr 26, 2017 at 1:13 PM, Florian Mayer <mayerflorian@me.com> wrot=
e:
>> $ echo $BASH_VERSION
>> 4.4.12(1)-release
>> $ echo $BASH_VERSION{nobraceexpansion}
>> 4.4.12(1)-release{nobraceexpansion}
>> $ echo ${BASH_VERSION}{brace,expansion}
>> 4.4.12(1)-releasebrace 4.4.12(1)-releaseexpansion
>> $ echo $BASH_VERSION{brace,expansion}
>> =3D> no output. Unexpected
>> $ echo $BASH_VERSIONfoo
>> =3D> no output as expected
>>=20
>> Why does
>> $ echo $BASH_VERSION{brace,expansion}
>> produce no output?
>>=20
> it's because brace expansion occurs before parameter expansion
> so first
>   echo $BASH_VERSION{brace,expansion}=20
> is expanded to
>   echo $BASH_VERSIONbrace $BASH_VERSIONexpansion
> and these 2 variables are not set.
>=20
> you can verify with:
> $ BASH_VERSIONbrace=3Dfoo BASH_VERSIONexpansion=3Dbar; echo $BASH_VERSION{=
brace,expansion}
> foo bar
>=20
>=20
>=20

From MAILER-DAEMON Wed Apr 26 09:25:16 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3MwW-0006fK-60
	for mharc-bug-bash@gnu.org; Wed, 26 Apr 2017 09:25:16 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43433)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3MwT-0006dE-5l
	for bug-bash@gnu.org; Wed, 26 Apr 2017 09:25:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3MwP-0001DG-8B
	for bug-bash@gnu.org; Wed, 26 Apr 2017 09:25:13 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:31215
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d3MwP-0001C1-2q
	for bug-bash@gnu.org; Wed, 26 Apr 2017 09:25:09 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMV66004; Wed, 26 Apr 2017 09:25:06 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDJ31606 (AUTH cpr);
	Wed, 26 Apr 2017 09:25:06 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Brace expansion fail compilation
References: <727B131F-4C9C-484B-A087-DA0EACE327A6@me.com>
To: Florian Mayer <mayerflorian@me.com>, "bug-bash@gnu.org" <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <945dc23b-e9d0-b27a-56d6-78e9d6b03757@case.edu>
Date: Wed, 26 Apr 2017 09:25:05 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <727B131F-4C9C-484B-A087-DA0EACE327A6@me.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Status: score=7/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.26.125716:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID,
	DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT,
	__MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __HIGHBITS,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_500_599,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS,
	[TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 26 Apr 2017 13:25:14 -0000

On 4/26/17 6:13 AM, Florian Mayer wrote:

> - Expansion will be performed like it should be the case, because â€ž{â€ž is obviously a parameter expansion terminal character as the line
> $ echo $BASH_VERSION{nobraceexpansion}
> shows, because this line really does expand $BASH_VERSION

This is not a correctly-formed candidate for brace expansion, so it is
left unchanged.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Wed Apr 26 11:10:38 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3OaU-0004qm-Os
	for mharc-bug-bash@gnu.org; Wed, 26 Apr 2017 11:10:38 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42979)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3OaP-0004qW-NV
	for bug-bash@gnu.org; Wed, 26 Apr 2017 11:10:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3OaO-0003kQ-Li
	for bug-bash@gnu.org; Wed, 26 Apr 2017 11:10:33 -0400
Received: from mail-it0-x235.google.com ([2607:f8b0:4001:c0b::235]:38289)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d3OaO-0003kF-Fu
	for bug-bash@gnu.org; Wed, 26 Apr 2017 11:10:32 -0400
Received: by mail-it0-x235.google.com with SMTP id f187so4577314ite.1
	for <bug-bash@gnu.org>; Wed, 26 Apr 2017 08:10:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=0HMIsZYIY4e57oW4gvQtztKPlFTHqNhekX2jwJ9iEfM=;
	b=YTu6GbENix9VSJ0roHOnXwUODa6HXljiXjOlA1A8mnI4gUJmQxE5FNnasMKp9KPBpM
	C7FA4HIYOxYdXM4MFayckZ+L3WV7WqW8LgecKpksNT4PwXh56+yFpMH+hN5Wx3mAHdX3
	aPdW8mnKK9vd/mwrhCi/i/9ZglFNifR6DXbOqx2q+muGEPFkV1eOdltk7+DoVfDfGA0+
	bLyvVamj18ELybikfDsb55igxR/dv6O37rxFiJ0vZvlt9U0w8T0vWF1mR1lcbFaoRx78
	Pp/C6JnhSqJK3tKRsS33mYn0JeFgrDse5ZsIalq9Y0xUKpeb/GNxMuRmHobVXZBqDRht
	8i7A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=0HMIsZYIY4e57oW4gvQtztKPlFTHqNhekX2jwJ9iEfM=;
	b=qv2YMUrSWgtW8T1UPlnPGNkPXeRTQiisKd7ctGEeiAcx2qOtO6h5q/5Qe/ikxuGjJr
	pb8UJdjDLdb/lSpe0Wyt5A0BALxWkQnA8huLaqRprBm1XMQa3kTxvo/hqBQW3aVm6iok
	E13DXMij557TuHa17PuL2Vd8YJVLxB6AafDQp2P8YL7hozztspJmMItahErFID6pf/C9
	Fz+NyzroZLnr+PGIBAHAnJE5s+qnuubulF1AJbeu5Zno9BFcR8hF4uNW2IDBw1L86wSd
	lumAqSlyBvIZLcX4SHUDOB01hj/+s0Rqd36vXAmnBeycmQKOrZLvSQQEyKvKv/x9XtHb
	LJGw==
X-Gm-Message-State: AN3rC/7YztTSsZcPlve64YjOsNIE/4G5QrN+1w48lkZImxy8eMHeqUp0
	yv1tDuSnZWc2kSsOCsmeIykcm3o4zg==
X-Received: by 10.36.190.205 with SMTP id i196mr1641603itf.88.1493219431445;
	Wed, 26 Apr 2017 08:10:31 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Wed, 26 Apr 2017 08:10:10 -0700 (PDT)
In-Reply-To: <4ce71a35-881e-52ed-33c1-056a8ea5d763@case.edu>
References: <CAOSMAuvABhAm=6M6nk=0v+bXvV6+MgzytVcgbu18J7pp48TKVQ@mail.gmail.com>
	<4ce71a35-881e-52ed-33c1-056a8ea5d763@case.edu>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Wed, 26 Apr 2017 10:10:10 -0500
Message-ID: <CAOSMAuu1o2b6YOtogFkiLyihc06T9uhaABqDtOWC6FsnNPd_=A@mail.gmail.com>
Subject: Re: Using Clang's static analyzer on bash
To: Chet Ramey <chet.ramey@case.edu>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c0b::235
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 26 Apr 2017 15:10:38 -0000

On Mon, Apr 24, 2017 at 10:13 AM, Chet Ramey <chet.ramey@case.edu> wrote:
[...]
> I'd be interested in seeing the results.  In my experience with similar
> tools, the false positive ratio is very high.

Most of the "errors" identified are due to unused variables. It does
have some interesting reports though:

#1 optimized_assignment in variables.c does not check if xrealloc was
successful (i.e. not NULL), so if it fails, strcpy will end up
dereferencing a null pointer.

#2 command_substitute in subst.c the value of old_pid is uninitialized
when pipe() returns an error, so last_made_pid ends up being a garbage
value. I modified the code to print the value of last_made_pid in
`error_exit'. I don't know how last_made_pid is used, so I don't know
if this is a problem or not.

| dualbus@debian:~/src/gnu/bash$ ./bash -c 'ulimit -n 3; $(:); echo hi'
| ./bash: cannot make pipe for command substitution: Too many open files
| last_made_pid = -1074209592
| hi

#3 parameter_brace_expand_indir in subst.c the value of `v' (SHELL_VAR
pointer) when var_is_special > 0 is not defined, so `legal_identifier
(name) && v == 0' relies on undefined behavior.

I've attached the build log to https://savannah.gnu.org/support/index.php?109301


From MAILER-DAEMON Wed Apr 26 11:12:38 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3OcQ-0005fs-MF
	for mharc-bug-bash@gnu.org; Wed, 26 Apr 2017 11:12:38 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43340)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3OcO-0005eb-N6
	for bug-bash@gnu.org; Wed, 26 Apr 2017 11:12:37 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3OcN-0004JW-Q0
	for bug-bash@gnu.org; Wed, 26 Apr 2017 11:12:36 -0400
Received: from mail-io0-x234.google.com ([2607:f8b0:4001:c06::234]:35136)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d3OcN-0004JC-Lv
	for bug-bash@gnu.org; Wed, 26 Apr 2017 11:12:35 -0400
Received: by mail-io0-x234.google.com with SMTP id r16so4652518ioi.2
	for <bug-bash@gnu.org>; Wed, 26 Apr 2017 08:12:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=kv2aX3kGwo9toS8zoGPMCkY+QDpiepNQIcgO6IfmuKA=;
	b=p00mcomY42prV2Z0e9ouj2jaA79r+wyYn984w7HDAkjQWw/CLEu2GemiP5dbx/08oH
	Q8DrvjP1hZ38So1NdmSLcLg3DXnHfcHpuyeeFpvF0TMe8FIDjQ2+3xZQNO5Wnu8cocIw
	j4qVa+bEzMNxcGKTJjNKyio+GkiWM7Rtz4BV8mvK02St936rn8lxpMbpBH+A7yDY5eIn
	WmVoDKnrxWNOHzGVffO3w2v5RFahac9FjrKeA4XKg008/sbcQyxqxPDZ5UQSwilvXJEg
	o8RkkTNT0zEeoy1veW1Qu08J5wqgcixIp+/90+0540q/j4xB8hbkOBmmPCtWI5nIidWv
	5l0g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=kv2aX3kGwo9toS8zoGPMCkY+QDpiepNQIcgO6IfmuKA=;
	b=BprFPKb+AU5+r38f9NcELY61DZSwoZEtgJknS3G+J4yxEcUh8UDA/qh4tkCrM9Udiw
	snIPxDLCnZ1zAYkcXoWcs2tUS2PSu+TbI2BI+4S2i+KjTKeTvvhsY9CzK/IkxoSeAW86
	grFBM6NazTZ8ff3cboNBuuamGrrYYJSzRVbifu4toH/xvGiwXNt5Kkt6R9LtUXfAtO/E
	MUg8YbR3LYbzMV86zK2Z9EoFGNf7xNFtCmT25Wuv8pB8Rh42i1ZtZwx86b/tzYt5Om1Q
	3emqMwxE5H/YMS6kX/Qa8h+aJE9Vp5yiSSMirTRELaLkOtDWGupdjV/DQJIN2DPaaltD
	5P0A==
X-Gm-Message-State: AN3rC/75riAal1MvMmPYZBcvcrtU9sORFW91ovXEEndIMj2lP8Iv8YQs
	CvRxySHoxleyuHT7YZMiKX/O27+HgQ==
X-Received: by 10.107.140.197 with SMTP id o188mr264311iod.180.1493219555013; 
	Wed, 26 Apr 2017 08:12:35 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Wed, 26 Apr 2017 08:12:14 -0700 (PDT)
In-Reply-To: <CAOSMAuu1o2b6YOtogFkiLyihc06T9uhaABqDtOWC6FsnNPd_=A@mail.gmail.com>
References: <CAOSMAuvABhAm=6M6nk=0v+bXvV6+MgzytVcgbu18J7pp48TKVQ@mail.gmail.com>
	<4ce71a35-881e-52ed-33c1-056a8ea5d763@case.edu>
	<CAOSMAuu1o2b6YOtogFkiLyihc06T9uhaABqDtOWC6FsnNPd_=A@mail.gmail.com>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Wed, 26 Apr 2017 10:12:14 -0500
Message-ID: <CAOSMAutsBjeG2yzQz8zoLU7WJGm6kkJQA6QomtMBi9JY9kioqg@mail.gmail.com>
Subject: Re: Using Clang's static analyzer on bash
To: Chet Ramey <chet.ramey@case.edu>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::234
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 26 Apr 2017 15:12:37 -0000

On Wed, Apr 26, 2017 at 10:10 AM, Eduardo Bustamante <dualbus@gmail.com> wrote:
[...]
> #1 optimized_assignment in variables.c does not check if xrealloc was
> successful (i.e. not NULL), so if it fails, strcpy will end up
> dereferencing a null pointer.

I just noticed that xrealloc will exit on failure, so this is not
really an issue.


From MAILER-DAEMON Wed Apr 26 11:48:23 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3PB1-0008Is-EB
	for mharc-bug-bash@gnu.org; Wed, 26 Apr 2017 11:48:23 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52771)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3PAz-0008HR-3W
	for bug-bash@gnu.org; Wed, 26 Apr 2017 11:48:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3PAu-0006l3-91
	for bug-bash@gnu.org; Wed, 26 Apr 2017 11:48:21 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:1065
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d3PAt-0006ii-RR
	for bug-bash@gnu.org; Wed, 26 Apr 2017 11:48:16 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMV76591; Wed, 26 Apr 2017 11:48:12 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDJ67774 (AUTH cpr);
	Wed, 26 Apr 2017 11:48:10 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Using Clang's static analyzer on bash
References: <CAOSMAuvABhAm=6M6nk=0v+bXvV6+MgzytVcgbu18J7pp48TKVQ@mail.gmail.com>
	<4ce71a35-881e-52ed-33c1-056a8ea5d763@case.edu>
	<CAOSMAuu1o2b6YOtogFkiLyihc06T9uhaABqDtOWC6FsnNPd_=A@mail.gmail.com>
To: Eduardo Bustamante <dualbus@gmail.com>
Cc: chet.ramey@case.edu, "bug-bash@gnu.org" <bug-bash@gnu.org>
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <a2498675-c3d9-6813-d40b-2c5f0174a8da@case.edu>
Date: Wed, 26 Apr 2017 11:48:09 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOSMAuu1o2b6YOtogFkiLyihc06T9uhaABqDtOWC6FsnNPd_=A@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.26.145416:17:8.317, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __CC_NAME,
	__HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID,
	DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT,
	__MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __C230066_P5,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_1800_1899, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY,
	BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Wed, 26 Apr 2017 15:48:22 -0000

On 4/26/17 11:10 AM, Eduardo Bustamante wrote:
> On Mon, Apr 24, 2017 at 10:13 AM, Chet Ramey <chet.ramey@case.edu> wrote:
> [...]
>> I'd be interested in seeing the results.  In my experience with similar
>> tools, the false positive ratio is very high.
> 
> Most of the "errors" identified are due to unused variables. It does
> have some interesting reports though:
> 
> #1 optimized_assignment in variables.c does not check if xrealloc was
> successful (i.e. not NULL), so if it fails, strcpy will end up
> dereferencing a null pointer.

Not a problem; xrealloc aborts on error.

> #2 command_substitute in subst.c the value of old_pid is uninitialized
> when pipe() returns an error, so last_made_pid ends up being a garbage
> value. I modified the code to print the value of last_made_pid in
> `error_exit'. I don't know how last_made_pid is used, so I don't know
> if this is a problem or not.

If you can't create pipes or open files, you're not going to get very far,
but still worth moving the assignment above the call to pipe().

> | dualbus@debian:~/src/gnu/bash$ ./bash -c 'ulimit -n 3; $(:); echo hi'
> | ./bash: cannot make pipe for command substitution: Too many open files
> | last_made_pid = -1074209592
> | hi
> 
> #3 parameter_brace_expand_indir in subst.c the value of `v' (SHELL_VAR
> pointer) when var_is_special > 0 is not defined, so `legal_identifier
> (name) && v == 0' relies on undefined behavior.

When var_is_special == 1, legal_identifier(name) returns 0. `&&' is
evaluated left-to-right, and stops as soon as legal_identifier fails.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 27 08:02:51 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3i8I-0006KO-Ps
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 08:02:50 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52959)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3i8G-0006I3-4x
	for bug-bash@gnu.org; Thu, 27 Apr 2017 08:02:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3i8E-0002l6-W1
	for bug-bash@gnu.org; Thu, 27 Apr 2017 08:02:48 -0400
Received: from mail-io0-x22d.google.com ([2607:f8b0:4001:c06::22d]:34056)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d3i8E-0002l2-PR
	for bug-bash@gnu.org; Thu, 27 Apr 2017 08:02:46 -0400
Received: by mail-io0-x22d.google.com with SMTP id a103so21021544ioj.1
	for <bug-bash@gnu.org>; Thu, 27 Apr 2017 05:02:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=qmnN579+V/CmOpSiY7XXpHpjXNqckabNGJyqhYqz3k4=;
	b=u45iu9TJwSCl3l0XUwq5Ytqnj7NoBB1uoRMHAo4Cib9bLKYqI8Gz0m6i8n6evQoCMJ
	6wj8A/BPRb9+8bpDZowWMur+b+h56DANYjCuTIWlryETakSDuTzFTswBFSu/ZgXByK5d
	aAzwU6OeC8ldinmayYDjcmwQxUfFcAwnQl8D/f9af0jV8KaOXfknI5srlihAZJJF/GVV
	dAaHXjFELTrATHcbjQ4IZMdLd0dv4a2Z2wixdZ7mC+S6yvAaFvbEtO71ZoiLDsOFqaeR
	vwlsqMRipKGC8IRdGW+aQHIqIuYZyd7uHWKC6UJ2rdOahsD05NnlOg3aFH0A4grVvZpp
	g30w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=qmnN579+V/CmOpSiY7XXpHpjXNqckabNGJyqhYqz3k4=;
	b=fRFrkwUQwLMcrwIvDCOh0dIerWtAOC9a/8+11QfYvyNBo4lthZR57i6L3IqfNwvBkV
	LnU4pnoqkTyFj1eEShd7jsEUGysUswgarYOFZsNzyJHh2onvIZOtH9y/A49lZjgP6GaF
	KiWytelhGCcQwG7Yzv52ARqSZY6qloxVs0duBC9UwGCBCl26jcU3+pNX73CuhPMZDQ2r
	14Ov68i22XTkfHvRxBYNrN0Za4aGHkqRsjOUJePd6YvG8xAfuv8E8upGdaFl1vg7821d
	jU765sLG/uzpmR6iORw/YWjQQTE3f+3oF8oMsxFotxjIFvYEiVR5+UU1WOUoPo2+kAA5
	QNzg==
X-Gm-Message-State: AN3rC/5nIaAvREqdaTPIm3ZwplIX3zp6ItComaayIR7EC1sbcXmuok+q
	R8aTlGoI50+57liu0ABQW8VNiXqQTeEv
X-Received: by 10.107.140.197 with SMTP id o188mr4091429iod.180.1493294565632; 
	Thu, 27 Apr 2017 05:02:45 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Thu, 27 Apr 2017 05:02:25 -0700 (PDT)
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Thu, 27 Apr 2017 07:02:25 -0500
Message-ID: <CAOSMAutn8+f03ay8_DTAtcwjArMGqR0ZBkOigMVq3SXCyTrgyA@mail.gmail.com>
Subject: AddressSanitizer: heap-buffer-overflow lib/readline/bind.c:437 in
	rl_translate_keyseq
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::22d
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 27 Apr 2017 12:02:49 -0000

dualbus@debian:~/src/gnu/bash$ xxd inputrc
00000000: 225c 432d 2230 3030 200a                 "\C-"000 .

# with ASAN
dualbus@debian:~/src/gnu/bash$ ./bash --noprofile --norc -ic 'bind -f inputrc'
=================================================================
==27315==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x602000009bb9 at pc 0x5628fdaa420b bp 0x7ffcde1bef40 sp
0x7ffcde1bef38
READ of size 1 at 0x602000009bb9 thread T0
    #0 0x5628fdaa420a in rl_translate_keyseq
/home/dualbus/src/gnu/bash/lib/readline/bind.c:437
    #1 0x5628fdaa2934 in rl_generic_bind
/home/dualbus/src/gnu/bash/lib/readline/bind.c:347
    #2 0x5628fdaa2520 in rl_bind_keyseq
/home/dualbus/src/gnu/bash/lib/readline/bind.c:251
    #3 0x5628fdaa82ab in rl_parse_and_bind
/home/dualbus/src/gnu/bash/lib/readline/bind.c:1405
    #4 0x5628fdaa6103 in _rl_read_init_file
/home/dualbus/src/gnu/bash/lib/readline/bind.c:927
    #5 0x5628fdaa5d4c in rl_read_init_file
/home/dualbus/src/gnu/bash/lib/readline/bind.c:870
    #6 0x5628fda1901c in bind_builtin bind.def:248
    #7 0x5628fd95272b in execute_builtin
/home/dualbus/src/gnu/bash/execute_cmd.c:4603
    #8 0x5628fd954341 in execute_builtin_or_function
/home/dualbus/src/gnu/bash/execute_cmd.c:5101
    #9 0x5628fd951bc1 in execute_simple_command
/home/dualbus/src/gnu/bash/execute_cmd.c:4389
    #10 0x5628fd93fac2 in execute_command_internal
/home/dualbus/src/gnu/bash/execute_cmd.c:811
    #11 0x5628fda294ae in parse_and_execute
/home/dualbus/src/gnu/bash/builtins/evalstring.c:430
    #12 0x5628fd90b121 in run_one_command
/home/dualbus/src/gnu/bash/shell.c:1405
    #13 0x5628fd9095fa in main /home/dualbus/src/gnu/bash/shell.c:718
    #14 0x7fc1396332b0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    #15 0x5628fd908469 in _start (/home/dualbus/src/gnu/bash/bash+0x7f469)

0x602000009bb9 is located 0 bytes to the right of 9-byte region
[0x602000009bb0,0x602000009bb9)
allocated by thread T0 here:
    #0 0x7fc139ea0d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
    #1 0x5628fda18195 in xmalloc /home/dualbus/src/gnu/bash/xmalloc.c:112
    #2 0x5628fdaa7e6f in rl_parse_and_bind
/home/dualbus/src/gnu/bash/lib/readline/bind.c:1372
    #3 0x5628fdaa6103 in _rl_read_init_file
/home/dualbus/src/gnu/bash/lib/readline/bind.c:927
    #4 0x5628fdaa5d4c in rl_read_init_file
/home/dualbus/src/gnu/bash/lib/readline/bind.c:870
    #5 0x5628fda1901c in bind_builtin bind.def:248
    #6 0x5628fd95272b in execute_builtin
/home/dualbus/src/gnu/bash/execute_cmd.c:4603
    #7 0x5628fd954341 in execute_builtin_or_function
/home/dualbus/src/gnu/bash/execute_cmd.c:5101
    #8 0x5628fd951bc1 in execute_simple_command
/home/dualbus/src/gnu/bash/execute_cmd.c:4389
    #9 0x5628fd93fac2 in execute_command_internal
/home/dualbus/src/gnu/bash/execute_cmd.c:811
    #10 0x5628fda294ae in parse_and_execute
/home/dualbus/src/gnu/bash/builtins/evalstring.c:430
    #11 0x5628fd90b121 in run_one_command
/home/dualbus/src/gnu/bash/shell.c:1405
    #12 0x5628fd9095fa in main /home/dualbus/src/gnu/bash/shell.c:718
    #13 0x7fc1396332b0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b0)

SUMMARY: AddressSanitizer: heap-buffer-overflow
/home/dualbus/src/gnu/bash/lib/readline/bind.c:437 in
rl_translate_keyseq
Shadow bytes around the buggy address:
  0x0c047fff9320: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9330: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9340: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9350: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9360: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c047fff9370: fa fa 07 fa fa fa 00[01]fa fa 00 fa fa fa 00 03
  0x0c047fff9380: fa fa fd fa fa fa fd fa fa fa fd fa fa fa 00 07
  0x0c047fff9390: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff93a0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff93b0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff93c0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==27315==ABORTING

# With Valgrind + without bash malloc
dualbus@debian:~/src/gnu/bash$ valgrind ./bash --noprofile --norc -ic
'bind -f inputrc'
==2112== Memcheck, a memory error detector
==2112== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==2112== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==2112== Command: ./bash --noprofile --norc -ic bind\ -f\ inputrc
==2112==
==2112== Conditional jump or move depends on uninitialised value(s)
==2112==    at 0x1EE229: rl_translate_keyseq (bind.c:437)
==2112==    by 0x1ED979: rl_generic_bind (bind.c:347)
==2112==    by 0x1ED767: rl_bind_keyseq (bind.c:251)
==2112==    by 0x1EFB79: rl_parse_and_bind (bind.c:1405)
==2112==    by 0x1EEE3F: _rl_read_init_file (bind.c:927)
==2112==    by 0x1EECA8: rl_read_init_file (bind.c:870)
==2112==    by 0x1AAE4B: bind_builtin (bind.def:248)
==2112==    by 0x155FF0: execute_builtin (execute_cmd.c:4603)
==2112==    by 0x156ECC: execute_builtin_or_function (execute_cmd.c:5101)
==2112==    by 0x1558F6: execute_simple_command (execute_cmd.c:4389)
==2112==    by 0x14F2AE: execute_command_internal (execute_cmd.c:811)
==2112==    by 0x1B21E7: parse_and_execute (evalstring.c:430)
==2112==
==2112==
==2112== HEAP SUMMARY:
==2112==     in use at exit: 226,535 bytes in 790 blocks
==2112==   total heap usage: 1,519 allocs, 729 frees, 286,870 bytes allocated
==2112==
==2112== LEAK SUMMARY:
==2112==    definitely lost: 0 bytes in 0 blocks
==2112==    indirectly lost: 0 bytes in 0 blocks
==2112==      possibly lost: 0 bytes in 0 blocks
==2112==    still reachable: 226,535 bytes in 790 blocks
==2112==         suppressed: 0 bytes in 0 blocks
==2112== Rerun with --leak-check=full to see details of leaked memory
==2112==
==2112== For counts of detected and suppressed errors, rerun with: -v
==2112== Use --track-origins=yes to see where uninitialised values come from
==2112== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

# With bash malloc
dualbus@debian:~/src/gnu/bash$ ./bash --noprofile --norc -ic 'bind -f inputrc'

malloc: unknown:0: assertion botched
malloc: 0x557ac4e2f948: allocated: last allocated from unknown:0
free: start and end chunk sizes differ
Aborting...Aborted


From MAILER-DAEMON Thu Apr 27 08:14:15 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3iJK-0007VQ-Qy
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 08:14:14 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:56564)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3iJH-0007Tm-Nj
	for bug-bash@gnu.org; Thu, 27 Apr 2017 08:14:13 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3iJF-0008Iy-K8
	for bug-bash@gnu.org; Thu, 27 Apr 2017 08:14:11 -0400
Received: from mail-io0-x236.google.com ([2607:f8b0:4001:c06::236]:34823)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d3iJF-0008Is-EM
	for bug-bash@gnu.org; Thu, 27 Apr 2017 08:14:09 -0400
Received: by mail-io0-x236.google.com with SMTP id r16so21220008ioi.2
	for <bug-bash@gnu.org>; Thu, 27 Apr 2017 05:14:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=r88mAje/9eeRADarwJRttGnTgAaqtl2ubBUVYoY4s6o=;
	b=VLOtk9tY+aSt2mUZGpurbHZS+QmM4RJaK3B2DXYVcIN7xcSHsa0Lf9qgGwcq99GNWo
	bEK/NRQOCu6lly7s8J4XQc3IpG/UQAK1+NLIPq0CZZSPPl0/2l2eu5PVliDSNXqGGDWN
	LchDaX61mjqLaTl0woCxEgf3bgG3jgDm34OHNI1bzc+/lrEESnyjvBHd2Gg4VJ3VdgXT
	qH7DOFyPlUZTiLu984pPGRJs2kZxUth86ld3sqMgM6v7CkMdGPROWwnexMgUxL6ko5Mk
	2YcJAD6qZQOLPuhXxxTVcq0/oHJx2wX1n6F0sdbWngUQZkhw95xuBmqG3lwxDuKOx2wH
	945Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=r88mAje/9eeRADarwJRttGnTgAaqtl2ubBUVYoY4s6o=;
	b=N0FCCASkEm5kaibEP6qKrLy1EuPrY/ycByjDiAXyuXby+23+U1a7isCHfu8PS5oz0p
	8C+MEiy5BVgkChRYUSvJ5R6jK9mUue0p7hsvSuKlc77hMwDxYIz4AIA8zTm/zXwk4MD3
	oBHn7sz7Wag3QsfcVqD+zI9C1RftYBKFVlVFy2UIPfhqTMX1nY3BYsEEXXXRorim9GvC
	QGz9BTDJR0UB/bTv83utKGFWrcw6c3Rl2QeMaUQ5rE8PX+3Gc73Uxev/njdRcZTteWRD
	56TwMhcAHsUaDXzBKahqWTNlG6UkD13wtiBoRMYySB4vsYnNRFknXo4+CRedXiyhEm75
	Pj6A==
X-Gm-Message-State: AN3rC/7dROCK/vcQz03f7Q+g5XwQxi2tfEQVO5dKrz5IoTixGXZ2Yrwz
	L+naTTqpyq/FLbWTKUyKyt/c5Y9J8peW
X-Received: by 10.107.140.197 with SMTP id o188mr4151220iod.180.1493295248452; 
	Thu, 27 Apr 2017 05:14:08 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Thu, 27 Apr 2017 05:13:47 -0700 (PDT)
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Thu, 27 Apr 2017 07:13:47 -0500
Message-ID: <CAOSMAuudjzjS8CccYbJYfyM-vt5c6sDdHo+Hpgg3REG+Fv2Xtw@mail.gmail.com>
Subject: free(): invalid next size (fast): 0x00005555558cac00 ***
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::236
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 27 Apr 2017 12:14:14 -0000

dualbus@debian:~/src/gnu/bash$ xxd bar
00000000: 3a22 3030 5c43 2d0a 3030 3030 3030 3030  :"00\C-.00000000
00000010: 3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000

# With system malloc
(gdb) r --noprofile --norc -ic 'bind -f bar'
Starting program: /home/dualbus/src/gnu/bash/bash --noprofile --norc
-ic 'bind -f bar'
*** Error in `/home/dualbus/src/gnu/bash/bash': free(): invalid next
size (fast): 0x00005555558cac00 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bcb)[0x7ffff767dbcb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76f96)[0x7ffff7683f96]
/lib/x86_64-linux-gnu/libc.so.6(+0x7778e)[0x7ffff768478e]
/home/dualbus/src/gnu/bash/bash(xfree+0x1f)[0x5555555f66b6]
/home/dualbus/src/gnu/bash/bash(rl_generic_bind+0x46)[0x55555563993a]
/home/dualbus/src/gnu/bash/bash(rl_macro_bind+0x7a)[0x5555556398ed]
/home/dualbus/src/gnu/bash/bash(rl_parse_and_bind+0x759)[0x55555563bd08]
/home/dualbus/src/gnu/bash/bash(+0xe6e40)[0x55555563ae40]
/home/dualbus/src/gnu/bash/bash(rl_read_init_file+0x8a)[0x55555563aca9]
/home/dualbus/src/gnu/bash/bash(bind_builtin+0x382)[0x5555555f6e4c]
/home/dualbus/src/gnu/bash/bash(+0x4dff1)[0x5555555a1ff1]
/home/dualbus/src/gnu/bash/bash(+0x4eecd)[0x5555555a2ecd]
/home/dualbus/src/gnu/bash/bash(+0x4d8f7)[0x5555555a18f7]
/home/dualbus/src/gnu/bash/bash(execute_command_internal+0x80a)[0x55555559b2af]
/home/dualbus/src/gnu/bash/bash(parse_and_execute+0x548)[0x5555555fe1e8]
/home/dualbus/src/gnu/bash/bash(+0x2f32f)[0x55555558332f]
/home/dualbus/src/gnu/bash/bash(main+0x83a)[0x5555555824aa]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7ffff762d2b1]
/home/dualbus/src/gnu/bash/bash(_start+0x2a)[0x555555581b6a]
======= Memory map: ========
555555554000-55555568e000 r-xp 00000000 fe:01 17570830
  /home/dualbus/src/gnu/bash/bash
55555588e000-555555891000 r--p 0013a000 fe:01 17570830
  /home/dualbus/src/gnu/bash/bash
555555891000-55555589b000 rw-p 0013d000 fe:01 17570830
  /home/dualbus/src/gnu/bash/bash
55555589b000-555555908000 rw-p 00000000 00:00 0                          [heap]
7ffff0000000-7ffff0021000 rw-p 00000000 00:00 0
7ffff0021000-7ffff4000000 ---p 00000000 00:00 0
7ffff6bb8000-7ffff6bce000 r-xp 00000000 fe:01 1310769
  /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffff6bce000-7ffff6dcd000 ---p 00016000 fe:01 1310769
  /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffff6dcd000-7ffff6dce000 r--p 00015000 fe:01 1310769
  /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffff6dce000-7ffff6dcf000 rw-p 00016000 fe:01 1310769
  /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffff6dcf000-7ffff6dd9000 r-xp 00000000 fe:01 1311109
  /lib/x86_64-linux-gnu/libnss_files-2.24.so
7ffff6dd9000-7ffff6fd9000 ---p 0000a000 fe:01 1311109
  /lib/x86_64-linux-gnu/libnss_files-2.24.so
7ffff6fd9000-7ffff6fda000 r--p 0000a000 fe:01 1311109
  /lib/x86_64-linux-gnu/libnss_files-2.24.so
7ffff6fda000-7ffff6fdb000 rw-p 0000b000 fe:01 1311109
  /lib/x86_64-linux-gnu/libnss_files-2.24.so
7ffff6fdb000-7ffff6fe1000 rw-p 00000000 00:00 0
7ffff6fe1000-7ffff6fec000 r-xp 00000000 fe:01 1311111
  /lib/x86_64-linux-gnu/libnss_nis-2.24.so
7ffff6fec000-7ffff71eb000 ---p 0000b000 fe:01 1311111
  /lib/x86_64-linux-gnu/libnss_nis-2.24.so
7ffff71eb000-7ffff71ec000 r--p 0000a000 fe:01 1311111
  /lib/x86_64-linux-gnu/libnss_nis-2.24.so
7ffff71ec000-7ffff71ed000 rw-p 0000b000 fe:01 1311111
  /lib/x86_64-linux-gnu/libnss_nis-2.24.so
7ffff71ed000-7ffff7201000 r-xp 00000000 fe:01 1311105
  /lib/x86_64-linux-gnu/libnsl-2.24.so
7ffff7201000-7ffff7401000 ---p 00014000 fe:01 1311105
  /lib/x86_64-linux-gnu/libnsl-2.24.so
7ffff7401000-7ffff7402000 r--p 00014000 fe:01 1311105
  /lib/x86_64-linux-gnu/libnsl-2.24.so
7ffff7402000-7ffff7403000 rw-p 00015000 fe:01 1311105
  /lib/x86_64-linux-gnu/libnsl-2.24.so
7ffff7403000-7ffff7405000 rw-p 00000000 00:00 0
7ffff7405000-7ffff740c000 r-xp 00000000 fe:01 1311107
  /lib/x86_64-linux-gnu/libnss_compat-2.24.so
7ffff740c000-7ffff760b000 ---p 00007000 fe:01 1311107
  /lib/x86_64-linux-gnu/libnss_compat-2.24.so
7ffff760b000-7ffff760c000 r--p 00006000 fe:01 1311107
  /lib/x86_64-linux-gnu/libnss_compat-2.24.so
7ffff760c000-7ffff760d000 rw-p 00007000 fe:01 1311107
  /lib/x86_64-linux-gnu/libnss_compat-2.24.so
7ffff760d000-7ffff77a2000 r-xp 00000000 fe:01 1311097
  /lib/x86_64-linux-gnu/libc-2.24.so
7ffff77a2000-7ffff79a1000 ---p 00195000 fe:01 1311097
  /lib/x86_64-linux-gnu/libc-2.24.so
7ffff79a1000-7ffff79a5000 r--p 00194000 fe:01 1311097
  /lib/x86_64-linux-gnu/libc-2.24.so
7ffff79a5000-7ffff79a7000 rw-p 00198000 fe:01 1311097
  /lib/x86_64-linux-gnu/libc-2.24.so
7ffff79a7000-7ffff79ab000 rw-p 00000000 00:00 0
7ffff79ab000-7ffff79ad000 r-xp 00000000 fe:01 1311100
  /lib/x86_64-linux-gnu/libdl-2.24.so
7ffff79ad000-7ffff7bad000 ---p 00002000 fe:01 1311100
  /lib/x86_64-linux-gnu/libdl-2.24.so
7ffff7bad000-7ffff7bae000 r--p 00002000 fe:01 1311100
  /lib/x86_64-linux-gnu/libdl-2.24.so
7ffff7bae000-7ffff7baf000 rw-p 00003000 fe:01 1311100
  /lib/x86_64-linux-gnu/libdl-2.24.so
7ffff7baf000-7ffff7bd4000 r-xp 00000000 fe:01 1310814
  /lib/x86_64-linux-gnu/libtinfo.so.5.9
7ffff7bd4000-7ffff7dd4000 ---p 00025000 fe:01 1310814
  /lib/x86_64-linux-gnu/libtinfo.so.5.9
7ffff7dd4000-7ffff7dd8000 r--p 00025000 fe:01 1310814
  /lib/x86_64-linux-gnu/libtinfo.so.5.9
7ffff7dd8000-7ffff7dd9000 rw-p 00029000 fe:01 1310814
  /lib/x86_64-linux-gnu/libtinfo.so.5.9
7ffff7dd9000-7ffff7dfc000 r-xp 00000000 fe:01 1310829
  /lib/x86_64-linux-gnu/ld-2.24.so
7ffff7e60000-7ffff7e61000 rw-p 00000000 00:00 0
7ffff7e61000-7ffff7eb2000 r--p 00000000 fe:01 26352446
  /usr/lib/locale/aa_DJ.utf8/LC_CTYPE
7ffff7eb2000-7ffff7fe2000 r--p 00000000 fe:01 26352445
  /usr/lib/locale/aa_DJ.utf8/LC_COLLATE
7ffff7fe2000-7ffff7fe4000 rw-p 00000000 00:00 0
7ffff7fe4000-7ffff7fe5000 r--p 00000000 fe:01 26352476
  /usr/lib/locale/aa_ET/LC_NUMERIC
7ffff7fe5000-7ffff7fe6000 r--p 00000000 fe:01 26476650
  /usr/lib/locale/en_US.utf8/LC_TIME
7ffff7fe6000-7ffff7fe7000 r--p 00000000 fe:01 26353097
  /usr/lib/locale/chr_US/LC_MONETARY
7ffff7fe7000-7ffff7fe8000 r--p 00000000 fe:01 26353383
  /usr/lib/locale/en_AG/LC_MESSAGES/SYS_LC_MESSAGES
7ffff7fe8000-7ffff7fe9000 r--p 00000000 fe:01 26353099
  /usr/lib/locale/chr_US/LC_PAPER
7ffff7fe9000-7ffff7fea000 r--p 00000000 fe:01 26353098
  /usr/lib/locale/chr_US/LC_NAME
7ffff7fea000-7ffff7feb000 r--p 00000000 fe:01 26476647
  /usr/lib/locale/en_US.utf8/LC_ADDRESS
7ffff7feb000-7ffff7fec000 r--p 00000000 fe:01 26353100
  /usr/lib/locale/chr_US/LC_TELEPHONE
7ffff7fec000-7ffff7fed000 r--p 00000000 fe:01 26353094
  /usr/lib/locale/chr_US/LC_MEASUREMENT
7ffff7fed000-7ffff7ff4000 r--s 00000000 fe:01 25438256
  /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
7ffff7ff4000-7ffff7ff5000 r--p 00000000 fe:01 26476648
  /usr/lib/locale/en_US.utf8/LC_IDENTIFICATION
7ffff7ff5000-7ffff7ff8000 rw-p 00000000 00:00 0
7ffff7ff8000-7ffff7ffa000 r--p 00000000 00:00 0                          [vvar]
7ffff7ffa000-7ffff7ffc000 r-xp 00000000 00:00 0                          [vdso]
7ffff7ffc000-7ffff7ffd000 r--p 00023000 fe:01 1310829
  /lib/x86_64-linux-gnu/ld-2.24.so
7ffff7ffd000-7ffff7ffe000 rw-p 00024000 fe:01 1310829
  /lib/x86_64-linux-gnu/ld-2.24.so
7ffff7ffe000-7ffff7fff000 rw-p 00000000 00:00 0
7ffffffde000-7ffffffff000 rw-p 00000000 00:00 0                          [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
  [vsyscall]

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
58      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
#1  0x00007ffff764140a in __GI_abort () at abort.c:89
#2  0x00007ffff767dbd0 in __libc_message (do_abort=do_abort@entry=2,
    fmt=fmt@entry=0x7ffff7772c30 "*** Error in `%s': %s: 0x%s ***\n")
at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff7683f96 in malloc_printerr (action=3,
str=0x7ffff7772d40 "free(): invalid next size (fast)", ptr=<optimized
out>,
    ar_ptr=<optimized out>) at malloc.c:5046
#4  0x00007ffff768478e in _int_free (av=0x7ffff79a5b00 <main_arena>,
p=0x5555558cabf0, have_lock=0) at malloc.c:3902
#5  0x00005555555f66b6 in xfree (string=0x5555558cac00) at xmalloc.c:148
#6  0x000055555563993a in rl_generic_bind (type=2,
keyseq=0x7fffffffde4a "", data=0x5555558cac00 "00",
    map=0x555555895140 <emacs_standard_keymap>) at bind.c:338
#7  0x00005555556398ed in rl_macro_bind (keyseq=0x7fffffffde4a "",
macro=0x5555558cac62 "00\\C-",
    map=0x555555895140 <emacs_standard_keymap>) at bind.c:315
#8  0x000055555563bd08 in rl_parse_and_bind (string=0x5555558cac60 "")
at bind.c:1450
#9  0x000055555563ae40 in _rl_read_init_file (filename=0x5555558b8740
"bar", include_level=0) at bind.c:927
#10 0x000055555563aca9 in rl_read_init_file (filename=0x5555558b8740
"bar") at bind.c:870
#11 0x00005555555f6e4c in bind_builtin (list=0x0) at ./bind.def:248
#12 0x00005555555a1ff1 in execute_builtin (builtin=0x5555555f6aca
<bind_builtin>, words=0x5555558b88e0, flags=64, subshell=0)
    at execute_cmd.c:4603
#13 0x00005555555a2ecd in execute_builtin_or_function
(words=0x5555558b88e0, builtin=0x5555555f6aca <bind_builtin>, var=0x0,
    redirects=0x0, fds_to_close=0x5555558b85d0, flags=64) at execute_cmd.c:5101
#14 0x00005555555a18f7 in execute_simple_command
(simple_command=0x5555558b8510, pipe_in=-1, pipe_out=-1, async=0,
    fds_to_close=0x5555558b85d0) at execute_cmd.c:4389
#15 0x000055555559b2af in execute_command_internal
(command=0x5555558b84e0, asynchronous=0, pipe_in=-1, pipe_out=-1,
    fds_to_close=0x5555558b85d0) at execute_cmd.c:811
#16 0x00005555555fe1e8 in parse_and_execute (string=0x5555558a9340
"bind -f bar", from_file=0x555555656830 "-c", flags=4)
    at evalstring.c:430
#17 0x000055555558332f in run_one_command (command=0x7fffffffe72e
"bind -f bar") at shell.c:1405
#18 0x00005555555824aa in main (argc=5, argv=0x7fffffffe458,
env=0x7fffffffe488) at shell.c:718

# With ASAN
dualbus@debian:~/src/gnu/bash$ ./bash --noprofile --norc -ic 'bind -f bar'
=================================================================
==24192==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x602000009c3b at pc 0x55f8abc481c3 bp 0x7fff59f1f3f0 sp
0x7fff59f1f3e8
WRITE of size 1 at 0x602000009c3b thread T0
    #0 0x55f8abc481c2 in rl_translate_keyseq
/home/dualbus/src/gnu/bash/lib/readline/bind.c:548
    #1 0x55f8abc46729 in rl_macro_bind
/home/dualbus/src/gnu/bash/lib/readline/bind.c:310
    #2 0x55f8abc4c605 in rl_parse_and_bind
/home/dualbus/src/gnu/bash/lib/readline/bind.c:1450
    #3 0x55f8abc4a103 in _rl_read_init_file
/home/dualbus/src/gnu/bash/lib/readline/bind.c:927
    #4 0x55f8abc49d4c in rl_read_init_file
/home/dualbus/src/gnu/bash/lib/readline/bind.c:870
    #5 0x55f8abbbd01c in bind_builtin bind.def:248
    #6 0x55f8abaf672b in execute_builtin
/home/dualbus/src/gnu/bash/execute_cmd.c:4603
    #7 0x55f8abaf8341 in execute_builtin_or_function
/home/dualbus/src/gnu/bash/execute_cmd.c:5101
    #8 0x55f8abaf5bc1 in execute_simple_command
/home/dualbus/src/gnu/bash/execute_cmd.c:4389
    #9 0x55f8abae3ac2 in execute_command_internal
/home/dualbus/src/gnu/bash/execute_cmd.c:811
    #10 0x55f8abbcd4ae in parse_and_execute
/home/dualbus/src/gnu/bash/builtins/evalstring.c:430
    #11 0x55f8abaaf121 in run_one_command
/home/dualbus/src/gnu/bash/shell.c:1405
    #12 0x55f8abaad5fa in main /home/dualbus/src/gnu/bash/shell.c:718
    #13 0x7f0963e132b0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    #14 0x55f8abaac469 in _start (/home/dualbus/src/gnu/bash/bash+0x7f469)

0x602000009c3b is located 0 bytes to the right of 11-byte region
[0x602000009c30,0x602000009c3b)
allocated by thread T0 here:
    #0 0x7f0964680d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
    #1 0x55f8abbbc195 in xmalloc /home/dualbus/src/gnu/bash/xmalloc.c:112
    #2 0x55f8abc46705 in rl_macro_bind
/home/dualbus/src/gnu/bash/lib/readline/bind.c:308
    #3 0x55f8abc4c605 in rl_parse_and_bind
/home/dualbus/src/gnu/bash/lib/readline/bind.c:1450
    #4 0x55f8abc4a103 in _rl_read_init_file
/home/dualbus/src/gnu/bash/lib/readline/bind.c:927
    #5 0x55f8abc49d4c in rl_read_init_file
/home/dualbus/src/gnu/bash/lib/readline/bind.c:870
    #6 0x55f8abbbd01c in bind_builtin bind.def:248
    #7 0x55f8abaf672b in execute_builtin
/home/dualbus/src/gnu/bash/execute_cmd.c:4603
    #8 0x55f8abaf8341 in execute_builtin_or_function
/home/dualbus/src/gnu/bash/execute_cmd.c:5101
    #9 0x55f8abaf5bc1 in execute_simple_command
/home/dualbus/src/gnu/bash/execute_cmd.c:4389
    #10 0x55f8abae3ac2 in execute_command_internal
/home/dualbus/src/gnu/bash/execute_cmd.c:811
    #11 0x55f8abbcd4ae in parse_and_execute
/home/dualbus/src/gnu/bash/builtins/evalstring.c:430
    #12 0x55f8abaaf121 in run_one_command
/home/dualbus/src/gnu/bash/shell.c:1405
    #13 0x55f8abaad5fa in main /home/dualbus/src/gnu/bash/shell.c:718
    #14 0x7f0963e132b0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b0)

SUMMARY: AddressSanitizer: heap-buffer-overflow
/home/dualbus/src/gnu/bash/lib/readline/bind.c:548 in
rl_translate_keyseq
Shadow bytes around the buggy address:
  0x0c047fff9330: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9340: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9350: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9360: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9370: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c047fff9380: fa fa fa fa fa fa 00[03]fa fa 04 fa fa fa fd fa
  0x0c047fff9390: fa fa fd fa fa fa fd fa fa fa 00 07 fa fa fd fa
  0x0c047fff93a0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff93b0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff93c0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff93d0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==24192==ABORTING


From MAILER-DAEMON Thu Apr 27 08:24:19 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3iT5-0003ms-I1
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 08:24:19 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59576)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3iT2-0003ks-UV
	for bug-bash@gnu.org; Thu, 27 Apr 2017 08:24:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3iT2-0003Y2-4q
	for bug-bash@gnu.org; Thu, 27 Apr 2017 08:24:16 -0400
Received: from mail-io0-x233.google.com ([2607:f8b0:4001:c06::233]:34441)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d3iT1-0003Xs-Vr
	for bug-bash@gnu.org; Thu, 27 Apr 2017 08:24:16 -0400
Received: by mail-io0-x233.google.com with SMTP id a103so21369199ioj.1
	for <bug-bash@gnu.org>; Thu, 27 Apr 2017 05:24:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=XWqmoSTWM1D9N8sIQxl/EMzkHI4274NUhFiwcGOWF7c=;
	b=fJVVIQTC7Q5nHIgAbtR86ePcdJObbv0sHoYz+bs1uQ3pI/b30CYFSdE6XrWgnuBeWF
	JcL5Sc5n9xogMPi9AuddDBGReOcBHyTR7gsotKuA6oWdx3/8Y3H9MVGyXmW7yxCEs1vi
	MtUyZ65oHvnNE8C98HQtj2K+2LfDqb6pEGiCBu+aoyTdtGuGRR2xNE7T8JYhLQJJYvaN
	FzWtQD6y1IGtjevfLkP+mUNg+RRh813xtlAz8617lpwuUFz0sCZkhBqh0QEUI/3eX1dr
	HTk34ZV7DzfcT4U2GfkB4vTRpECC5gMe4lC4JCidoPsPr6Uk0Vx5hEpejXFsOYYtBX1F
	YeMw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=XWqmoSTWM1D9N8sIQxl/EMzkHI4274NUhFiwcGOWF7c=;
	b=ZeqV2F+QpUFsg8/z6xIu1Ylh36F/fqpXCGNUBemEwu9UmaYA+dCACeoYB9SxApwAiY
	m/NwLWOVdty8GNutiROm3uSBbyqsTYZGIxnH9kR+4TIOwXD4UVdyRsvqmS4DCo7UpRuS
	Q/xKSza1M1aQ1Q5umnQi5bBznyCxUnFDwGeBmvxg4kpAo+L6cFVr0/MoDazz7+42csaQ
	eT1sVIdN5JyInZEOMoYrHRWLJapN6befmPGMxGbSw3n/JrtPJwOZXaK6dzujozJTOLG+
	c+/cSjyszKMRFwV+k0ELW0vmV3/P3N0qLUtEPeoL2UZvKIPMqJFZRHqs/+RR1S1LFXMu
	XG7A==
X-Gm-Message-State: AN3rC/6aFTelyL7hltE7bu9S+dGbiMnBGeRwCyc5TBl2Xe98gnpn1TD5
	+7zJJ80fKVchrQfv1bnO9FyMZw9lDpdV
X-Received: by 10.107.140.197 with SMTP id o188mr4192696iod.180.1493295855201; 
	Thu, 27 Apr 2017 05:24:15 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Thu, 27 Apr 2017 05:23:54 -0700 (PDT)
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Thu, 27 Apr 2017 07:23:54 -0500
Message-ID: <CAOSMAuushrbcvqv51k_qwRQZUVGNUa70pn1JXzdR2ND_oHYiCA@mail.gmail.com>
Subject: Memory leak in read_history_range when history file size is zero
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::233
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 27 Apr 2017 12:24:18 -0000

dualbus@debian:~/src/gnu/bash$ ./bash --noprofile --norc -ic
'HISTFILE=/dev/null; history -r'

=================================================================
==24289==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x7efe83383d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
    #1 0x55a42abc3195 in xmalloc /home/dualbus/src/gnu/bash/xmalloc.c:112
    #2 0x55a42ac8b2c2 in history_filename
/home/dualbus/src/gnu/bash/lib/readline/histfile.c:152
    #3 0x55a42ac8bc5a in read_history_range
/home/dualbus/src/gnu/bash/lib/readline/histfile.c:280
    #4 0x55a42ac8bb7e in read_history
/home/dualbus/src/gnu/bash/lib/readline/histfile.c:253
    #5 0x55a42abdd23a in history_builtin history.def:273
    #6 0x55a42aafd72b in execute_builtin
/home/dualbus/src/gnu/bash/execute_cmd.c:4603
    #7 0x55a42aaff341 in execute_builtin_or_function
/home/dualbus/src/gnu/bash/execute_cmd.c:5101
    #8 0x55a42aafcbc1 in execute_simple_command
/home/dualbus/src/gnu/bash/execute_cmd.c:4389
    #9 0x55a42aaeaac2 in execute_command_internal
/home/dualbus/src/gnu/bash/execute_cmd.c:811
    #10 0x55a42aaf33ac in execute_connection
/home/dualbus/src/gnu/bash/execute_cmd.c:2637
    #11 0x55a42aaeb897 in execute_command_internal
/home/dualbus/src/gnu/bash/execute_cmd.c:980
    #12 0x55a42abd44ae in parse_and_execute
/home/dualbus/src/gnu/bash/builtins/evalstring.c:430
    #13 0x55a42aab6121 in run_one_command
/home/dualbus/src/gnu/bash/shell.c:1405
    #14 0x55a42aab45fa in main /home/dualbus/src/gnu/bash/shell.c:718
    #15 0x7efe82b162b0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b0)

SUMMARY: AddressSanitizer: 10 byte(s) leaked in 1 allocation(s).


Fix:

dualbus@debian:~/src/gnu/bash$ git diff -- lib/readline/histfile.c
diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c
index 489801b4..66a76118 100644
--- a/lib/readline/histfile.c
+++ b/lib/readline/histfile.c
@@ -292,8 +292,10 @@ read_history_range (const char *filename, int from, int to)
       goto error_and_exit;
     }

-  if (file_size == 0)
+  if (file_size == 0) {
+    FREE (input);
     return 0;  /* don't waste time if we don't have to */
+  }

 #ifdef HISTORY_USE_MMAP
   /* We map read/write and private so we can change newlines to NULs without


From MAILER-DAEMON Thu Apr 27 14:29:43 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3oAh-00026r-LL
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 14:29:43 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52835)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3oAf-00026e-3t
	for bug-bash@gnu.org; Thu, 27 Apr 2017 14:29:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3oAc-0002yc-2M
	for bug-bash@gnu.org; Thu, 27 Apr 2017 14:29:41 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:61062
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d3oAb-0002xn-TA
	for bug-bash@gnu.org; Thu, 27 Apr 2017 14:29:38 -0400
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMW31800; Thu, 27 Apr 2017 14:29:30 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDW66429 (AUTH cpr);
	Thu, 27 Apr 2017 14:29:28 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: Memory leak in read_history_range when history file size is zero
References: <CAOSMAuushrbcvqv51k_qwRQZUVGNUa70pn1JXzdR2ND_oHYiCA@mail.gmail.com>
To: Eduardo Bustamante <dualbus@gmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <80990747-b2bd-cfcd-45f4-a5981a8d76e8@case.edu>
Date: Thu, 27 Apr 2017 14:29:27 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOSMAuushrbcvqv51k_qwRQZUVGNUa70pn1JXzdR2ND_oHYiCA@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.27.180016:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC1,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR,
	__SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_400_LESS,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_300_399,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 27 Apr 2017 18:29:42 -0000

On 4/27/17 8:23 AM, Eduardo Bustamante wrote:
> dualbus@debian:~/src/gnu/bash$ ./bash --noprofile --norc -ic
> 'HISTFILE=/dev/null; history -r'

Thanks for the report and fix.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 27 15:10:04 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3onk-0001j6-F0
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 15:10:04 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34212)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3onh-0001hX-GG
	for bug-bash@gnu.org; Thu, 27 Apr 2017 15:10:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3ond-0001od-GL
	for bug-bash@gnu.org; Thu, 27 Apr 2017 15:10:01 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:2150
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d3ond-0001oS-AI
	for bug-bash@gnu.org; Thu, 27 Apr 2017 15:09:57 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMW33590; Thu, 27 Apr 2017 15:09:55 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDL87296 (AUTH cpr);
	Thu, 27 Apr 2017 15:09:55 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: free(): invalid next size (fast): 0x00005555558cac00 ***
References: <CAOSMAuudjzjS8CccYbJYfyM-vt5c6sDdHo+Hpgg3REG+Fv2Xtw@mail.gmail.com>
To: Eduardo Bustamante <dualbus@gmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <3aa838e6-dd43-2e53-e186-63d624d74267@case.edu>
Date: Thu, 27 Apr 2017 15:09:54 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOSMAuudjzjS8CccYbJYfyM-vt5c6sDdHo+Hpgg3REG+Fv2Xtw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.27.180016:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID,
	DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT,
	__MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC1, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_500_599,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 27 Apr 2017 19:10:02 -0000

On 4/27/17 8:13 AM, Eduardo Bustamante wrote:
> dualbus@debian:~/src/gnu/bash$ xxd bar
> 00000000: 3a22 3030 5c43 2d0a 3030 3030 3030 3030  :"00\C-.00000000
> 00000010: 3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000

Thanks for the report.  This should generate an invalid key binding
error.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 27 15:35:32 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3pCO-0008Nk-4a
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 15:35:32 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39037)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3pCM-0008Ne-9N
	for bug-bash@gnu.org; Thu, 27 Apr 2017 15:35:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3pCI-0003JY-Vb
	for bug-bash@gnu.org; Thu, 27 Apr 2017 15:35:30 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:8286
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d3pCI-0003JU-PS
	for bug-bash@gnu.org; Thu, 27 Apr 2017 15:35:26 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMW35682; Thu, 27 Apr 2017 15:35:25 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDL93060 (AUTH cpr);
	Thu, 27 Apr 2017 15:35:24 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: AddressSanitizer: heap-buffer-overflow lib/readline/bind.c:437 in
	rl_translate_keyseq
References: <CAOSMAutn8+f03ay8_DTAtcwjArMGqR0ZBkOigMVq3SXCyTrgyA@mail.gmail.com>
To: Eduardo Bustamante <dualbus@gmail.com>,
	"bug-bash@gnu.org" <bug-bash@gnu.org>
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <4ebf3c91-29cc-8fce-3892-cba764dd157a@case.edu>
Date: Thu, 27 Apr 2017 15:35:23 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAOSMAutn8+f03ay8_DTAtcwjArMGqR0ZBkOigMVq3SXCyTrgyA@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.27.190316:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __REFERENCES, __TO_MALFORMED_2,
	__TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR,
	__HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID,
	DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT,
	__MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC1, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW,
	BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_400_499,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 27 Apr 2017 19:35:31 -0000

On 4/27/17 8:02 AM, Eduardo Bustamante wrote:
> dualbus@debian:~/src/gnu/bash$ xxd inputrc
> 00000000: 225c 432d 2230 3030 200a                 "\C-"000 .

Thanks for the report.  This was an easy fix. You must be fuzzing
readline's key sequence parser.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 27 15:56:23 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3pWZ-0006oe-4H
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 15:56:23 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43724)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Vladimir.Marek@oracle.com>) id 1d3pWW-0006mh-9I
	for bug-bash@gnu.org; Thu, 27 Apr 2017 15:56:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Vladimir.Marek@oracle.com>) id 1d3pWR-0003RW-7t
	for bug-bash@gnu.org; Thu, 27 Apr 2017 15:56:20 -0400
Received: from aserp1040.oracle.com ([141.146.126.69]:40823)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <Vladimir.Marek@oracle.com>)
	id 1d3pWQ-0003Pd-VX
	for bug-bash@gnu.org; Thu, 27 Apr 2017 15:56:15 -0400
Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233])
	by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with
	ESMTP id v3RJuB18015461
	(version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Thu, 27 Apr 2017 19:56:12 GMT
Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72])
	by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v3RJuBcS019623
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Thu, 27 Apr 2017 19:56:11 GMT
Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22])
	by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v3RJuB42011572
	for <bug-bash@gnu.org>; Thu, 27 Apr 2017 19:56:11 GMT
Received: from virtual.cz.oracle.com (/10.163.86.11)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Thu, 27 Apr 2017 12:56:10 -0700
Date: Thu, 27 Apr 2017 21:56:09 +0200
From: Vladimir Marek <Vladimir.Marek@oracle.com>
To: bug-bash@gnu.org
Subject: Core dump
Message-ID: <20170427195608.GE29449@virtual.cz.oracle.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16)
X-Source-IP: aserv0021.oracle.com [141.146.126.233]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 141.146.126.69
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 27 Apr 2017 19:56:21 -0000

Hi,

array_to_key() {
       # Converts 1 2 3 -> 1,2,3, (comma at the end)
       printf '%d,' "$@"
}

multi_store() {
       local array_name="$1"; shift
       local value="$1"; shift
       if unset -v "$array_name"; then
              declare -A $array_name
              declare -- $array_name[$(array_to_key "$@")]="$value"
       fi
}

multi_store CHESS_3D queen 2 2 5

(segfault)



pstack core
core 'core' of 8005:    /bin/bash
 00000000004bb8ea hash_search () + 7a
 00000000004ce08d assoc_insert () + 1d
 00000000004cb259 assign_array_element () + 30d
 00000000004eab03 declare_builtin () + 5e7
 00000000004713ff ???????? ()
 0000000000470302 ???????? ()
 0000000000469824 execute_command_internal () + 72c
 000000000046d2f3 ???????? ()
 000000000046965a execute_command_internal () + 562
 0000000000469026 execute_command () + 9e
 00000000004696d5 execute_command_internal () + 5dd
 000000000046d2f3 ???????? ()
 000000000046965a execute_command_internal () + 562
 0000000000469695 execute_command_internal () + 59d
 0000000000470bef ???????? ()
 000000000047147e ???????? ()
 00000000004703a2 ???????? ()
 0000000000469824 execute_command_internal () + 72c
 0000000000469026 execute_command () + 9e
 0000000000449f88 reader_loop () + 318
 0000000000447f37 main () + e9b
 0000000000446f3c ???????? ()


Confirmed on linux and solaris. The intention was to create something
similar to famous 'upvar' function but dealing with a hash. I'm not 100%
sure it should work this way, but core dump seems to be a bit of an
overreaction :)

Thank you for bash, Chet!
-- 
	Vlad


From MAILER-DAEMON Thu Apr 27 17:57:17 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3rPZ-0000w7-E1
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 17:57:17 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:45147)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3rPX-0000w1-6r
	for bug-bash@gnu.org; Thu, 27 Apr 2017 17:57:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d3rPU-0002eJ-4r
	for bug-bash@gnu.org; Thu, 27 Apr 2017 17:57:15 -0400
Received: from mpv2-2015.cwru.edu ([129.22.103.227]:30132
	helo=mpv1-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d3rPT-0002dV-V3
	for bug-bash@gnu.org; Thu, 27 Apr 2017 17:57:12 -0400
Received: from mpv8-2015.CWRU.Edu (EHLO mpv8-2015.case.edu) ([129.22.103.210])
	by mpv2-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMW41916; Thu, 27 Apr 2017 17:57:05 -0400 (EDT)
Received: from h251.66.130.174.dynamic.ip.windstream.net (EHLO
	_192.168.254.3_) ([174.130.66.251])
	by mpv8-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id HCF70930 (AUTH cpr);
	Thu, 27 Apr 2017 17:57:04 -0400 (EDT)
X-pre-Mira-Junkmail: RBL
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: Core dump
To: Vladimir Marek <Vladimir.Marek@oracle.com>, bug-bash@gnu.org
References: <20170427195608.GE29449@virtual.cz.oracle.com>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <772fdb89-baaa-8f8a-bb72-a7c734c0efe9@case.edu>
Date: Thu, 27 Apr 2017 17:57:03 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0.1
MIME-Version: 1.0
In-Reply-To: <20170427195608.GE29449@virtual.cz.oracle.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.27.210316:17:8.317, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR, LEO_OBFU_SUBJ_RE,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME,
	__TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC1, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __STOCK_PHRASE_7,
	__FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODY_SIZE_700_799,
	BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1,
	__MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10,
	__FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS, IN_REP_TO,
	MSG_THREAD, [TRUNCATED], so=2010-03-03 19:42:08,
	dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 27 Apr 2017 21:57:16 -0000

On 4/27/17 3:56 PM, Vladimir Marek wrote:
> array_to_key() {
>        # Converts 1 2 3 -> 1,2,3, (comma at the end)
>        printf '%d,' "$@"
> }
> 
> multi_store() {
>        local array_name="$1"; shift
>        local value="$1"; shift
>        if unset -v "$array_name"; then
>               declare -A $array_name
>               declare -- $array_name[$(array_to_key "$@")]="$value"
>        fi
> }
> 
> multi_store CHESS_3D queen 2 2 5

Bash version? This was fixed before bash-4.3 was released.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Thu Apr 27 18:09:53 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3rbl-0000JK-Lb
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 18:09:53 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51381)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Vladimir.Marek@oracle.com>) id 1d3rbj-0000Hh-Cb
	for bug-bash@gnu.org; Thu, 27 Apr 2017 18:09:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Vladimir.Marek@oracle.com>) id 1d3rbe-0002IR-FU
	for bug-bash@gnu.org; Thu, 27 Apr 2017 18:09:51 -0400
Received: from aserp1040.oracle.com ([141.146.126.69]:32823)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <Vladimir.Marek@oracle.com>)
	id 1d3rbe-0002Hv-4n
	for bug-bash@gnu.org; Thu, 27 Apr 2017 18:09:46 -0400
Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71])
	by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with
	ESMTP id v3RM9aES001427
	(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);
	Thu, 27 Apr 2017 22:09:36 GMT
Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72])
	by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v3RM9ZEi023221
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256
	verify=OK); Thu, 27 Apr 2017 22:09:35 GMT
Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15])
	by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v3RM9Zkj016322;
	Thu, 27 Apr 2017 22:09:35 GMT
Received: from virtual.cz.oracle.com (/10.163.86.11)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Thu, 27 Apr 2017 15:09:35 -0700
Date: Fri, 28 Apr 2017 00:09:33 +0200
From: Vladimir Marek <Vladimir.Marek@oracle.com>
To: Chet Ramey <chet.ramey@case.edu>
Cc: bug-bash@gnu.org
Subject: Re: Core dump
Message-ID: <20170427220932.GG29449@virtual.cz.oracle.com>
References: <20170427195608.GE29449@virtual.cz.oracle.com>
	<772fdb89-baaa-8f8a-bb72-a7c734c0efe9@case.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <772fdb89-baaa-8f8a-bb72-a7c734c0efe9@case.edu>
User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16)
X-Source-IP: userv0021.oracle.com [156.151.31.71]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 141.146.126.69
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Thu, 27 Apr 2017 22:09:52 -0000

> > array_to_key() {
> >        # Converts 1 2 3 -> 1,2,3, (comma at the end)
> >        printf '%d,' "$@"
> > }
> > 
> > multi_store() {
> >        local array_name="$1"; shift
> >        local value="$1"; shift
> >        if unset -v "$array_name"; then
> >               declare -A $array_name
> >               declare -- $array_name[$(array_to_key "$@")]="$value"
> >        fi
> > }
> > 
> > multi_store CHESS_3D queen 2 2 5
> 
> Bash version? This was fixed before bash-4.3 was released.

Oh, I thought originally it's latest stable, but on second look that
machine was not updated yet. So both Solaris and linux older that 4.3.

I'm sorry for the noise
-- 
	Vlad


From MAILER-DAEMON Thu Apr 27 21:34:27 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d3unj-0008Dm-4A
	for mharc-bug-bash@gnu.org; Thu, 27 Apr 2017 21:34:27 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43385)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3ung-0008Dg-JF
	for bug-bash@gnu.org; Thu, 27 Apr 2017 21:34:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d3unf-0003XI-OC
	for bug-bash@gnu.org; Thu, 27 Apr 2017 21:34:24 -0400
Received: from mail-io0-x22a.google.com ([2607:f8b0:4001:c06::22a]:33552)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d3unf-0003Ww-KH
	for bug-bash@gnu.org; Thu, 27 Apr 2017 21:34:23 -0400
Received: by mail-io0-x22a.google.com with SMTP id k87so43928196ioi.0
	for <bug-bash@gnu.org>; Thu, 27 Apr 2017 18:34:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=0Q87+kCImDXbkbU8saZjq2dHavTrD5t5U4+NGf8dn84=;
	b=XhdBeFiGUv4oQPI6x/LtCD3xON6ibL8+L9ox/c0dITAhPE4bzE9xW0/815dZVTPebx
	e1ihzeOvHpddJhtVd26GPHvdOAz5uR3iPWi8Y1YDsQrLQiNR1dGmryZfd2SiT3owP9sZ
	qttvqiFANs4jymUsMrwKD1oplTlDu3Vtn8L/NyHq5af//Qmf6goEHLnRO/f+tfipXVyM
	Oxnr6dRCuKDifVHc42SR4yjqE54UcnALlTcDUsOn4vNw3AbMppl+L9nvX0oyoKMrMrmW
	rh2AERBY5BtPJeO29wIQcwuxUxr6IgEMIUwtOPKldsMa6ale79n9IYbTWt8AW7YuMuX4
	9I1g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=0Q87+kCImDXbkbU8saZjq2dHavTrD5t5U4+NGf8dn84=;
	b=bxeG+o2k6MIyYJR/taVln8Jzdxpd9YQnkSwj0EugCHFspjQ0JhcTRNPoysRLx2wMHC
	btVYcHY2UwLl8zldZPeKPH3a4e+W/V8OUKNTK9s74sjFqb8woAov+r+LfBmr2gHtZWJm
	pIebvS2TnSI/uvpABchZaQOPCM+sHezlybYfl38YBsK52CF7IOIETCe+49vFjo0P9tx8
	ONoupWzUdfGWhv3GlkG66Q4Vr/FJsJfyKRALG05mKDT5RPbURV8tC4U/f1gfrKmEhlrg
	ef2ePvr/dFsF+9RUSOQvOq9vOUiBkz7a4x+XMyXMrutAIGmQS6tGcbX2PwKZuIOr9tkh
	zkWw==
X-Gm-Message-State: AN3rC/7I9vJFy5ysrHX/JFjwG1mkniwHmCtmKaGfQnBMAHJ1dmi/MvPl
	bhcPEE1w3AFIxohDHT8fJBZ5OcKBVA==
X-Received: by 10.107.20.211 with SMTP id 202mr7721353iou.94.1493343262801;
	Thu, 27 Apr 2017 18:34:22 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.112.41 with HTTP; Thu, 27 Apr 2017 18:34:01 -0700 (PDT)
In-Reply-To: <4ebf3c91-29cc-8fce-3892-cba764dd157a@case.edu>
References: <CAOSMAutn8+f03ay8_DTAtcwjArMGqR0ZBkOigMVq3SXCyTrgyA@mail.gmail.com>
	<4ebf3c91-29cc-8fce-3892-cba764dd157a@case.edu>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Thu, 27 Apr 2017 20:34:01 -0500
Message-ID: <CAOSMAutBKsuhP8i3aghS_W76Lm9qpFF+SJxO3E93ACCKDbqWxw@mail.gmail.com>
Subject: Re: AddressSanitizer: heap-buffer-overflow lib/readline/bind.c:437 in
	rl_translate_keyseq
To: Chet Ramey <chet.ramey@case.edu>
Cc: "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::22a
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Fri, 28 Apr 2017 01:34:25 -0000

On Thu, Apr 27, 2017 at 2:35 PM, Chet Ramey <chet.ramey@case.edu> wrote:
[...]
> Thanks for the report.  This was an easy fix. You must be fuzzing
> readline's key sequence parser.

Yes. I'm currently trying a few approaches. I got this crash from:

afl-fuzz -i i1/ -o o1/ -- ./bash/bash --noprofile --norc -ic 'bind -f @@'

After compiling with CC=afl-gcc ...

With this seed:

# cat i1/1
"\e\C-e": shell-expand-line
"\C-x(": start-kbd-macro
"\e&": tilde-expand
"\C-t": transpose-chars
"\et": transpose-words
"\C-x\C-u": undo
"\C-_": undo
"\C-u": unix-line-discard
"\C-w": unix-word-rubout
"\eu": upcase-word
"\C-y": yank
"\e.": yank-last-arg
"\e_": yank-last-arg
"\e\C-y": yank-nth-arg
"\ey": yank-pop


From MAILER-DAEMON Fri Apr 28 06:55:26 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d43Yc-00067D-2o
	for mharc-bug-bash@gnu.org; Fri, 28 Apr 2017 06:55:26 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49965)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <svashish@redhat.com>) id 1d43YZ-000676-0t
	for bug-bash@gnu.org; Fri, 28 Apr 2017 06:55:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <svashish@redhat.com>) id 1d43YV-0006d0-5Z
	for bug-bash@gnu.org; Fri, 28 Apr 2017 06:55:23 -0400
Received: from mx1.redhat.com ([209.132.183.28]:36806)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <svashish@redhat.com>) id 1d43YU-0006cb-Vd
	for bug-bash@gnu.org; Fri, 28 Apr 2017 06:55:19 -0400
Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com
	[10.5.11.15])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id EEA9F7F4A7
	for <bug-bash@gnu.org>; Fri, 28 Apr 2017 10:55:16 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EEA9F7F4A7
Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com;
	dmarc=none (p=none dis=none) header.from=redhat.com
Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com;
	spf=pass smtp.mailfrom=svashish@redhat.com
DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EEA9F7F4A7
Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21])
	by smtp.corp.redhat.com (Postfix) with ESMTPS id E4EC78B74F
	for <bug-bash@gnu.org>; Fri, 28 Apr 2017 10:55:16 +0000 (UTC)
Received: from zmail23.collab.prod.int.phx2.redhat.com
	(zmail23.collab.prod.int.phx2.redhat.com [10.5.83.28])
	by colo-mx.corp.redhat.com (Postfix) with ESMTP id C29655EC60
	for <bug-bash@gnu.org>; Fri, 28 Apr 2017 10:55:16 +0000 (UTC)
Date: Fri, 28 Apr 2017 06:55:16 -0400 (EDT)
From: Siteshwar Vashisht <svashisht@redhat.com>
To: bug-bash@gnu.org
Message-ID: <1204424204.1788485.1493376916522.JavaMail.zimbra@redhat.com>
In-Reply-To: <1451101589.1786719.1493376105624.JavaMail.zimbra@redhat.com>
Subject: command builtin should disable different behavior for special
	built-ins
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Originating-IP: [10.34.4.148, 10.4.195.2]
Thread-Topic: command builtin should disable different behavior for special
	built-ins
Thread-Index: YE/LOw/AwPn9w893wZ/9rwYeyPQT3Q==
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.26]);
	Fri, 28 Apr 2017 10:55:17 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 209.132.183.28
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Fri, 28 Apr 2017 10:55:24 -0000

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I\
. -I./include -I./lib  -D_GNU_SOURCE -DRECYCLES_PIDS -DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin'  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -gre\
cord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wno-parentheses -Wno-format-security
uname output: Linux localhost.localdomain 4.11.0-0.rc8.git0.1.fc27.x86_64 #1 SMP Mon Apr 24 15:30:53 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-redhat-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: release

Description:
In POSIX mode, command builtin should disable different behavior for special built-ins.

According to description for special builtin-ins[1] in POSIX, a special builtin may cause shell to abort on error :
An error in a special built-in utility may cause a shell executing that utility to abort

However as per [2], command builtin should disable different behavior for special builtins :
If the command_name is the same as the name of one of the special built-in utilities, the special properties in the enumerated list at the beginning of Special Built-In Utilities shall not occur.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14
[2] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html

Repeat-By:
  sh -c 'readonly VAR=123; command eval "VAR=123"; echo $?'

Actual output:
  shell aborts at below error:
    sh: VAR: readonly variable

Expected output:
  'echo $?' should be executed :
    sh: VAR: readonly variable
    1

-- 
--
Siteshwar Vashisht


From MAILER-DAEMON Fri Apr 28 09:24:23 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d45sk-0005Ef-S4
	for mharc-bug-bash@gnu.org; Fri, 28 Apr 2017 09:24:22 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55921)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d45si-0005DV-KT
	for bug-bash@gnu.org; Fri, 28 Apr 2017 09:24:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d45se-0003VS-NT
	for bug-bash@gnu.org; Fri, 28 Apr 2017 09:24:20 -0400
Received: from mpv4-2015.cwru.edu ([129.22.103.195]:1809
	helo=mpv4-2015.case.edu)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <chet.ramey@case.edu>) id 1d45se-0003US-H8
	for bug-bash@gnu.org; Fri, 28 Apr 2017 09:24:16 -0400
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
	by mpv4-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id ALM60824; Fri, 28 Apr 2017 09:24:12 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id BDM76749 (AUTH cpr);
	Fri, 28 Apr 2017 09:24:11 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Subject: Re: command builtin should disable different behavior for special
	built-ins
References: <1204424204.1788485.1493376916522.JavaMail.zimbra@redhat.com>
To: Siteshwar Vashisht <svashisht@redhat.com>, bug-bash@gnu.org
Cc: chet.ramey@case.edu
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <5d109118-ab82-e39f-680f-ef5a0b69ac29@case.edu>
Date: Fri, 28 Apr 2017 09:24:10 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
	Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <1204424204.1788485.1493376916522.JavaMail.zimbra@redhat.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=7/60, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.4.28.123616:17:7.944, ip=,
	rules=__HAS_REPLYTO, __BOUNCE_CHALLENGE_SUBJ,
	__BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __REFERENCES,
	__TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC,
	__HAS_CC_HDR, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID,
	__SANE_MSGID, DATE_TZ_NA, __USER_AGENT,
	__MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT,
	__CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
	__REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC1,
	__FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN,
	__ANY_URI, __URI_WITH_PATH, __URI_NO_WWW,
	__CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY,
	__URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW,
	BODY_SIZE_600_699, BODYTEXTP_SIZE_3000_LESS,
	__MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01,
	HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD,
	__FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES,
	MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.195
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Fri, 28 Apr 2017 13:24:21 -0000

On 4/28/17 6:55 AM, Siteshwar Vashisht wrote:

> Bash Version: 4.4
> Patch Level: 12
> Release Status: release
> 
> Description:
> In POSIX mode, command builtin should disable different behavior for special built-ins.
> 
> According to description for special builtin-ins[1] in POSIX, a special builtin may cause shell to abort on error :
> An error in a special built-in utility may cause a shell executing that utility to abort

Thanks for the report. This was fixed back in early March.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Fri Apr 28 20:09:25 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d4Fwz-0002BE-0l
	for mharc-bug-bash@gnu.org; Fri, 28 Apr 2017 20:09:25 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38770)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d4Fww-0002B8-Nq
	for bug-bash@gnu.org; Fri, 28 Apr 2017 20:09:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d4Fwt-0004HW-Ia
	for bug-bash@gnu.org; Fri, 28 Apr 2017 20:09:22 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:40492
	helo=Ishtar.sc.tlinx.org)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <bash@tlinx.org>) id 1d4Fwt-0004Gi-57
	for bug-bash@gnu.org; Fri, 28 Apr 2017 20:09:19 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
	v3T09BSi040315
	for <bug-bash@gnu.org>; Fri, 28 Apr 2017 17:09:13 -0700
Message-ID: <5903D9A7.4050207@tlinx.org>
Date: Fri, 28 Apr 2017 17:09:11 -0700
From: L A Walsh <bash@tlinx.org>
User-Agent: Thunderbird
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: globstar question
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 29 Apr 2017 00:09:23 -0000


I wanted to search for a file that had 'Tokyo' in the basename,
in all directories below a given point.  I had been doing it 'find',
but thought globstar should work.
W/globstar set, I looked for:

ls **Tokyo*
(nothing)
ls ***Tokyo*
(nothing)
ls **Tokyo**Tokyo*
(nothing)
ls **/*Tokyo*
(found multiple matches (including the one I was
 searching for))

A sample file I was searching for:

Library/Tokyo Ravens/[gg]_Tokyo_Ravens_-_01_[398DE7BC].mkv

I.e. had Tokyo in _both_, dir and subfiles,
Why didn't any of the 1st 3 patterns find anything?

It seemed that I needed a '/' in the pattern for it
to be processed as a globstar pattern...??

Is that supposed to be a requirement for globstar
to function?  From this (from bash manpage):

  *      Matches any string, including the null string.  When  the
         globstar  shell  option  is  enabled,  and * is used in a
         pathname expansion context, two adjacent  *s  used  as  a
         single  pattern  will  match  all  files and zero or more
         directories and subdirectories.  If followed by a /,  two
         adjacent  *s  will match only directories and subdirecto-
         ries.

The slashes don't seem to be required.

Other glob settings:

dotglob         on
extglob         on
failglob        off
globasciiranges on
globstar        on
nocaseglob      on
nullglob        off

>  echo $BASH_VERSION
4.4.12(2)-release

Thanks,
-linda







From MAILER-DAEMON Fri Apr 28 22:03:02 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d4Hiw-00060l-5w
	for mharc-bug-bash@gnu.org; Fri, 28 Apr 2017 22:03:02 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50947)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d4Hit-0005xU-Q1
	for bug-bash@gnu.org; Fri, 28 Apr 2017 22:03:00 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d4Hiq-0008FX-M3
	for bug-bash@gnu.org; Fri, 28 Apr 2017 22:02:59 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:3037
	helo=mpv1-2015.case.edu) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1d4Hiq-0008FI-FP
	for bug-bash@gnu.org; Fri, 28 Apr 2017 22:02:56 -0400
Received: from mpv7-2015.CWRU.Edu (EHLO mpv7-2015.case.edu) ([129.22.103.242])
	by mpv1-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id AMR68970; Fri, 28 Apr 2017 22:02:52 -0400 (EDT)
Received: from h254.183.142.40.ip.windstream.net (EHLO _192.168.254.3_)
	([40.142.183.254])
	by mpv7-2015.case.edu (MOS 4.4.7-GA FastPath queued)
	with ESMTP id HCC53626 (AUTH cpr);
	Fri, 28 Apr 2017 22:02:52 -0400 (EDT)
Reply-To: chet.ramey@case.edu
Cc: chet.ramey@case.edu
Subject: Re: globstar question
To: L A Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>
References: <5903D9A7.4050207@tlinx.org>
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
Message-ID: <15cfc629-e1e9-4f5f-4908-75bb58f1da80@case.edu>
Date: Fri, 28 Apr 2017 22:02:50 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
	Gecko/20100101 Thunderbird/52.0.1
MIME-Version: 1.0
In-Reply-To: <5903D9A7.4050207@tlinx.org>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Junkmail-Status: score=8/60, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/60, refid=2.7.2:2017.4.29.10616:17:8.317, ip=,
	rules=__HAS_REPLYTO, __HAS_CC_HDR, LEO_OBFU_SUBJ_RE,
	__BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
	__SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME,
	__TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM,
	FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA,
	__USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION,
	__IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE,
	__REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC,
	__FROM_DOMAIN_IN_ANY_CC1, __FROM_DOMAIN_IN_ANY_CC2,
	__REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH,
	__URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE,
	__URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG,
	__NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS,
	BODY_SIZE_2000_2999, __MIME_TEXT_P1, __MIME_TEXT_ONLY,
	__URI_NS, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS,
	IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT,
	__TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, [TRUNCATED],
	so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-Received-From: 129.22.103.226
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 29 Apr 2017 02:03:01 -0000

On 4/28/17 8:09 PM, L A Walsh wrote:
> 
> I wanted to search for a file that had 'Tokyo' in the basename,
> in all directories below a given point.  I had been doing it 'find',
> but thought globstar should work.
> W/globstar set, I looked for:
> 
> ls **Tokyo*
> (nothing)
> ls ***Tokyo*
> (nothing)
> ls **Tokyo**Tokyo*
> (nothing)
> ls **/*Tokyo*
> (found multiple matches (including the one I was
> searching for))
> 
> A sample file I was searching for:
> 
> Library/Tokyo Ravens/[gg]_Tokyo_Ravens_-_01_[398DE7BC].mkv
> 
> I.e. had Tokyo in _both_, dir and subfiles,
> Why didn't any of the 1st 3 patterns find anything?

Because the first two search for files containing the string `Tokyo' in the
current directory and the third finds files containing `Tokyo' twice.

> It seemed that I needed a '/' in the pattern for it
> to be processed as a globstar pattern...??
> 
> Is that supposed to be a requirement for globstar
> to function?  From this (from bash manpage):

Yes.  This is what "used as a single pattern" means.  When used for
pathname expansion, patterns are individual strings of characters,
and slashes separate patterns.  So the `**Tokyo*' is a single pattern,
`***Tokyo*' is a single pattern, and so on, while `**/*Tokyo*' is two
patterns, one of which is `**'.  So `**' needs to appear as a pattern
by itself, either as the string `**' or as one of the patterns separated
by slashes, to get the behavior you want.

> 
>  *      Matches any string, including the null string.  When  the
>         globstar  shell  option  is  enabled,  and * is used in a
>         pathname expansion context, two adjacent  *s  used  as  a
>         single  pattern  will  match  all  files and zero or more
>         directories and subdirectories.  If followed by a /,  two
>         adjacent  *s  will match only directories and subdirecto-
>         ries.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sat Apr 29 19:47:10 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d4c50-0004wj-DQ
	for mharc-bug-bash@gnu.org; Sat, 29 Apr 2017 19:47:10 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:41039)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <adam.danischewski@gmail.com>) id 1d4c4y-0004wc-JE
	for bug-bash@gnu.org; Sat, 29 Apr 2017 19:47:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <adam.danischewski@gmail.com>) id 1d4c4x-0001f4-FN
	for bug-bash@gnu.org; Sat, 29 Apr 2017 19:47:08 -0400
Received: from mail-qt0-x235.google.com ([2607:f8b0:400d:c0d::235]:35858)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <adam.danischewski@gmail.com>)
	id 1d4c4x-0001eo-9k
	for bug-bash@gnu.org; Sat, 29 Apr 2017 19:47:07 -0400
Received: by mail-qt0-x235.google.com with SMTP id g60so72881273qtd.3
	for <bug-bash@gnu.org>; Sat, 29 Apr 2017 16:47:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:from:date:message-id:subject:to;
	bh=d5I908lOK9LjfMkXo/KqIMa4d+loGdQxcqhGbgy4UKE=;
	b=Yxv/+CEyMqbjdzPAt5/11FGR1xzXdFhH9c/lIuBdd8ssCqyjXC3HGyda74Rec73ciw
	M1kyOvXj6O7QDkuR1opb2i3djM7h2uqehfN00jUxqSlIRGPmGxZugqv0kAvO/x01wQX/
	p3mG1pSrT8hqNmvXH2tfhJVvWHbf1DgV72iYil3H/gyZDOBh6YkQL3EzRgwW7Dtjcbpd
	MrDTwjJ6Az1gg0jLyBEtJQjLuZtdaq5SGgnfrrMd3KcHJ8UyFJOsdOXii/wEP3HWgP1c
	/D5ENL//ISKwNJqEhmMAC8zsKkNiz1gT6rAjcHpLdYRHdT5xiiZdILNRLnufqoOrafkW
	rX9Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=d5I908lOK9LjfMkXo/KqIMa4d+loGdQxcqhGbgy4UKE=;
	b=foOddGVplBZjv+DCAJMB3HCGd0M05MwL5EnxZJWrUpgSHswFnGufFJTRUpfBCbtQ96
	JcK+US0Z8n2KtjYmDQ7hu7eHqfaD29/X+MzyPuf9IHJSgPSyuIPfT/7N7B/pmq/5v0r8
	atTwAUGROF1P1jeDe0vd5MADGWlEbOHhKk1+7FEqG65LIa0CNqtCa4oH6g33v+qpsIvb
	W7BWqGRfdXs9U+PnQYSKU+V7cKBaiDfP5+PWu7C6q3ISqXjBJLee0FQy6s/VDJ2C0Oh/
	usDYcDrcgx5+myuaCnxqv3k3JepNE4nt1FpH9P4PLfE+LUb9zh/+7NIix4KQYJWgafwy
	okjw==
X-Gm-Message-State: AN3rC/44tUWs9bEBj1jxKbxUED6c7iXlfk686kySgwkI479WaZrmTH88
	3GeUG4C/2WgBHDT/RTEj+g9pxQqKqg==
X-Received: by 10.200.52.180 with SMTP id w49mr15311188qtb.75.1493509626606;
	Sat, 29 Apr 2017 16:47:06 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.12.188.156 with HTTP; Sat, 29 Apr 2017 16:47:06 -0700 (PDT)
From: Adam Danischewski <adam.danischewski@gmail.com>
Date: Sat, 29 Apr 2017 19:47:06 -0400
Message-ID: <CAOQZJ0Edaf8PrA2G8q9NE9LAJVoG6pygOSgubTs4+wGYLN1S_Q@mail.gmail.com>
Subject: Bash -f Test Operator - Not working as expected
To: Chester Ramey <chet.ramey@case.edu>, bug-bash@gnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c0d::235
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.21
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sat, 29 Apr 2017 23:47:09 -0000

$ ls -al
/mnt/samsung32/.word_list_repo/instruments_song_repo/546725_pinstripe.mp3
lrwxrwxrwx 1 cronkilla cronkilla 74 Apr 29 19:30
/mnt/samsung32/.word_list_repo/instruments_song_repo/546725_pinstripe.mp3
->
/mnt/samsung32/.word_list_repo/master_song_repo/0/4/5/546725_pinstripe.mp3
$ [[ -L
"/mnt/samsung32/.word_list_repo/instruments_song_repo/546725_pinstripe.mp3"
]] && echo hi
hi
$ [[ ! -L
"/mnt/samsung32/.word_list_repo/instruments_song_repo/546725_pinstripe.mp3"
]] && echo hi
$ [[ -f
"/mnt/samsung32/.word_list_repo/instruments_song_repo/546725_pinstripe.mp3"
]] && echo hi
hi

It looks like the test operator "-f" is not functioning as described,
according to the documentation this should only return true on a REGULAR
file, not a symbolic link.

You can repeat the behavior by creating any symbolic link to a file or
directory and then using the test operator on the command line.

cd /tmp
touch test.txt
ln -s test.txt lnk2test
[[ -f lnk2test ]] && echo hi
[[ -L lnk2test ]] && echo hi
[[ ! -L lnk2test ]] && echo hi

The first test above -f should fail yet doesn't, the last negated symbolic
link test may be a workaround for finding a regular file unless you see
something wrong with that.

From MAILER-DAEMON Sat Apr 29 20:09:34 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d4cQg-0006Hn-4A
	for mharc-bug-bash@gnu.org; Sat, 29 Apr 2017 20:09:34 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42848)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d4cQd-0006Hg-Aw
	for bug-bash@gnu.org; Sat, 29 Apr 2017 20:09:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dualbus@gmail.com>) id 1d4cQa-0006ow-N6
	for bug-bash@gnu.org; Sat, 29 Apr 2017 20:09:31 -0400
Received: from mail-io0-x22e.google.com ([2607:f8b0:4001:c06::22e]:35079)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <dualbus@gmail.com>) id 1d4cQa-0006om-HA
	for bug-bash@gnu.org; Sat, 29 Apr 2017 20:09:28 -0400
Received: by mail-io0-x22e.google.com with SMTP id r16so89029344ioi.2
	for <bug-bash@gnu.org>; Sat, 29 Apr 2017 17:09:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=pbk0v5QI2dcmQasPeZI9Ty82K6E7UJGNJHvy7AU7EZc=;
	b=SiEto/HVtoIb5hUf4+KmarXKMCR86b6H37ZaauUNeDS3/CI1HeUsyCS0+NGPgGNQ+C
	v3fhdp16KYJ5R4TvW/fSGGrUZ7IwQLrWHoosqkLZ0dTM0IyQU8/33it/GI1KH8m1/Q95
	GR8JkCCDWDF1hXY5C51Zd4A/St3qHsAqwWK9ZryNmew2EgKxx+F6YtcuhjiD46VdVyXo
	Ug3SnHLusRjyC8TQa6COvRu0rgltLrAy34rFXrhZOT9+xGUlcA+XcFnrXyfQFm3LK8aG
	+P+OVFqepZ+GOpBR7kMgKagoBHGiP0Mrz8xYGAJ2+W1euaqOd0cyfhPwx3XcB/71elj0
	vSgw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=pbk0v5QI2dcmQasPeZI9Ty82K6E7UJGNJHvy7AU7EZc=;
	b=fz3jGfRzsQ8MzrAh/1RK5S2b6f8DcjWbnHSVEwxlKiLYD3YJLMmv3LaJqAnIRzuhkr
	aKLUHCFSY8SlVzjTkmJXrcn0u6EQdIybgBrfEPV8kyyj6TqRkglT5fo7aamUGtxZW6IQ
	P/i+eGtllaVqfJk8ZpsQlSbunaJefLAA0HY+Xg/c95hZzNfe6wUaM1kDMXNDivAPbIgE
	rocOdlj3xf2FVxRfNrg7arIKxy5kYmbd/C30bYlrMj2CD2NyhxFwTxhmdbV97c23f9u/
	iBicZ9GXRyTQiih0Ly4OMk30SGX02R3D0SItw/vo/3k8qFdZWdHAX8gsieWYm+P4g/oa
	WEiA==
X-Gm-Message-State: AN3rC/68Hrz8ahElKSo1SwLGRoNOdYsnWH2Qj75PpQPiGgj1eGcmHZOD
	BNSLc4Uju/qbe7HNhPpX3JEvG8f5SA==
X-Received: by 10.107.140.197 with SMTP id o188mr16190265iod.180.1493510967792;
	Sat, 29 Apr 2017 17:09:27 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.158.195 with HTTP; Sat, 29 Apr 2017 17:09:07 -0700 (PDT)
In-Reply-To: <CAOQZJ0Edaf8PrA2G8q9NE9LAJVoG6pygOSgubTs4+wGYLN1S_Q@mail.gmail.com>
References: <CAOQZJ0Edaf8PrA2G8q9NE9LAJVoG6pygOSgubTs4+wGYLN1S_Q@mail.gmail.com>
From: Eduardo Bustamante <dualbus@gmail.com>
Date: Sat, 29 Apr 2017 19:09:07 -0500
Message-ID: <CAOSMAusFAgvUj3VaM+5q1jw-yOOmhyFf7Ab3etTc5otACJxYzw@mail.gmail.com>
Subject: Re: Bash -f Test Operator - Not working as expected
To: Adam Danischewski <adam.danischewski@gmail.com>
Cc: Chester Ramey <chet.ramey@case.edu>, "bug-bash@gnu.org" <bug-bash@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4001:c06::22e
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 30 Apr 2017 00:09:32 -0000

This is not a bug, and it has come up before.

Please read: https://lists.gnu.org/archive/html/bug-bash/2013-06/msg00110.html
and https://lists.gnu.org/archive/html/bug-bash/2015-02/msg00029.html


From MAILER-DAEMON Sat Apr 29 23:22:53 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d4fRk-0002bJ-U4
	for mharc-bug-bash@gnu.org; Sat, 29 Apr 2017 23:22:52 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60191)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d4fRi-0002bB-U4
	for bug-bash@gnu.org; Sat, 29 Apr 2017 23:22:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1d4fRf-00087r-SR
	for bug-bash@gnu.org; Sat, 29 Apr 2017 23:22:51 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:38768
	helo=Ishtar.sc.tlinx.org)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <bash@tlinx.org>) id 1d4fRf-00087H-G8
	for bug-bash@gnu.org; Sat, 29 Apr 2017 23:22:47 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
	v3U3MaRt027774; Sat, 29 Apr 2017 20:22:38 -0700
Message-ID: <5905587C.8060901@tlinx.org>
Date: Sat, 29 Apr 2017 20:22:36 -0700
From: L A Walsh <bash@tlinx.org>
User-Agent: Thunderbird
MIME-Version: 1.0
To: chet.ramey@case.edu
CC: bug-bash <bug-bash@gnu.org>
Subject: Re: globstar question
References: <5903D9A7.4050207@tlinx.org>
	<15cfc629-e1e9-4f5f-4908-75bb58f1da80@case.edu>
In-Reply-To: <15cfc629-e1e9-4f5f-4908-75bb58f1da80@case.edu>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 30 Apr 2017 03:22:52 -0000



Chet Ramey wrote:
> On 4/28/17 8:09 PM, L A Walsh wrote:
>> ls **Tokyo*
>> (nothing)
>> ls ***Tokyo*
>> (nothing)
>> ls **Tokyo**Tokyo*
>> (nothing)
>> ls **/*Tokyo*
>> (found multiple matches (including the one I was
>> searching for))
>>     
>
> Because the first two search for files containing the string `Tokyo' in the
> current directory and the third finds files containing `Tokyo' twice.
>   
----
    So '**' is only special when it's a token by itself?

   



From MAILER-DAEMON Sun Apr 30 11:32:31 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d4qpr-0005iC-1W
	for mharc-bug-bash@gnu.org; Sun, 30 Apr 2017 11:32:31 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48649)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <omasmotorrad@gmail.com>) id 1d4qgv-0004C1-H9
	for bug-bash@gnu.org; Sun, 30 Apr 2017 11:23:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <omasmotorrad@gmail.com>) id 1d4qgr-0006tt-17
	for bug-bash@gnu.org; Sun, 30 Apr 2017 11:23:17 -0400
Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:34790)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <omasmotorrad@gmail.com>)
	id 1d4qgq-0006tL-PS
	for bug-bash@gnu.org; Sun, 30 Apr 2017 11:23:12 -0400
Received: by mail-wr0-x242.google.com with SMTP id 6so11840627wrb.1
	for <bug-bash@gnu.org>; Sun, 30 Apr 2017 08:23:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=from:content-transfer-encoding:subject:message-id:date:to
	:mime-version; bh=LypQR3yAGNWU2pN6Kbyw1GWtg7RCNMkEI4kFVHv8tFw=;
	b=s64JIRkBr2MZtbqybYJRFLr8fUPVFsK04uFYTNH1qALcS4jNRSH+hDS4BsZk9eVzvl
	HkmuJfgzn3w/pnhpYGoQUTmfm2dItHdeldEp7HIV4jINn4r0hZm0OXFve4aJeaZmgTeP
	xIN9PVkS4x5/4O7Y4tm04ilNcZUxrJTm159tuq5I15Yp2f9+oMGKoiUazE02usExn0c/
	3PrG3OIIZc5YB1Ii3+otWsLi+kK5UHYRouF2kOGDpXp1JP04LpOcBDkZqZsrUK8iIP4B
	E+VxU7BG7fka/gv+cf+bCHY/Ao3Dft7j52GC9RekpE17/hXvPvy4QPp6jXNUft7nBjzR
	c9Mg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:from:content-transfer-encoding:subject
	:message-id:date:to:mime-version;
	bh=LypQR3yAGNWU2pN6Kbyw1GWtg7RCNMkEI4kFVHv8tFw=;
	b=lBCFdbXwkS5MdLE5iGGVzyZcD8d2QAvrIKrS0ALLKwTUbxl7GkxAetTgpBWN5hrheE
	gEwAt9cAcN9q/5xlGfkj8kDdL+EdSNBKW5ARdMaalCrW5IoOCI8kbqg984D952FeDEcb
	HV/OvCf8gU2DJikA4Kn64tySkGGWzFEaKVzL6UEepopQUFMLDRzir6PBjbN/Eo3WjMGA
	OzkhRTFXLyOEgbMJd8CtIFx4K3nHn8wXA+yf/LaA7O9h+KOckl6BCShgBY0nea5NOoBM
	hBi7iXW5AGnq9XpxCrj2Z6uwrHHtYeq38NqCDk5xgYOI5wwhg6pDawDRqDl1WA4hwRal
	6oGw==
X-Gm-Message-State: AN3rC/4HahHKRUZmNkyhRhvx9lVkwnUGx0q5lE3QZjlbAoaJeU/Jgex+
	8Q6Ha0dtX0h7aBu+JAk=
X-Received: by 10.223.135.42 with SMTP id a39mr12508257wra.113.1493565791107; 
	Sun, 30 Apr 2017 08:23:11 -0700 (PDT)
Received: from florians-mbp.fritz.box
	(ipb21b615c.dynamic.kabel-deutschland.de. [178.27.97.92])
	by smtp.gmail.com with ESMTPSA id
	z90sm16922779wrc.36.2017.04.30.08.23.09 for <bug-bash@gnu.org>
	(version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
	Sun, 30 Apr 2017 08:23:10 -0700 (PDT)
From: omasmotorrad <omasmotorrad@gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Subject: [suggestion] Brace expansion configurability
Message-Id: <6D2F395E-3172-451F-A96B-DA1C701A4336@gmail.com>
Date: Sun, 30 Apr 2017 17:23:08 +0200
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\))
X-Mailer: Apple Mail (2.3124)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2a00:1450:400c:c0c::242
X-Mailman-Approved-At: Sun, 30 Apr 2017 11:32:29 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 30 Apr 2017 15:23:18 -0000

Why is it that one cannot change the delimiter for the
words generated during brace expansion?

On stackexchange, there too are questions
regarding this. Personally I=E2=80=99d like to be able to write
$ IFS=3D=E2=80=9E,=E2=80=9C echo a{b,c,d}
rather than
$ echo a{b,c,d} | tr =E2=80=9E =E2=80=9E =E2=80=9E,=E2=80=9C

In this example both lines are equally long but
considerably slower. At $work I=E2=80=99m forced to use windows.
For that reason, my Linux machine runs inside a VM which apparently =
makes
context switching much slower compared to my natively running
bash at $home.

Is there a possibility to change the delimiter that brace expansion
uses to separate the generated words?
If not: My suggestion:
1) Brace expansion could always take the first byte of IFS. This would =
not
break previous behavior, because IFS is already set so that it contains =
space as its first character.
For the case, that this indeed would break things. We could
2) Introduce another bash special Variable. For instance BASH_BDEL or =
BFS (Brace Field Separator)=E2=80=A6.
The line
$ IFS=3D=E2=80=9E,=E2=80=9C echo a{b,c,d}
would change appropriately

Another advantage will be, that we=E2=80=99d be able to replicate =
strings very efficiently using only
builtin resources. Even the very minimalistic standard library of lua =
has string.rep
lua $ print(string.rep(=E2=80=9Efoo=E2=80=9C, 3)) =3D> foofoofoo
could be translated to
$ BFS=3D=E2=80=9E=E2=80=9C echo {,,}foo

What do you think?

If (1) is possible, what parts of bash would I have to touch to do a =
quick and dirty hack
for the time being?

For reference:
=
https://unix.stackexchange.com/questions/121653/how-to-output-comma-separa=
ted-strings-using-bash-brace-expansion
=
http://stackoverflow.com/questions/30891856/change-separator-delim-in-bash=
-brace-expansion=


From MAILER-DAEMON Sun Apr 30 14:31:44 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1d4tdI-0001AD-6y
	for mharc-bug-bash@gnu.org; Sun, 30 Apr 2017 14:31:44 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48135)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d4tdF-00017w-EH
	for bug-bash@gnu.org; Sun, 30 Apr 2017 14:31:42 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mayerflorian@me.com>) id 1d4tdC-00073F-CG
	for bug-bash@gnu.org; Sun, 30 Apr 2017 14:31:41 -0400
Received: from pv35p18im-ztdg05101101.me.com ([17.133.188.44]:62214)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <mayerflorian@me.com>) id 1d4tdC-00072j-4l
	for bug-bash@gnu.org; Sun, 30 Apr 2017 14:31:38 -0400
Received: from process-dkim-sign-daemon.pv35p18im-ztdg05101101.me.com by
	pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016)) id <0OP800H00J4TW800@pv35p18im-ztdg05101101.me.com> for
	bug-bash@gnu.org; Sun, 30 Apr 2017 18:31:34 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a;
	t=1493577094; bh=8LfHtDl7XrkbAu0tLvOCFYZ24Vtclvx8mY3wPaaKZWg=;
	h=From:Content-type:Subject:Message-id:Date:To:MIME-version;
	b=UaFThmKSkFLvwcA24hh0fDWXVUEE8sAjTesXouS3BdUUcJK7RZD74GD1B4tb2eHgH
	dZpuzw9tIed0Fpogb40EuprlLLVZG59THTC4SQu+nyKoJbjZxIrvYrYVKMLxqrUMkZ
	xBAWQAST7DLYYdbsbJk7uGc5QdiJYbR6cCbQOZAmqwmvt3PYfhIgjuzknjo1pm772P
	xZXgAetATHG85Hk4FjH0bx+AO9HiIen/cUrPZ06+yh2OcT1xKy2ZsE36ctx0kG55l9
	ThKdSIgODt300zzQvq+g7oaGfEIqmlFHXPGsFh3w3u4KfTf0rEdeDs6W7RJxWPEn86
	E7koXdA0ljabw==
Received: from icloud.com ([127.0.0.1]) by pv35p18im-ztdg05101101.me.com
	(Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26
	2016))
	with ESMTPSA id <0OP800I78JGJE050@pv35p18im-ztdg05101101.me.com> for
	bug-bash@gnu.org; Sun, 30 Apr 2017 18:31:34 +0000 (GMT)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
	definitions=2017-04-30_13:,, signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	clxscore=1034 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0
	bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
	engine=8.0.1-1701120000 definitions=main-1704300148
From: Florian Mayer <mayerflorian@me.com>
Content-type: text/plain; charset=utf-8
Content-transfer-encoding: quoted-printable
Subject: Space removal in AE takes place before brace expansion
Message-id: <A8E4CEBF-6B37-48D8-B53E-C28990944C6C@me.com>
Date: Sun, 30 Apr 2017 20:31:30 +0200
To: "bug-bash@gnu.org" <bug-bash@gnu.org>
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
X-Mailer: Apple Mail (2.3124)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 17.133.188.44
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.21
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: <http://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-List-Received-Date: Sun, 30 Apr 2017 18:31:42 -0000

I want to add up all numbers from 1 to 10, but when I do=20
$ echo $(({1,10}=E2=80=99+=E2=80=99 +0)) # with a space between the =
first + and the second one
I get an error:
bash: ((: 1+ ,3 10+ ,3: syntax error: operand expected (error token is =
",3 10+ ,3=E2=80=9C)

It seems as if brace expansion gets executed first (as expected) but =
with
all the spaces removed that had existed before inside the (( )) =
parentheses pair.
The line
$ (( {1, 10}'+' ,3)) # (space between 1 and 10)
also gives the same error and thus shows that spaces are removed before
brace expansion takes place. Why is that?

I=E2=80=99d consider this a bug, because brace expansion is expected to =
execute first
and with regards to semantics, spaces are significant...

$ eval echo \$\(\( {1..10}'+' 0\)\)
does the trick, though=E2=80=A6=


