From MAILER-DAEMON Sun Apr 01 04:52:40 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEGWe-0000fh-Ub
	for mharc-bug-bash@gnu.org; Sun, 01 Apr 2012 04:52:40 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52570)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEGWb-0000ek-TZ
	for bug-bash@gnu.org; Sun, 01 Apr 2012 04:52:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEGWa-00061L-96
	for bug-bash@gnu.org; Sun, 01 Apr 2012 04:52:37 -0400
Received: from mho-02-ewr.mailhop.org ([204.13.248.72]:28400)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEGWa-00061D-5u
	for bug-bash@gnu.org; Sun, 01 Apr 2012 04:52:36 -0400
Received: from 4.41.21.95.dynamic.jazztel.es ([95.21.41.4]
	helo=mail.viric.name)
	by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.72) (envelope-from <viric@viric.name>)
	id 1SEGWX-000FN2-1a; Sun, 01 Apr 2012 08:52:33 +0000
Received: by mail.viric.name (Postfix, from userid 1000)
	id 59C7C55C3FA; Sun,  1 Apr 2012 10:52:30 +0200 (CEST)
X-Mail-Handler: MailHop Outbound by DynDNS
X-Originating-IP: 95.21.41.4
X-Report-Abuse-To: abuse@dyndns.com (see
	http://www.dyndns.com/services/mailhop/outbound_abuse.html for
	abuse reporting information)
X-MHO-User: U2FsdGVkX18+Ps33GuF7rWCqG21QidSc
Date: Sun, 1 Apr 2012 10:52:30 +0200
From: =?iso-8859-1?Q?Llu=EDs?= Batlle i Rossell <viric@viric.name>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Strange behaviour on 'read' from a pipe
Message-ID: <20120401085230.GP3029@vicerveza.homeunix.net>
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
In-Reply-To: <4F77AC64.2010602@case.edu>
X-Accept-Language: ca, es, eo, ru, en, jbo, tokipona
User-Agent: Mutt/1.5.20 (2009-06-14)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 204.13.248.72
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 01 Apr 2012 08:52:39 -0000

On Sat, Mar 31, 2012 at 09:16:20PM -0400, Chet Ramey wrote:
> On 3/31/12 9:19 AM, Llu=EDs Batlle i Rossell wrote:
> > Hello,
> >=20
> > I have this script, that I've found to never write "DONE" in my syste=
ms, with
> > bash 4.0, 4.1, 4.2.. until 4.2-p20, my last test.
> >=20
> > However, in irc some people told me it prints DONE for them. If I run=
 the script with
> > bash under 'strace -f', it also prints DONE.
>=20
> It looks like a simple race condition.  I suspect that the scheduler
> arranges things so that the child process ends up exiting between the
> open and the read, but I don't have any real evidence to back it up.
> (Like you, my Mac OS X system prints `DONE'.)
>=20
> You might want to try using exec to open the FIFO in the parent process
> rather than trying to open it on each read.

Yes, I know I can work around it, but I meant that the race of the parent
getting SIGCHLD in the read call did not bring any useful outcome.

For me, useful outcomes could be:
- read nothing, and unblock with error
- keep on reading the same fd

But it does not do any of those.

Thank you,
Llu=EDs.


From MAILER-DAEMON Sun Apr 01 05:53:24 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEHTQ-0000zw-OV
	for mharc-bug-bash@gnu.org; Sun, 01 Apr 2012 05:53:24 -0400
Received: from eggs.gnu.org ([208.118.235.92]:38657)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SEHTO-0000zn-7r
	for bug-bash@gnu.org; Sun, 01 Apr 2012 05:53:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SEHTM-0002e9-Du
	for bug-bash@gnu.org; Sun, 01 Apr 2012 05:53:21 -0400
Received: from mail-out.m-online.net ([212.18.0.10]:45880)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SEHTM-0002dx-7H
	for bug-bash@gnu.org; Sun, 01 Apr 2012 05:53:20 -0400
Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net
	[192.168.8.180])
	by mail-out.m-online.net (Postfix) with ESMTP id 3VLBhV4sxZz3hhXK;
	Sun,  1 Apr 2012 11:53:14 +0200 (CEST)
Received: from igel.home (ppp-88-217-123-48.dynamic.mnet-online.de
	[88.217.123.48])
	by mail.mnet-online.de (Postfix) with ESMTPA id 3VLBhV5QNlz4KK6W;
	Sun,  1 Apr 2012 11:53:14 +0200 (CEST)
Received: by igel.home (Postfix, from userid 501)
	id 2EE12CA29F; Sun,  1 Apr 2012 11:53:13 +0200 (CEST)
From: Andreas Schwab <schwab@linux-m68k.org>
To: chet.ramey@case.edu
Subject: Re: Strange behaviour on 'read' from a pipe
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu>
X-Yow: Here is my refrigerator full of FLANK STEAK...and over there is my
	UPHOLSTERED CANOE...I don't know WHY I OWN them!!
Date: Sun, 01 Apr 2012 11:53:12 +0200
In-Reply-To: <4F77AC64.2010602@case.edu> (Chet Ramey's message of "Sat, 31 Mar
	2012 21:16:20 -0400")
Message-ID: <m2mx6vrd6f.fsf@igel.home>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux)
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.6, seldom 2.4 (older,
	4)
X-Received-From: 212.18.0.10
Cc: =?utf-8?Q?Llu=C3=ADs?= Batlle i Rossell <viric@viric.name>,
	bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 01 Apr 2012 09:53:23 -0000

Chet Ramey <chet.ramey@case.edu> writes:

> On 3/31/12 9:19 AM, Llu=C3=ADs Batlle i Rossell wrote:
>> Hello,
>>=20
>> I have this script, that I've found to never write "DONE" in my system=
s, with
>> bash 4.0, 4.1, 4.2.. until 4.2-p20, my last test.
>>=20
>> However, in irc some people told me it prints DONE for them. If I run =
the script with
>> bash under 'strace -f', it also prints DONE.
>
> It looks like a simple race condition.  I suspect that the scheduler
> arranges things so that the child process ends up exiting between the
> open and the read, but I don't have any real evidence to back it up.

Note that the opening of the pipe as part of the redirection in the
parent blocks until there is a writer, ie. until the child opens the
pipe.  Can this open call return EINTR?

Andreas.

--=20
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint =3D 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED=
5
"And now for something completely different."


From MAILER-DAEMON Sun Apr 01 05:58:28 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEHYK-0001o7-Ew
	for mharc-bug-bash@gnu.org; Sun, 01 Apr 2012 05:58:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51052)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEHYI-0001nx-B1
	for bug-bash@gnu.org; Sun, 01 Apr 2012 05:58:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEHYG-0003qf-KB
	for bug-bash@gnu.org; Sun, 01 Apr 2012 05:58:25 -0400
Received: from mho-02-ewr.mailhop.org ([204.13.248.72]:10509)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEHYG-0003qZ-GX
	for bug-bash@gnu.org; Sun, 01 Apr 2012 05:58:24 -0400
Received: from 4.41.21.95.dynamic.jazztel.es ([95.21.41.4]
	helo=mail.viric.name)
	by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.72) (envelope-from <viric@viric.name>)
	id 1SEHYD-000DtZ-6a; Sun, 01 Apr 2012 09:58:21 +0000
Received: by mail.viric.name (Postfix, from userid 1000)
	id 7CA8055C3FE; Sun,  1 Apr 2012 11:58:16 +0200 (CEST)
X-Mail-Handler: MailHop Outbound by DynDNS
X-Originating-IP: 95.21.41.4
X-Report-Abuse-To: abuse@dyndns.com (see
	http://www.dyndns.com/services/mailhop/outbound_abuse.html for
	abuse reporting information)
X-MHO-User: U2FsdGVkX18F7AaFeMbiXx+xhabdaKVq
Date: Sun, 1 Apr 2012 11:58:16 +0200
From: =?iso-8859-1?Q?Llu=EDs?= Batlle i Rossell <viric@viric.name>
To: Andreas Schwab <schwab@linux-m68k.org>
Subject: Re: Strange behaviour on 'read' from a pipe
Message-ID: <20120401095816.GS3029@vicerveza.homeunix.net>
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu> <m2mx6vrd6f.fsf@igel.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
In-Reply-To: <m2mx6vrd6f.fsf@igel.home>
X-Accept-Language: ca, es, eo, ru, en, jbo, tokipona
User-Agent: Mutt/1.5.20 (2009-06-14)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 204.13.248.72
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 01 Apr 2012 09:58:27 -0000

On Sun, Apr 01, 2012 at 11:53:12AM +0200, Andreas Schwab wrote:
> Chet Ramey <chet.ramey@case.edu> writes:
>=20
> > On 3/31/12 9:19 AM, Llu=EDs Batlle i Rossell wrote:
> >> Hello,
> >>=20
> >> I have this script, that I've found to never write "DONE" in my syst=
ems, with
> >> bash 4.0, 4.1, 4.2.. until 4.2-p20, my last test.
> >>=20
> >> However, in irc some people told me it prints DONE for them. If I ru=
n the script with
> >> bash under 'strace -f', it also prints DONE.
> >
> > It looks like a simple race condition.  I suspect that the scheduler
> > arranges things so that the child process ends up exiting between the
> > open and the read, but I don't have any real evidence to back it up.
>=20
> Note that the opening of the pipe as part of the redirection in the
> parent blocks until there is a writer, ie. until the child opens the
> pipe.  Can this open call return EINTR?

Ah, maybe this is the source trouble. EINTR in open, instead of read.

But in this case, even a C program could not be protected against this ra=
ce
other than blocking signals before opening the descriptor.

Maybe someone else knows better.


From MAILER-DAEMON Sun Apr 01 11:06:43 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEMMd-0004qZ-GB
	for mharc-bug-bash@gnu.org; Sun, 01 Apr 2012 11:06:43 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47111)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SEMMb-0004qT-MX
	for bug-bash@gnu.org; Sun, 01 Apr 2012 11:06:42 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SEMMZ-0002fe-OS
	for bug-bash@gnu.org; Sun, 01 Apr 2012 11:06:41 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:35899)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SEMMZ-0002fa-K6
	for bug-bash@gnu.org; Sun, 01 Apr 2012 11:06:39 -0400
Received: from mpv7.tis.CWRU.Edu (EHLO mpv7.case.edu) ([129.22.104.170])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXF93824; Sun, 01 Apr 2012 11:06:37 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TAZ50005 (AUTH cpr);
	Sun, 01 Apr 2012 11:06:22 -0400 (EDT)
Message-ID: <4F786EEE.5050101@case.edu>
Date: Sun, 01 Apr 2012 11:06:22 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Andreas Schwab <schwab@linux-m68k.org>
Subject: Re: Strange behaviour on 'read' from a pipe
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu> <m2mx6vrd6f.fsf@igel.home>
In-Reply-To: <m2mx6vrd6f.fsf@igel.home>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: =?ISO-8859-1?Q?Llu=EDs_Batlle_i_Rossell?= <viric@viric.name>,
	bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 01 Apr 2012 15:06:43 -0000

On 4/1/12 5:53 AM, Andreas Schwab wrote:

>> It looks like a simple race condition.  I suspect that the scheduler
>> arranges things so that the child process ends up exiting between the
>> open and the read, but I don't have any real evidence to back it up.
> 
> Note that the opening of the pipe as part of the redirection in the
> parent blocks until there is a writer, ie. until the child opens the
> pipe.  Can this open call return EINTR?

open() is supposed to return EINTR only if interrupted by a signal.  The
only signal I can see occurring is SIGCHLD, and bash installs the SIGCHLD
handler with SA_RESTART.

Chet

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


From MAILER-DAEMON Sun Apr 01 13:02:47 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEOAx-0006QJ-ER
	for mharc-bug-bash@gnu.org; Sun, 01 Apr 2012 13:02:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53005)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEOAu-0006QD-SE
	for bug-bash@gnu.org; Sun, 01 Apr 2012 13:02:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEOAs-0003wA-OC
	for bug-bash@gnu.org; Sun, 01 Apr 2012 13:02:44 -0400
Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:46751)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEOAs-0003vu-Ky
	for bug-bash@gnu.org; Sun, 01 Apr 2012 13:02:42 -0400
Received: from 4.41.21.95.dynamic.jazztel.es ([95.21.41.4]
	helo=mail.viric.name)
	by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.72) (envelope-from <viric@viric.name>)
	id 1SEOAp-000P7z-1O; Sun, 01 Apr 2012 17:02:39 +0000
Received: by mail.viric.name (Postfix, from userid 1000)
	id 9973855C40A; Sun,  1 Apr 2012 19:02:35 +0200 (CEST)
X-Mail-Handler: MailHop Outbound by DynDNS
X-Originating-IP: 95.21.41.4
X-Report-Abuse-To: abuse@dyndns.com (see
	http://www.dyndns.com/services/mailhop/outbound_abuse.html for
	abuse reporting information)
X-MHO-User: U2FsdGVkX1/ZfGIN38RQ/vhFWtNexD8S
Date: Sun, 1 Apr 2012 19:02:35 +0200
From: =?iso-8859-1?Q?Llu=EDs?= Batlle i Rossell <viric@viric.name>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Strange behaviour on 'read' from a pipe
Message-ID: <20120401170235.GU3029@vicerveza.homeunix.net>
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu> <m2mx6vrd6f.fsf@igel.home>
	<4F786EEE.5050101@case.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F786EEE.5050101@case.edu>
X-Accept-Language: ca, es, eo, ru, en, jbo, tokipona
User-Agent: Mutt/1.5.20 (2009-06-14)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 204.13.248.71
Cc: Andreas Schwab <schwab@linux-m68k.org>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 01 Apr 2012 17:02:46 -0000

On Sun, Apr 01, 2012 at 11:06:22AM -0400, Chet Ramey wrote:
> On 4/1/12 5:53 AM, Andreas Schwab wrote:
> 
> >> It looks like a simple race condition.  I suspect that the scheduler
> >> arranges things so that the child process ends up exiting between the
> >> open and the read, but I don't have any real evidence to back it up.
> > 
> > Note that the opening of the pipe as part of the redirection in the
> > parent blocks until there is a writer, ie. until the child opens the
> > pipe.  Can this open call return EINTR?
> 
> open() is supposed to return EINTR only if interrupted by a signal.  The
> only signal I can see occurring is SIGCHLD, and bash installs the SIGCHLD
> handler with SA_RESTART.

Then, any idea of what can be happening?


From MAILER-DAEMON Sun Apr 01 18:28:18 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SETFy-0005o2-Ue
	for mharc-bug-bash@gnu.org; Sun, 01 Apr 2012 18:28:18 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41256)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SETFw-0005nv-7f
	for bug-bash@gnu.org; Sun, 01 Apr 2012 18:28:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SETFu-0006Bz-7c
	for bug-bash@gnu.org; Sun, 01 Apr 2012 18:28:15 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:65368)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SETFu-0006Bo-30
	for bug-bash@gnu.org; Sun, 01 Apr 2012 18:28:14 -0400
Received: from mpv7.tis.CWRU.Edu (EHLO mpv7.case.edu) ([129.22.104.170])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXG12122; Sun, 01 Apr 2012 18:28:11 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TBI11188 (AUTH cpr);
	Sun, 01 Apr 2012 18:27:57 -0400 (EDT)
Message-ID: <4F78D662.30506@case.edu>
Date: Sun, 01 Apr 2012 18:27:46 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: =?ISO-8859-1?Q?Llu=EDs_Batlle_i_Rossell?= <viric@viric.name>
Subject: Re: Strange behaviour on 'read' from a pipe
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu> <m2mx6vrd6f.fsf@igel.home>
	<4F786EEE.5050101@case.edu>
	<20120401170235.GU3029@vicerveza.homeunix.net>
In-Reply-To: <20120401170235.GU3029@vicerveza.homeunix.net>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: Andreas Schwab <schwab@linux-m68k.org>, bug-bash@gnu.org,
	Chet Ramey <chet.ramey@case.edu>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 01 Apr 2012 22:28:17 -0000

On 4/1/12 1:02 PM, Lluís Batlle i Rossell wrote:
> On Sun, Apr 01, 2012 at 11:06:22AM -0400, Chet Ramey wrote:
>> On 4/1/12 5:53 AM, Andreas Schwab wrote:
>>
>>>> It looks like a simple race condition.  I suspect that the scheduler
>>>> arranges things so that the child process ends up exiting between the
>>>> open and the read, but I don't have any real evidence to back it up.
>>>
>>> Note that the opening of the pipe as part of the redirection in the
>>> parent blocks until there is a writer, ie. until the child opens the
>>> pipe.  Can this open call return EINTR?
>>
>> open() is supposed to return EINTR only if interrupted by a signal.  The
>> only signal I can see occurring is SIGCHLD, and bash installs the SIGCHLD
>> handler with SA_RESTART.
> 
> Then, any idea of what can be happening?

It looks like a race condition, like I said.  I can't reproduce it on my
system, so I don't have anything to troubleshoot.


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


From MAILER-DAEMON Mon Apr 02 04:24:47 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEcZD-0000tX-Pp
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 04:24:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55322)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <joao.m.santos.silva@gmail.com>) id 1SEPG3-00084s-4g
	for bug-bash@gnu.org; Sun, 01 Apr 2012 14:12:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <joao.m.santos.silva@gmail.com>) id 1SEPG1-0001Qh-KD
	for bug-bash@gnu.org; Sun, 01 Apr 2012 14:12:06 -0400
Received: from mail-qa0-f41.google.com ([209.85.216.41]:47027)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <joao.m.santos.silva@gmail.com>) id 1SEPG1-0001Pa-Cx
	for bug-bash@gnu.org; Sun, 01 Apr 2012 14:12:05 -0400
Received: by qafl39 with SMTP id l39so1721770qaf.14
	for <bug-bash@gnu.org>; Sun, 01 Apr 2012 11:11:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:date:message-id:subject:from:to:content-type
	:content-transfer-encoding;
	bh=15yKWs3kb0Fnw0CqmXEIAXQQWfwob6Ja1h3OiyidxxM=;
	b=wPn9+4xPhjBB3GXo1Kv1D2C1kwhBD0i500VRLkGEPgJTnXAwbrB8Syh66ljZLvxy7l
	5oWzsEthNs+dRtKCMIUY15+Pr8hIOvisJBWcM72Vp4qYLx+B5S43KqGaJrKS30PLPBOP
	GCsXl47wf4pS/k1Kb5ojZvvORE8rQuQAbaaS/73M/8Qc5KmHBgZtoVh/0qAPLeZpYdnX
	Wwwt6xLe11C7kEG4A1txXYEsTW1tYxXES066SYSNOfsj2FnjZ+uBnt7nk6r1V5LXYiFu
	0q5jxSS+Zkyr2F1fO9LuImBM17k44+LkXgB+yBcOYAMVCCPDYJ8NW9wAQM3sF1NerrAb
	opwQ==
MIME-Version: 1.0
Received: by 10.229.75.143 with SMTP id y15mr2252584qcj.2.1333303915486; Sun,
	01 Apr 2012 11:11:55 -0700 (PDT)
Received: by 10.229.248.70 with HTTP; Sun, 1 Apr 2012 11:11:55 -0700 (PDT)
Date: Sun, 1 Apr 2012 19:11:55 +0100
Message-ID: <CAAv-bCwcJzH9LqraEypxr33oP74pzuzDbhv1yfU00MS=VPXMyw@mail.gmail.com>
Subject: bash completion issue
From: =?ISO-8859-1?Q?Jo=E3o_M=2E_S=2E_Silva?= <joao.m.santos.silva@gmail.com>
To: bug-bash@gnu.org
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.216.41
X-Mailman-Approved-At: Mon, 02 Apr 2012 04:24:45 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 01 Apr 2012 18:12:08 -0000

Hi,

I don't know if this is a know issue. It probably is, because I'm not
a bash-completion long-time user:

$ tar Jxvf pkg/mpfr-3.1.0.tar.xz -C -srbash: compgen: -r: invalid option
compgen: usage: compgen [-abcdefgjksuv] [-o option]  [-A action] [-G
globpat] [-W wordlist]  [-F function] [-C command] [-X filterpat] [-P
prefix] [-S suffix] [word]

After "-sr" I pressed tab for auto-completion. The minus was a typo
that caused the error.

--=20
Jo=E3o M. S. Silva


From MAILER-DAEMON Mon Apr 02 09:26:08 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEhGq-0006D6-6S
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 09:26:08 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45873)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dennistwilliamson@gmail.com>) id 1SEhGj-0006Cw-1p
	for bug-bash@gnu.org; Mon, 02 Apr 2012 09:26:06 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dennistwilliamson@gmail.com>) id 1SEhGc-0007k0-W1
	for bug-bash@gnu.org; Mon, 02 Apr 2012 09:26:00 -0400
Received: from mail-yx0-f169.google.com ([209.85.213.169]:52037)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dennistwilliamson@gmail.com>) id 1SEhGc-0007ji-PA
	for bug-bash@gnu.org; Mon, 02 Apr 2012 09:25:54 -0400
Received: by yenm8 with SMTP id m8so1338964yen.0
	for <bug-bash@gnu.org>; Mon, 02 Apr 2012 06:25:52 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=RNem+pXr0sNR0E8OhXqG4VY5y+87v4a0e5aSTh799Yc=;
	b=tCwgrIh+lVRQIikUipVzlLGz3KAifJgKYLjnJNabqzNw96SNwJ3cltdNaZmCjhmt1r
	YM02ZQym7GaBsBiZ+/7Z/xHfV41zJ+to2/vaJsf3zKfulSYVQUPtrKE0WHq4pB6s9GdH
	gQKawlTJBz8FgZi+2ltnvVzPLWykWTsGHzleKXn0FaeWBrGM/3S/m6iJ/TVPKJ2phVsi
	NBi8bfNY63+tadt4TlHpFgWMgAzXHE8B7/Nk4ZW1RVwUiSwcw1HFF0UraBg5khRm4NBh
	kf57JkMrFgzPwl77EaTa6OnOyUh/C/j1dZzIdMetNkh9Fwpnntv4653ffCUxfW49Dp+t
	Xekw==
MIME-Version: 1.0
Received: by 10.60.14.166 with SMTP id q6mr12285258oec.17.1333373152054; Mon,
	02 Apr 2012 06:25:52 -0700 (PDT)
Received: by 10.182.51.137 with HTTP; Mon, 2 Apr 2012 06:25:51 -0700 (PDT)
Received: by 10.182.51.137 with HTTP; Mon, 2 Apr 2012 06:25:51 -0700 (PDT)
In-Reply-To: <Exw1q.167160$w86.84184@newsfe22.ams2>
References: <Exw1q.167160$w86.84184@newsfe22.ams2>
Date: Mon, 2 Apr 2012 08:25:51 -0500
Message-ID: <CANaoh6JCtmN+aUNmwkb4Hpma2b++9LiW8k5xBmtABX0Uy=QHRw@mail.gmail.com>
Subject: Re: sed problem
From: Dennis Williamson <dennistwilliamson@gmail.com>
To: Francky Leyn <Francky@leyn.eu>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.213.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 13:26:06 -0000

Wrong list. Your question is not about Bash and it's not about a bug in
Bash.

From MAILER-DAEMON Mon Apr 02 09:57:05 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEhkn-0008UJ-1K
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 09:57:05 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51631)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SEhkk-0008UB-UC
	for bug-bash@gnu.org; Mon, 02 Apr 2012 09:57:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SEhkj-0000O9-3F
	for bug-bash@gnu.org; Mon, 02 Apr 2012 09:57:02 -0400
Received: from fmmailgate07.web.de ([217.72.192.248]:56500)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SEhki-0000Ny-TJ
	for bug-bash@gnu.org; Mon, 02 Apr 2012 09:57:01 -0400
Received: from moweb002.kundenserver.de (moweb002.kundenserver.de
	[172.19.20.108])
	by fmmailgate07.web.de (Postfix) with ESMTP id 6A23AFEF583
	for <bug-bash@gnu.org>; Mon,  2 Apr 2012 15:56:58 +0200 (CEST)
Received: from [192.168.178.49] ([93.134.95.201]) by smtp.web.de (mrweb001)
	with ESMTPA (Nemesis) id 0Ldmkd-1SfD462Z0d-00irZa;
	Mon, 02 Apr 2012 15:56:58 +0200
Message-ID: <4F79B02A.9000305@web.de>
Date: Mon, 02 Apr 2012 15:56:58 +0200
From: dethrophes <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Dennis Williamson <dennistwilliamson@gmail.com>, 
	Francky Leyn <Francky@leyn.eu>
Subject: Re: sed problem
References: <Exw1q.167160$w86.84184@newsfe22.ams2>
	<CANaoh6JCtmN+aUNmwkb4Hpma2b++9LiW8k5xBmtABX0Uy=QHRw@mail.gmail.com>
In-Reply-To: <CANaoh6JCtmN+aUNmwkb4Hpma2b++9LiW8k5xBmtABX0Uy=QHRw@mail.gmail.com>
X-Provags-ID: V02:K0:Kra9QSxw2J90Z7Glyy8rjuqePNo7CVVvRWjuBTbOJhd
	+o1zrFNN4160KW/5kvhCTabArNccgPYCU5OZ8DoapqkFq4YagH
	b2FupKUnEGiSy+i8m1X/0AwvlGK76V/ExYzmlFQOlbLMjWMxl3
	WKkoazBDiAqs7rplZupFjAxZZFuUDFVGhrorEe8PoBE+X1e2mW
	nmYHpVnPGhmrY2xO7TXkg==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.248
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 13:57:04 -0000

Am 02.04.2012 15:25, schrieb Dennis Williamson:
> Wrong list. Your question is not about Bash and it's not about a bug in
> Bash.
bash completion not bash.
http://bash-completion.alioth.debian.org/ 
<mailto:bash-completion-devel@lists.alioth.debian.org>

From MAILER-DAEMON Mon Apr 02 10:02:44 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEhqG-0003jz-6w
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 10:02:44 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56840)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dennistwilliamson@gmail.com>) id 1SEhq5-0003ie-6Y
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:02:42 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dennistwilliamson@gmail.com>) id 1SEhq0-0001ol-K2
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:02:32 -0400
Received: from mail-gx0-f169.google.com ([209.85.161.169]:33573)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dennistwilliamson@gmail.com>) id 1SEhq0-0001oI-DF
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:02:28 -0400
Received: by ggeq1 with SMTP id q1so1367570gge.0
	for <bug-bash@gnu.org>; Mon, 02 Apr 2012 07:02:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=Tzf1LolMPIKKB3KENZhKOcfXwrtE9FlMIDhjMHKOHw0=;
	b=xv01f6irnMbWkln7+mIgBEZ6nns3q96QzcTifq1Id5JSaZD4LdXC6k9sWvNyoyYpt2
	xxvn/9tI+jWD/RB4s7ezMfQ853RI4lBGDj4k9mL4gnmVd1pyr1bFdnux4NADjwSAmlMX
	Q9XBhJRAABnHfcML2oBEZPeN+aWys4PkWSWY/wIhOA911bfzmLH2e92q7XY6/TfbZEqq
	q4a2E0La0NL+udHwkKRyJ1mMKlhS8mKvrSxkjgheCDTXLYY4/s8ykoH7h+0bkEXPL9Wr
	aCjuwfnE5WRQt1eKqcbfJ3iU7D9aCTq/fVKh80vVm3zoMPf9zgFBh9NLBuioQ1Zp5jO6
	6scg==
MIME-Version: 1.0
Received: by 10.60.3.34 with SMTP id 2mr12451770oez.27.1333375346470; Mon, 02
	Apr 2012 07:02:26 -0700 (PDT)
Received: by 10.182.51.137 with HTTP; Mon, 2 Apr 2012 07:02:26 -0700 (PDT)
Received: by 10.182.51.137 with HTTP; Mon, 2 Apr 2012 07:02:26 -0700 (PDT)
In-Reply-To: <4F79B02A.9000305@web.de>
References: <Exw1q.167160$w86.84184@newsfe22.ams2>
	<CANaoh6JCtmN+aUNmwkb4Hpma2b++9LiW8k5xBmtABX0Uy=QHRw@mail.gmail.com>
	<4F79B02A.9000305@web.de>
Date: Mon, 2 Apr 2012 09:02:26 -0500
Message-ID: <CANaoh6Kt_aLpW5NR7ZwRm0iS6exLBG9-bMEJBHEJVTJj1GHJiw@mail.gmail.com>
Subject: Re: sed problem
From: Dennis Williamson <dennistwilliamson@gmail.com>
To: dethrophes <dethrophes@web.de>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.161.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 14:02:42 -0000

You must have replied to the wrong message. The original was about sed, not
completion.

From MAILER-DAEMON Mon Apr 02 10:24:31 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEiBL-0003h4-P5
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 10:24:31 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45956)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEiBG-0003QL-Cn
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:24:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEiBE-00088I-Ea
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:24:25 -0400
Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:32224)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEiBE-000881-Ai
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:24:24 -0400
Received: from 4.41.21.95.dynamic.jazztel.es ([95.21.41.4]
	helo=mail.viric.name)
	by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.72) (envelope-from <viric@viric.name>)
	id 1SEiBC-000Oqg-7R; Mon, 02 Apr 2012 14:24:22 +0000
Received: by mail.viric.name (Postfix, from userid 1000)
	id 3209855C4BC; Mon,  2 Apr 2012 16:24:18 +0200 (CEST)
X-Mail-Handler: MailHop Outbound by DynDNS
X-Originating-IP: 95.21.41.4
X-Report-Abuse-To: abuse@dyndns.com (see
	http://www.dyndns.com/services/mailhop/outbound_abuse.html for
	abuse reporting information)
X-MHO-User: U2FsdGVkX18DESvtVthMYqWgY4l6Q/v2
Date: Mon, 2 Apr 2012 16:24:18 +0200
From: =?iso-8859-1?Q?Llu=EDs?= Batlle i Rossell <viric@viric.name>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Strange behaviour on 'read' from a pipe
Message-ID: <20120402142418.GW3029@vicerveza.homeunix.net>
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu> <m2mx6vrd6f.fsf@igel.home>
	<4F786EEE.5050101@case.edu>
	<20120401170235.GU3029@vicerveza.homeunix.net>
	<4F78D662.30506@case.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
In-Reply-To: <4F78D662.30506@case.edu>
X-Accept-Language: ca, es, eo, ru, en, jbo, tokipona
User-Agent: Mutt/1.5.20 (2009-06-14)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 204.13.248.71
Cc: Andreas Schwab <schwab@linux-m68k.org>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 14:24:31 -0000

On Sun, Apr 01, 2012 at 06:27:46PM -0400, Chet Ramey wrote:
> On 4/1/12 1:02 PM, Llu=EDs Batlle i Rossell wrote:
> > On Sun, Apr 01, 2012 at 11:06:22AM -0400, Chet Ramey wrote:
> >> On 4/1/12 5:53 AM, Andreas Schwab wrote:
> >>
> >>>> It looks like a simple race condition.  I suspect that the schedul=
er
> >>>> arranges things so that the child process ends up exiting between =
the
> >>>> open and the read, but I don't have any real evidence to back it u=
p.
> >>>
> >>> Note that the opening of the pipe as part of the redirection in the
> >>> parent blocks until there is a writer, ie. until the child opens th=
e
> >>> pipe.  Can this open call return EINTR?
> >>
> >> open() is supposed to return EINTR only if interrupted by a signal. =
 The
> >> only signal I can see occurring is SIGCHLD, and bash installs the SI=
GCHLD
> >> handler with SA_RESTART.
> >=20
> > Then, any idea of what can be happening?
>=20
> It looks like a race condition, like I said.  I can't reproduce it on m=
y
> system, so I don't have anything to troubleshoot.

Running "strace ./script" says these next. Notice it hangs at open(). If =
I use
"strace -f" to follow the child, all works.

OTH, I tried in another computer with the same bash+libc (hashes compared=
), and
it worked there. But in the problematic computer (linux 3.2.11 x86_64) al=
so
other bash/libc versions hanged.

...
read(255, "\nfunction spawn {\n    \"$@\"\n    e"..., 281) =3D 201
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  =3D 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  =3D 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  =3D 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) =3D 0
lseek(255, -113, SEEK_CUR)              =3D 168
clone(child_stack=3D0, flags=3DCLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SI=
GCHLD,
child_tidptr=3D0x7fd40fbbc9d0) =3D 29446
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) =3D 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) =3D 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) =3D 0
rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) =3D 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) =3D 0
rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) =3D 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) =3D 0
rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) =3D 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) =3D 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  =3D 0
read(255, "\nwhile true; do\n    echo reading"..., 281) =3D 113
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  =3D 0
brk(0x21b2000)                          =3D 0x21b2000
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) =3D 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) =3D 0
write(1, "reading\n", 8reading
)                =3D 8
open("/tmp/pipe", O_RDONLYdebug:done
)             =3D ? ERESTARTSYS (To be restarted)
--- {si_signo=3DSIGCHLD, si_code=3DCLD_EXITED, si_pid=3D29446, si_status=3D=
0,
si_utime=3D0, si_stime=3D0} (Child exited) ---
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) =3D=3D 0}], WNOHANG, NULL) =3D=
 29446
wait4(-1, 0x7fff2c3c0798, WNOHANG, NULL) =3D -1 ECHILD (No child processe=
s)
rt_sigreturn(0xffffffffffffffff)        =3D 2
open("/tmp/pipe", O_RDONLY




From MAILER-DAEMON Mon Apr 02 10:35:17 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEiLl-0003Lt-5D
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 10:35:17 -0400
Received: from eggs.gnu.org ([208.118.235.92]:42519)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lina.lastname@gmail.com>) id 1SEiLh-0003B2-4n
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:35:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lina.lastname@gmail.com>) id 1SEiLa-0002zJ-Kf
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:35:12 -0400
Received: from mail-qc0-f169.google.com ([209.85.216.169]:39837)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lina.lastname@gmail.com>) id 1SEiLa-0002vq-Bp
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:35:06 -0400
Received: by qcsd16 with SMTP id d16so1869406qcs.0
	for <bug-bash@gnu.org>; Mon, 02 Apr 2012 07:35:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=8hTufrkDtEdTYZBlG4AGaPLpLMq4GAVsmwiJT8S98ag=;
	b=dietbmqRe/iwdI6c2jU8JG1S+iV8B2S70O1oTjlXgHDb59M73IWubPbjUmL9eNACC4
	kozk3A9P4gaPfwAgJs8sbFNq5J1u3FiyrXruP7yrkPBNbhrgoUFuSnq8AkVCoF5917Er
	QXNAA01f1PjkxnapmMS21pji2GsnXTQqf0uZHb2gROBOPjeIYkp4SkOYTMZtWFuhLUn/
	RN/vQuv1fR3dxp7xb1iaLUlohnrABbD4x9Vzlr0enHVIJFSiTxI7zzNVjApXPhjoH1eC
	c2aLJjgZwsxg2DeB7Lyvox4kpO2H+pBcZnIKNl0JKlti3n6rN9+BJY9cWmRnvFK+Ds1q
	aUkw==
MIME-Version: 1.0
Received: by 10.224.32.12 with SMTP id a12mr11462900qad.0.1333377303808; Mon,
	02 Apr 2012 07:35:03 -0700 (PDT)
Received: by 10.224.101.197 with HTTP; Mon, 2 Apr 2012 07:35:03 -0700 (PDT)
In-Reply-To: <Exw1q.167160$w86.84184@newsfe22.ams2>
References: <Exw1q.167160$w86.84184@newsfe22.ams2>
Date: Mon, 2 Apr 2012 22:35:03 +0800
Message-ID: <CAG9cJmn5QzgyaNRTe3tH29SMdBpzidKs13BJp_ZihMVJOUsCbg@mail.gmail.com>
Subject: Re: sed problem
From: lina <lina.lastname@gmail.com>
To: Francky Leyn <Francky@leyn.eu>
Content-Type: text/plain; charset=ISO-8859-1
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.216.169
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 14:35:14 -0000

On Sat, Aug 13, 2011 at 11:14 PM, Francky Leyn <Francky@leyn.eu> wrote:
> Hello,
>
> I have the following problem: I must write a sed script that
> converts parts of groff syntax to LaTeX syntax.
>
> eg: .BI -o gif_output_file -> \textbf{-o} \textit{gif\_output\_file}
>
> Lets neglect the underscores for the moment.
>
> This can be dan with
>
> s/\.BI \([^ ]*\) \([^ ]*\)/\\textbf{\1} \\textit{\2}/
>
> However, it also has to work for:
>
> eg: .BI -o " gif_output_file
>
> It doesn't: this is the output:
>
> \textbf{-o} \textit{"} gif\_output\_file"
>
> Of couse.
>
> My question: how do you write it correctly in sed?


I came up with a very clumsy one, but easily to see what's going on,
anyway, it seems work.

$ echo "BI -o\" gif_output_file" | sed  -e 's/.* \(\-o\)\([\"]*\)
\(.*\)/\\texbf{\1} \\textit{\2} \\textit{\3}/g; s/\_/\\_/g ; s/
\\textit{}//g '
\texbf{-o} \textit{"} \textit{gif\_output\_file}

echo "BI -o gif_output_file" | sed  -e 's/.* \(\-o\)\([\"]*\)
\(.*\)/\\texbf{\1} \\textit{\2} \\textit{\3}/g; s/\_/\\_/g ; s/
\\textit{}//g '
\texbf{-o} \textit{gif\_output\_file}


You are welcome.


>
> Best reagrds,
>
> Francky


From MAILER-DAEMON Mon Apr 02 10:39:37 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEiPx-0004Qt-01
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 10:39:37 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58848)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEiPr-0004QM-8y
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:39:35 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEiPk-0003et-S2
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:39:30 -0400
Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:47583)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEiPk-0003ej-P8
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:39:24 -0400
Received: from 4.41.21.95.dynamic.jazztel.es ([95.21.41.4]
	helo=mail.viric.name)
	by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.72) (envelope-from <viric@viric.name>)
	id 1SEiPj-000710-7I; Mon, 02 Apr 2012 14:39:23 +0000
Received: by mail.viric.name (Postfix, from userid 1000)
	id BAFE855C4C2; Mon,  2 Apr 2012 16:39:19 +0200 (CEST)
X-Mail-Handler: MailHop Outbound by DynDNS
X-Originating-IP: 95.21.41.4
X-Report-Abuse-To: abuse@dyndns.com (see
	http://www.dyndns.com/services/mailhop/outbound_abuse.html for
	abuse reporting information)
X-MHO-User: U2FsdGVkX1/e1ZPrWlcknUxg9xm47lS8
Date: Mon, 2 Apr 2012 16:39:19 +0200
From: =?iso-8859-1?Q?Llu=EDs?= Batlle i Rossell <viric@viric.name>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Strange behaviour on 'read' from a pipe
Message-ID: <20120402143919.GX3029@vicerveza.homeunix.net>
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu> <m2mx6vrd6f.fsf@igel.home>
	<4F786EEE.5050101@case.edu>
	<20120401170235.GU3029@vicerveza.homeunix.net>
	<4F78D662.30506@case.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
In-Reply-To: <4F78D662.30506@case.edu>
X-Accept-Language: ca, es, eo, ru, en, jbo, tokipona
User-Agent: Mutt/1.5.20 (2009-06-14)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 204.13.248.71
Cc: Andreas Schwab <schwab@linux-m68k.org>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 14:39:35 -0000

On Sun, Apr 01, 2012 at 06:27:46PM -0400, Chet Ramey wrote:
> On 4/1/12 1:02 PM, Llu=EDs Batlle i Rossell wrote:
> > On Sun, Apr 01, 2012 at 11:06:22AM -0400, Chet Ramey wrote:
> >> On 4/1/12 5:53 AM, Andreas Schwab wrote:
> >>
> >>>> It looks like a simple race condition.  I suspect that the schedul=
er
> >>>> arranges things so that the child process ends up exiting between =
the
> >>>> open and the read, but I don't have any real evidence to back it u=
p.
> >>>
> >>> Note that the opening of the pipe as part of the redirection in the
> >>> parent blocks until there is a writer, ie. until the child opens th=
e
> >>> pipe.  Can this open call return EINTR?
> >>
> >> open() is supposed to return EINTR only if interrupted by a signal. =
 The
> >> only signal I can see occurring is SIGCHLD, and bash installs the SI=
GCHLD
> >> handler with SA_RESTART.
> >=20
> > Then, any idea of what can be happening?
>=20
> It looks like a race condition, like I said.  I can't reproduce it on m=
y
> system, so I don't have anything to troubleshoot.

Trying to reproduce the race, I got rid of 'sleep', and expected this to =
never
hang. But it hangs where I try. Should I submit this to LKML maybe?

I think it should not hang ever, but maybe I forecast something bad.
-------------
#!/var/run/current-system/sw/bin/bash

PIPE=3D/tmp/pipe

rm -f $PIPE
mkfifo $PIPE

function spawn {
    echo DONE > $PIPE
}

spawn sleep 1 &

while true; do
    echo reading
    while read LINE < $PIPE; do
        echo $LINE
        spawn &
    done
done
---------------


From MAILER-DAEMON Mon Apr 02 14:19:22 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SElqc-0000A4-M1
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 14:19:22 -0400
Received: from eggs.gnu.org ([208.118.235.92]:40111)
	by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <fidu@gmx.at>)
	id 1SEiFh-0005N5-Ez
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:29:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <fidu@gmx.at>) id 1SEiFe-000179-C8
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:29:01 -0400
Received: from mailout-de.gmx.net ([213.165.64.22]:34629)
	by eggs.gnu.org with smtp (Exim 4.71) (envelope-from <fidu@gmx.at>)
	id 1SEiFe-00016N-1e
	for bug-bash@gnu.org; Mon, 02 Apr 2012 10:28:58 -0400
Received: (qmail invoked by alias); 02 Apr 2012 14:28:55 -0000
Received: from 80-121-18-10.adsl.highway.telekom.at (EHLO [10.7.6.101])
	[80.121.18.10]
	by mail.gmx.net (mp004) with SMTP; 02 Apr 2012 16:28:55 +0200
X-Authenticated: #7844416
X-Provags-ID: V01U2FsdGVkX198wytv8qR8Z/ysCvVgG+fOrOuv1WvPgInOdHn2Kb
	oQPOJ7kbOMyjkv
Message-ID: <4F79B7A6.8070104@gmx.at>
Date: Mon, 02 Apr 2012 16:28:54 +0200
From: Fidu <fidu@gmx.at>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US;
	rv:1.9.1.16) Gecko/20120317 Icedove/3.0.11
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: test - StringComparisons dont work
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Y-GMX-Trusted: 0
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 213.165.64.22
X-Mailman-Approved-At: Mon, 02 Apr 2012 14:19:21 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 14:29:09 -0000

BASH_VERSION='4.1.5(1)-release'

Hi!
x=sss;
test "rrr" > $x  redirects to file sss, instead of comparing.
Any hint?


Qu2:
How to use
 expr?expr:expr
              conditional operator
       = *= /= %= += -= <<= >>= &= ^= |=
              assignment

I didn't find any working construction?
   ($x=3)?(x=10:x=0);
Operators aren't explained anywhere?

thanks, Andrew



From MAILER-DAEMON Mon Apr 02 14:27:59 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SElyx-0003xZ-U1
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 14:27:59 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44029)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SElyw-0003wv-0e
	for bug-bash@gnu.org; Mon, 02 Apr 2012 14:27:59 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SElyp-0004sg-Oy
	for bug-bash@gnu.org; Mon, 02 Apr 2012 14:27:57 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45575
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SElyp-0004ru-IS
	for bug-bash@gnu.org; Mon, 02 Apr 2012 14:27:51 -0400
Received: (qmail 19064 invoked from network); 2 Apr 2012 18:27:48 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Mon, 02 Apr 2012 14:27:48 -0400
Received: (qmail 1514 invoked by uid 563); 2 Apr 2012 18:27:48 -0000
Date: Mon, 2 Apr 2012 14:27:48 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Fidu <fidu@gmx.at>
Subject: Re: test - StringComparisons dont work
Message-ID: <20120402182748.GQ22241@eeg.ccf.org>
References: <4F79B7A6.8070104@gmx.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F79B7A6.8070104@gmx.at>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 18:27:59 -0000

On Mon, Apr 02, 2012 at 04:28:54PM +0200, Fidu wrote:
> test "rrr" > $x  redirects to file sss, instead of comparing.
> Any hint?

test rrr \> "$x"

or

test rrr ">" "$x"

However, it should be noted that ">" as a string comparison operator in
the test command is an extension, and not portable.  As such, it might
be better to use [[ so that you can *plainly see* that the code is using
bashisms, and is not sh-compatible.

[[ rrr > "$x" ]]

This gives you the benefit of not needing to quote the > operator, as well
as the visual clue about non-portability.


From MAILER-DAEMON Mon Apr 02 14:46:24 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEmGm-0001Ci-29
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 14:46:24 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49200)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEmGj-0001CB-Bx
	for bug-bash@gnu.org; Mon, 02 Apr 2012 14:46:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEmGh-0001Bt-4P
	for bug-bash@gnu.org; Mon, 02 Apr 2012 14:46:20 -0400
Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:48915)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEmGh-0001Ba-10
	for bug-bash@gnu.org; Mon, 02 Apr 2012 14:46:19 -0400
Received: from 4.41.21.95.dynamic.jazztel.es ([95.21.41.4]
	helo=mail.viric.name)
	by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.72) (envelope-from <viric@viric.name>)
	id 1SEmGd-000F7i-RC; Mon, 02 Apr 2012 18:46:16 +0000
Received: by mail.viric.name (Postfix, from userid 1000)
	id 68B9755C4F4; Mon,  2 Apr 2012 20:46:12 +0200 (CEST)
X-Mail-Handler: MailHop Outbound by DynDNS
X-Originating-IP: 95.21.41.4
X-Report-Abuse-To: abuse@dyndns.com (see
	http://www.dyndns.com/services/mailhop/outbound_abuse.html for
	abuse reporting information)
X-MHO-User: U2FsdGVkX1+HPsYGJ6e+sFF4IdmumcSj
Date: Mon, 2 Apr 2012 20:46:12 +0200
From: =?iso-8859-1?Q?Llu=EDs?= Batlle i Rossell <viric@viric.name>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Strange behaviour on 'read' from a pipe
Message-ID: <20120402184612.GA3029@vicerveza.homeunix.net>
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu> <m2mx6vrd6f.fsf@igel.home>
	<4F786EEE.5050101@case.edu>
	<20120401170235.GU3029@vicerveza.homeunix.net>
	<4F78D662.30506@case.edu>
	<20120402143919.GX3029@vicerveza.homeunix.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
In-Reply-To: <20120402143919.GX3029@vicerveza.homeunix.net>
X-Accept-Language: ca, es, eo, ru, en, jbo, tokipona
User-Agent: Mutt/1.5.20 (2009-06-14)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 204.13.248.71
Cc: Andreas Schwab <schwab@linux-m68k.org>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 18:46:22 -0000

On Mon, Apr 02, 2012 at 04:39:19PM +0200, Llu=EDs Batlle i Rossell wrote:
> Trying to reproduce the race, I got rid of 'sleep', and expected this t=
o never
> hang. But it hangs where I try. Should I submit this to LKML maybe?
>=20
> I think it should not hang ever, but maybe I forecast something bad.
> -------------
> #!/var/run/current-system/sw/bin/bash
>=20
> PIPE=3D/tmp/pipe
>=20
> rm -f $PIPE
> mkfifo $PIPE
>=20
> function spawn {
>     echo DONE > $PIPE
> }
>=20
> spawn sleep 1 &
>=20
> while true; do
>     echo reading
>     while read LINE < $PIPE; do
>         echo $LINE
>         spawn &
>     done
> done
> ---------------

Adding a 'sleep 0.1' before 'echo DONE' makes it hang very early in three=
 linux
machines I tried. Let me know if you can reproduce it. Let me know if thi=
s helps
you reproduce the problem. Here again:

----------
#!/bin/sh

PIPE=3D/tmp/pipe

rm -f $PIPE
mkfifo $PIPE
set -x

spawn() {
    sleep 0.1
    echo DONE > $PIPE
}

spawn &

while true; do
    while read LINE < $PIPE; do
        echo $LINE
        spawn &
    done
done
-----------


From MAILER-DAEMON Mon Apr 02 15:29:41 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEmwf-0001YI-Ta
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 15:29:41 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58528)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SEmwd-0001VY-13
	for bug-bash@gnu.org; Mon, 02 Apr 2012 15:29:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SEmwb-0002iq-8C
	for bug-bash@gnu.org; Mon, 02 Apr 2012 15:29:38 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45604
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SEmwb-0002iL-1Q
	for bug-bash@gnu.org; Mon, 02 Apr 2012 15:29:37 -0400
Received: (qmail 19581 invoked from network); 2 Apr 2012 19:29:34 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Mon, 02 Apr 2012 15:29:34 -0400
Received: (qmail 1665 invoked by uid 563); 2 Apr 2012 19:29:33 -0000
Date: Mon, 2 Apr 2012 15:29:33 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: =?iso-8859-1?Q?Llu=EDs?= Batlle i Rossell <viric@viric.name>
Subject: Re: Strange behaviour on 'read' from a pipe
Message-ID: <20120402192933.GS22241@eeg.ccf.org>
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu> <m2mx6vrd6f.fsf@igel.home>
	<4F786EEE.5050101@case.edu>
	<20120401170235.GU3029@vicerveza.homeunix.net>
	<4F78D662.30506@case.edu>
	<20120402143919.GX3029@vicerveza.homeunix.net>
	<20120402184612.GA3029@vicerveza.homeunix.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20120402184612.GA3029@vicerveza.homeunix.net>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 19:29:40 -0000

On Mon, Apr 02, 2012 at 08:46:12PM +0200, Lluís Batlle i Rossell wrote:
> #!/bin/sh

You're running this in sh?  But reporting it as a bug in bash?

> PIPE=/tmp/pipe
> 
> rm -f $PIPE
> mkfifo $PIPE
> set -x
> 
> spawn() {
>     sleep 0.1
>     echo DONE > $PIPE
> }
> 
> spawn &
> 
> while true; do
>     while read LINE < $PIPE; do
>         echo $LINE
>         spawn &
>     done
> done

I ran this, with #!/bin/bash and with sleep 1 instead of sleep 0.1,
on an HP-UX 10.20 system and a Debian 6.0 (Linux) system.  For me,
it printed "DONE" once per second until I pressed ctrl-C, on both
systems.

Changing the sleep 1 back to sleep 0.1 and re-running on the Linux
system produced the same result, just 10 times as fast.

Changing the #!/bin/bash to #!/bin/sh and re-re-running on Linux
still produced the same result.


From MAILER-DAEMON Mon Apr 02 16:17:37 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SEnh3-0001UF-JI
	for mharc-bug-bash@gnu.org; Mon, 02 Apr 2012 16:17:37 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37030)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEnh1-0001Tu-57
	for bug-bash@gnu.org; Mon, 02 Apr 2012 16:17:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEngz-0006sW-9Z
	for bug-bash@gnu.org; Mon, 02 Apr 2012 16:17:34 -0400
Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:11067)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <viric@viric.name>) id 1SEngz-0006sS-5j
	for bug-bash@gnu.org; Mon, 02 Apr 2012 16:17:33 -0400
Received: from 4.41.21.95.dynamic.jazztel.es ([95.21.41.4]
	helo=mail.viric.name)
	by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.72) (envelope-from <viric@viric.name>)
	id 1SEngx-0008Qa-K4; Mon, 02 Apr 2012 20:17:31 +0000
Received: by mail.viric.name (Postfix, from userid 1000)
	id DC46E55C50E; Mon,  2 Apr 2012 22:17:26 +0200 (CEST)
X-Mail-Handler: MailHop Outbound by DynDNS
X-Originating-IP: 95.21.41.4
X-Report-Abuse-To: abuse@dyndns.com (see
	http://www.dyndns.com/services/mailhop/outbound_abuse.html for
	abuse reporting information)
X-MHO-User: U2FsdGVkX1+9/ib9ebZuwoqMha26VpiT
Date: Mon, 2 Apr 2012 22:17:26 +0200
From: =?iso-8859-1?Q?Llu=EDs?= Batlle i Rossell <viric@viric.name>
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: Strange behaviour on 'read' from a pipe
Message-ID: <20120402201726.GC3029@vicerveza.homeunix.net>
References: <20120331131938.GM3029@vicerveza.homeunix.net>
	<4F77AC64.2010602@case.edu> <m2mx6vrd6f.fsf@igel.home>
	<4F786EEE.5050101@case.edu>
	<20120401170235.GU3029@vicerveza.homeunix.net>
	<4F78D662.30506@case.edu>
	<20120402143919.GX3029@vicerveza.homeunix.net>
	<20120402184612.GA3029@vicerveza.homeunix.net>
	<20120402192933.GS22241@eeg.ccf.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
In-Reply-To: <20120402192933.GS22241@eeg.ccf.org>
X-Accept-Language: ca, es, eo, ru, en, jbo, tokipona
User-Agent: Mutt/1.5.20 (2009-06-14)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 204.13.248.71
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 02 Apr 2012 20:17:36 -0000

On Mon, Apr 02, 2012 at 03:29:33PM -0400, Greg Wooledge wrote:
> On Mon, Apr 02, 2012 at 08:46:12PM +0200, Llu=EDs Batlle i Rossell wrot=
e:
> > #!/bin/sh
>=20
> You're running this in sh?  But reporting it as a bug in bash?

In that case, sh points to bash. Sorry for the confusion I could have cau=
sed.

> > while true; do
> >     while read LINE < $PIPE; do
> >         echo $LINE
> >         spawn &
> >     done
> > done
>=20
> I ran this, with #!/bin/bash and with sleep 1 instead of sleep 0.1,
> on an HP-UX 10.20 system and a Debian 6.0 (Linux) system.  For me,
> it printed "DONE" once per second until I pressed ctrl-C, on both
> systems.
>=20
> Changing the sleep 1 back to sleep 0.1 and re-running on the Linux
> system produced the same result, just 10 times as fast.
>=20
> Changing the #!/bin/bash to #!/bin/sh and re-re-running on Linux
> still produced the same result.

I found the race condition, after implementing it in C. It's there in the=
 script
too.

It can happen that the child spawns, but does not reach the "open pipe wr=
iting"
call of echo DONE, while the loop goes another round, runs read LINE agai=
n, and
reads *EOF*, exiting the inner while loop.

Sorry for the headache.

Here is the proper version without race condition, that uses the close/re=
ad()=3D0
as synchronisation:

---------------
#!/bin/bash

PIPE=3D/tmp/pipe

rm -f $PIPE
mkfifo $PIPE

spawn() {
    echo DONE > $PIPE
}

spawn &

# read A  -- to read EOF from the child, to ensure it closed the pipe.
while (read LINE ; echo $LINE; read A; echo child closed) < $PIPE; do
    spawn &
done
----------------

Best regards,
Llu=EDs.


From MAILER-DAEMON Tue Apr 03 22:13:35 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SFFj5-0006wM-RC
	for mharc-bug-bash@gnu.org; Tue, 03 Apr 2012 22:13:35 -0400
Received: from eggs.gnu.org ([208.118.235.92]:35542)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jrrandall@gmail.com>) id 1SFBBh-0006QC-9P
	for bug-bash@gnu.org; Tue, 03 Apr 2012 17:22:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jrrandall@gmail.com>) id 1SFBBf-0005xC-IO
	for bug-bash@gnu.org; Tue, 03 Apr 2012 17:22:48 -0400
Received: from mail-yw0-f41.google.com ([209.85.213.41]:40331)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jrrandall@gmail.com>) id 1SFBBf-0005x5-Bs
	for bug-bash@gnu.org; Tue, 03 Apr 2012 17:22:47 -0400
Received: by yhr47 with SMTP id 47so130754yhr.0
	for <bug-bash@gnu.org>; Tue, 03 Apr 2012 14:22:44 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:from:date:message-id:subject:to:content-type;
	bh=QLJR5e2lpTRhmMoRnM4YhtUGmr8/VMa48eJ7i0zvBp4=;
	b=KzTKdcKWzCSZ+3kWXv0nkFRIH1bly6vfAlZJiq25jm368BkFNSYe+q9DyQW249LJv/
	+Y6N9rXcaBHSXrE3md5QOMehv96sNbqGqOiMBS6YhVQADeJLwCsM5q9xB/AgM9i+Lkih
	VEQdOb3fxXdXO1IGOicTgS2XIUstP6OCy9tr5l42K6P/rIFYZu438KgnMjoGIff8crhx
	Cs1wRnyeAU+7nki3Mu9yxNgVjPSrJNslGa/IWCNY+W2g4KZipHjOg7Huu2WB0KG06xFe
	RazcE3Ms85EvCeOORmH6aIf64uySFMNMd7hxTxdyP0E8HzKA/GpgQznAACEGIYaiq+VJ
	ScNQ==
Received: by 10.60.21.103 with SMTP id u7mr21154064oee.11.1333488162228; Tue,
	03 Apr 2012 14:22:42 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.60.28.227 with HTTP; Tue, 3 Apr 2012 14:22:22 -0700 (PDT)
From: "jrrandall@gmail.com" <jrrandall@gmail.com>
Date: Tue, 3 Apr 2012 17:22:22 -0400
Message-ID: <CAFtv-6b1ibi2CZ+34+fY5g5aUrgiQHWQbAaHF089s6F2YKZw8w@mail.gmail.com>
Subject: Expanding aliases to full command before execution
To: bug-bash@gnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.213.41
X-Mailman-Approved-At: Tue, 03 Apr 2012 22:13:34 -0400
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 03 Apr 2012 21:22:50 -0000

Hi everyone,

In bash, is it possible to expand my aliases either before they are
executed or when they are stored in the history file?
For example, if I have:  alias ll='ls -l'  defined in my .bashrc, when I
execute "ll" from the command line, I'd like my history file to contain "ls
-l".  Is there any way to accomplish this?

Thanks,
Justin

-- 
Justin Randall

From MAILER-DAEMON Tue Apr 03 22:25:29 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SFFub-0000g1-UX
	for mharc-bug-bash@gnu.org; Tue, 03 Apr 2012 22:25:29 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49420)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SFFuZ-0000fM-Be
	for bug-bash@gnu.org; Tue, 03 Apr 2012 22:25:28 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SFFuX-0005Kv-N3
	for bug-bash@gnu.org; Tue, 03 Apr 2012 22:25:26 -0400
Received: from saturn.syslang.net ([207.172.210.41]:34612)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SFFuX-0005Kj-Ik
	for bug-bash@gnu.org; Tue, 03 Apr 2012 22:25:25 -0400
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by saturn.syslang.net (8.14.5/8.14.5) with ESMTP id q342PKiG029571
	for <bug-bash@gnu.org>; Tue, 3 Apr 2012 22:25:21 -0400
Message-ID: <4F7BB112.9010708@syslang.net>
Date: Tue, 03 Apr 2012 22:25:22 -0400
From: "Steven W. Orr" <steveo@syslang.net>
Organization: SysLang, Inc.
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
	rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: Expanding aliases to full command before execution
References: <CAFtv-6b1ibi2CZ+34+fY5g5aUrgiQHWQbAaHF089s6F2YKZw8w@mail.gmail.com>
In-Reply-To: <CAFtv-6b1ibi2CZ+34+fY5g5aUrgiQHWQbAaHF089s6F2YKZw8w@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 207.172.210.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 04 Apr 2012 02:25:28 -0000

On 4/3/2012 5:22 PM, jrrandall@gmail.com wrote:
> Hi everyone,
>
> In bash, is it possible to expand my aliases either before they are
> executed or when they are stored in the history file?
> For example, if I have:  alias ll='ls -l'  defined in my .bashrc, when I
> execute "ll" from the command line, I'd like my history file to contain "ls
> -l".  Is there any way to accomplish this?
>
> Thanks,
> Justin
>

M-C-e

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


From MAILER-DAEMON Wed Apr 04 08:06:38 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SFOz0-0007ZG-4R
	for mharc-bug-bash@gnu.org; Wed, 04 Apr 2012 08:06:38 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39605)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1SFOyu-0007YR-2d
	for bug-bash@gnu.org; Wed, 04 Apr 2012 08:06:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrt@sc3d.org>) id 1SFOyn-0000Db-VZ
	for bug-bash@gnu.org; Wed, 04 Apr 2012 08:06:31 -0400
Received: from exprod7og109.obsmtp.com ([64.18.2.171]:49497)
	by eggs.gnu.org with smtp (Exim 4.71) (envelope-from <rrt@sc3d.org>)
	id 1SFOyn-0000DE-Mm
	for bug-bash@gnu.org; Wed, 04 Apr 2012 08:06:25 -0400
Received: from mail-yx0-f179.google.com ([209.85.213.179]) (using TLSv1) by
	exprod7ob109.postini.com ([64.18.6.12]) with SMTP
	ID DSNKT3w5PPxO3O/tK9XD6o+0ym7uTEUPjrHm@postini.com;
	Wed, 04 Apr 2012 05:06:23 PDT
Received: by yenl1 with SMTP id l1so51944yen.10
	for <bug-bash@gnu.org>; Wed, 04 Apr 2012 05:06:19 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=mime-version:date:message-id:subject:from:to:content-type
	:x-gm-message-state;
	bh=HUFoyHP4p76skA+CM32Qf4TIpqoRy2kSw7UdyJ1td+I=;
	b=PJlFOjnaD0F9wW7G1uYwmu0tjVIpgktuWJfdt2FSKNhQppFtVw5Td4mDAonF47VmBU
	sb8rIZgdDfje7tfBH+d6Nh4JQbjjW0rRBvSOrcasMF8Y5JwE8EWY92vqqy+l3OJg9Gka
	+hej55Ig7LAXY8imQqdAjJNqT13jiBFpFOrdAoQxW4s78xmdtiD/Hj083WjoWiZuJ4cH
	bJfOcuVDICZv7BsKqGQ2uCuuHGMbWyG+Zn4+DAVXgtwyjw8sVWtiIFTfV3BQneVBLuFM
	K5ngFqCGf2QyL1EGYiMucl4vzuYnz6uDJdA/cRq6OcursAMXpB+WttEbjQ+dg8XPrrnz
	5zqg==
MIME-Version: 1.0
Received: by 10.60.10.137 with SMTP id i9mr25572232oeb.23.1333541179560; Wed,
	04 Apr 2012 05:06:19 -0700 (PDT)
Received: by 10.182.116.4 with HTTP; Wed, 4 Apr 2012 05:06:19 -0700 (PDT)
Date: Wed, 4 Apr 2012 13:06:19 +0100
Message-ID: <CAOnWdogzba2w1XsWZDzZtLy4S3HoY43RNQhHt=vVtKVJzy-8rw@mail.gmail.com>
Subject: Misleading text at start of manual
From: Reuben Thomas <rrt@sc3d.org>
To: bug-bash@gnu.org
Content-Type: text/plain; charset=ISO-8859-1
X-Gm-Message-State: ALoCoQk9hfYXOuXbiHItkaDJ5qTNKgm/28Wo+QEvTWX/+WkXjev1RtnZtZODK6JzZpcPwrgMR1Yn
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	4)
X-Received-From: 64.18.2.171
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 04 Apr 2012 12:06:36 -0000

(Checked against bash 4.2; for some reason, the manual on gnu.org is only 4.1.)

The top node, "Bash Features", says:

"The following menu breaks the features up into categories based upon which
one of these other shells inspired the feature."

But the following menu doesn't seem to bear that out. Perhaps it's
simplest just to remove this sentence, as the top-level menu is
perfectly logical and self-explanatory.

-- 
http://rrt.sc3d.org


From MAILER-DAEMON Wed Apr 04 11:28:00 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SFS7s-00058k-Ti
	for mharc-bug-bash@gnu.org; Wed, 04 Apr 2012 11:28:00 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34395)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jrrandall@gmail.com>) id 1SFS7l-00058I-T3
	for bug-bash@gnu.org; Wed, 04 Apr 2012 11:28:00 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jrrandall@gmail.com>) id 1SFS7b-0004Ak-Bh
	for bug-bash@gnu.org; Wed, 04 Apr 2012 11:27:53 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:42234)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jrrandall@gmail.com>) id 1SFS7b-00049D-4u
	for bug-bash@gnu.org; Wed, 04 Apr 2012 11:27:43 -0400
Received: by obbta14 with SMTP id ta14so594569obb.0
	for <bug-bash@gnu.org>; Wed, 04 Apr 2012 08:27:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:content-type:content-transfer-encoding;
	bh=jbhyU4O1Tc90gv4lgsHCrWbW6gEgdCd9qRR0rKWoX1Y=;
	b=qVEH/mbGHwe0RlG/mHVS/1NtWtATHtw1Gtu4hHU/KgVzKWGiRrPf20raOls9dO6AEB
	HFPKtGPfTrIeVmAE8C8lGPMvn4ykUROUq3FUIEKOdJ0hHRgPShFW7Y7EQfyWyCzTMAJc
	rgKaiTcF8p8QPW8AwNAHxgsWrVn9c9fUAheLddolfg5RfyeW2LTUi8YgKIi8GYLd9MVQ
	wfpqwLIflQZRmDtDvdVpccOKK64Q3gZH6xoaAMXaDI9u7RQIJUstfpScnPZwdZPED47+
	jvlU+6X1mda/svPPDoNUqFsaSelI8rtylg1Gw0x6hVhfXj7CVpmVoNc6bPf/4xVI/cVW
	LKvA==
Received: by 10.182.202.104 with SMTP id kh8mr3831557obc.1.1333553251492; Wed,
	04 Apr 2012 08:27:31 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.60.28.227 with HTTP; Wed, 4 Apr 2012 08:27:11 -0700 (PDT)
In-Reply-To: <CAFtv-6b1ibi2CZ+34+fY5g5aUrgiQHWQbAaHF089s6F2YKZw8w@mail.gmail.com>
References: <CAFtv-6b1ibi2CZ+34+fY5g5aUrgiQHWQbAaHF089s6F2YKZw8w@mail.gmail.com>
From: "jrrandall@gmail.com" <jrrandall@gmail.com>
Date: Wed, 4 Apr 2012 11:27:11 -0400
Message-ID: <CAFtv-6YZNF57Nr5mkXM5aevQdXsmy8sOjGhLJfvP=zAEa1CTgA@mail.gmail.com>
Subject: Re: Expanding aliases to full command before execution
To: bug-bash@gnu.org
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 04 Apr 2012 15:28:00 -0000

On Tue, Apr 3, 2012 at 5:22 PM, jrrandall@gmail.com <jrrandall@gmail.com> w=
rote:
> Hi everyone,
>
> In bash, is it possible to expand my aliases either before they are execu=
ted
> or when they are stored in the history file?
> For example, if I have:=A0 alias ll=3D'ls -l'=A0 defined in my .bashrc, w=
hen I
> execute "ll" from the command line, I'd like my history file to contain "=
ls
> -l".=A0 Is there any way to accomplish this?
>
> Thanks,
> Justin
>

I seem to have constructed a solution to my own problem.  I wrote a
function that creates the desired behavior for me and saves it in
$expanded if the argument was in fact an alias.

function expand_alias()                 # expand an alias to full command
{
    if [ "$1" =3D "." ]; then
        argument=3D"\\$1"
    else
        argument=3D"$1"
    fi
    match=3D$( alias -p | grep -w "alias $argument=3D" )
    if [ -n "$match" ]; then
        expanded=3D"`echo $match | sed -e s/[^=3D]*=3D// | sed 's/^.\(.*\).=
$/\1/'`"
    else
        expanded=3D"$1"
    fi
}


Thanks,
Justin


From MAILER-DAEMON Wed Apr 04 18:17:25 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SFYW5-0006he-QI
	for mharc-bug-bash@gnu.org; Wed, 04 Apr 2012 18:17:25 -0400
Received: from eggs.gnu.org ([208.118.235.92]:54852)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SFYVu-0006d9-1i
	for bug-bash@gnu.org; Wed, 04 Apr 2012 18:17:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SFYVl-0004om-N9
	for bug-bash@gnu.org; Wed, 04 Apr 2012 18:17:11 -0400
Received: from fmmailgate06.web.de ([217.72.192.247]:45929)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SFYVl-0004nh-EF
	for bug-bash@gnu.org; Wed, 04 Apr 2012 18:17:05 -0400
Received: from moweb001.kundenserver.de (moweb001.kundenserver.de
	[172.19.20.114])
	by fmmailgate06.web.de (Postfix) with ESMTP id 6C08710AD389
	for <bug-bash@gnu.org>; Wed,  4 Apr 2012 21:12:38 +0200 (CEST)
Received: from [192.168.178.49] ([93.134.83.65]) by smtp.web.de (mrweb002)
	with ESMTPA (Nemesis) id 0M5woT-1SQglW2lPV-00xtL5;
	Wed, 04 Apr 2012 21:12:36 +0200
Message-ID: <4F7C9D21.1030501@web.de>
Date: Wed, 04 Apr 2012 21:12:33 +0200
From: dethrophes <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: Expanding aliases to full command before execution
References: <CAFtv-6b1ibi2CZ+34+fY5g5aUrgiQHWQbAaHF089s6F2YKZw8w@mail.gmail.com>
	<CAFtv-6YZNF57Nr5mkXM5aevQdXsmy8sOjGhLJfvP=zAEa1CTgA@mail.gmail.com>
In-Reply-To: <CAFtv-6YZNF57Nr5mkXM5aevQdXsmy8sOjGhLJfvP=zAEa1CTgA@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:pZaObk7DvEzWFCvJAArfzUarTyjm/dLy+MmjfYq6OUo
	p/bkXkjDSs13n/DGpAx4lr737RUIrweNR9J5MC7piVSnoUh30i
	jiAq8m2F1pTaIX6LWC0pyZiv0m6gct6MIkM9TWJfGEpnNTUGMQ
	E84TELwfSXc0lXllCub1HyOejCXpkbmSKMplZ0e91QcsgCKfEP
	ScoJMjhfOTQ/k5/KFPSaA==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.247
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 04 Apr 2012 22:17:23 -0000

Am 04.04.2012 17:27, schrieb jrrandall@gmail.com:
> On Tue, Apr 3, 2012 at 5:22 PM, jrrandall@gmail.com<jrrandall@gmail.com>  wrote:
>> Hi everyone,
>>
>> In bash, is it possible to expand my aliases either before they are executed
>> or when they are stored in the history file?
>> For example, if I have:  alias ll='ls -l'  defined in my .bashrc, when I
>> execute "ll" from the command line, I'd like my history file to contain "ls
>> -l".  Is there any way to accomplish this?
>>
>> Thanks,
>> Justin
>>
> I seem to have constructed a solution to my own problem.  I wrote a
> function that creates the desired behavior for me and saves it in
> $expanded if the argument was in fact an alias.
>
> function expand_alias()                 # expand an alias to full command
> {
>      if [ "$1" = "." ]; then
>          argument="\\$1"
>      else
>          argument="$1"
>      fi
>      match=$( alias -p | grep -w "alias $argument=" )
>      if [ -n "$match" ]; then
>          expanded="`echo $match | sed -e s/[^=]*=// | sed 's/^.\(.*\).$/\1/'`"
>      else
>          expanded="$1"
>      fi
> }
>
>
> Thanks,
> Justin
>
or you could just do

function expand_alias()                 # expand an alias to full command
{
     if expanded=$( alias "${1}" ); then
         expanded="${expanded#*=}"
     else
         expanded="$1"
     fi
}

though depending on what your actually trying to do you'd be getter of 
using type, as not all aliases are aliases a lot are functions these days.



     case $(type -t "$c") in
       "")
         echo No such command "$c"
         return 127
         ;;
       alias)
         c="$(type "$c"|sed "s/^.* to \`//;s/.$//")"
         ;;
       function)
         c=$(type "$c"|sed 1d)";\"$c\""
         ;;
       *)
         c="\"$c\""
         ;;
     esac

bash -xvc "$c"


From MAILER-DAEMON Wed Apr 04 19:08:34 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SFZJa-0004il-5t
	for mharc-bug-bash@gnu.org; Wed, 04 Apr 2012 19:08:34 -0400
Received: from eggs.gnu.org ([208.118.235.92]:46256)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SFZJT-0004hT-Lz
	for bug-bash@gnu.org; Wed, 04 Apr 2012 19:08:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SFZJM-0000Ov-KH
	for bug-bash@gnu.org; Wed, 04 Apr 2012 19:08:27 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:47280
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SFZJM-0000Ny-3S
	for bug-bash@gnu.org; Wed, 04 Apr 2012 19:08:20 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q34N84DQ024294; Wed, 4 Apr 2012 16:08:06 -0700
Message-ID: <4F7CD454.2090104@tlinx.org>
Date: Wed, 04 Apr 2012 16:08:04 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: "jrrandall@gmail.com" <jrrandall@gmail.com>
Subject: Re: Expanding aliases to full command before execution
References: <CAFtv-6b1ibi2CZ+34+fY5g5aUrgiQHWQbAaHF089s6F2YKZw8w@mail.gmail.com>
	<CAFtv-6YZNF57Nr5mkXM5aevQdXsmy8sOjGhLJfvP=zAEa1CTgA@mail.gmail.com>
In-Reply-To: <CAFtv-6YZNF57Nr5mkXM5aevQdXsmy8sOjGhLJfvP=zAEa1CTgA@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 04 Apr 2012 23:08:32 -0000



jrrandall@gmail.com wrote:

> function expand_alias()                 # expand an alias to full command
> {
>     if [ "$1" = "." ]; then
>         argument="\\$1"
>     else
>         argument="$1"
>     fi
>     match=$( alias -p | grep -w "alias $argument=" )
>     if [ -n "$match" ]; then
>         expanded="`echo $match | sed -e s/[^=]*=// | sed 's/^.\(.*\).$/\1/'`"
>     else
>         expanded="$1"
>     fi
> }
---

I could see this being an option, because I can think of times I might want one 
or the other...

I might want to know exactly what I typed, (if only to remind me to use an alias 
for some long string and save on RSHP (Repetitive-Stress Hit-Points);

But at the same time it would be useful to know what alias(es) were in effect
at the time... (if only the alias was listed!)

so maybe a literal version, followed by (for lines that were 'expanded' by:

	"[" <literal expansion> "]"

Of course the same problem arises with 'functions' as they are said to replace 
aliases in _almost_ every situation.  I.e. do you really want your history file
to be different depending on whether you did
	alias ll=ls\ -l
or
	function ll { ls -l "$@"}
??
Wouldn't they have a similar effect on the accuracy of your record?

Of course, then my idea of literal expansion would get very messy... providing
a practical reason to not do it for functions... (depends on what your 
requirements are )... ;-)






From MAILER-DAEMON Wed Apr 04 19:26:41 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SFZb7-0001YM-Q0
	for mharc-bug-bash@gnu.org; Wed, 04 Apr 2012 19:26:41 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58019)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SFZaw-0001Uq-EF
	for bug-bash@gnu.org; Wed, 04 Apr 2012 19:26:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SFZaq-00052Z-I0
	for bug-bash@gnu.org; Wed, 04 Apr 2012 19:26:29 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:47384
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SFZaq-00052A-1o
	for bug-bash@gnu.org; Wed, 04 Apr 2012 19:26:24 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q34NQGhS031728 for <bug-bash@gnu.org>; Wed, 4 Apr 2012 16:26:18 -0700
Message-ID: <4F7CD898.5020204@tlinx.org>
Date: Wed, 04 Apr 2012 16:26:16 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: weird behavior of set -e
References: <mailman.356.1308940515.785.bug-bash@gnu.org>
	<4e0528b7$0$6545$3ca0ca56@newsspool4.vodafone-ip.de>
In-Reply-To: <4e0528b7$0$6545$3ca0ca56@newsspool4.vodafone-ip.de>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-bash@gnu.org
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, 04 Apr 2012 23:26:40 -0000



mhenn wrote:

> Am 24.06.2011 11:51, schrieb Harald Dunkel:
>> Hi folks,
>>
>> A colleague pointed me to this problem: If I run
>> 	( set -e; ( false; echo x ) )
>> in bash 4.1.5, then there is no screen output, as
>> expected. If I change this to
>> 	( set -e; ( false; echo x ) || echo y )
>> then I get "x" instead of "y". How comes?
>> Any helpful comment would be highly appreciated.
>>
>> Harri
>>
> 
> Hey Harald,
> Thus, "false" is executed, but the command sequence is not cancelled
> because of the "||". Then, after the ";" "echo x" is executed, which
> gives a 0 exit status, which leads to "echo y" never to be executed
> because of evaluation shortcut of "||". For this, see also:
> 	
> 	man bash | less -p 'The \&\&'

---

	Has this behavior changed in more recent versions?

The above description seems to be rather non-intuitive, given that ( ) should
mean it is evaluated in a sub-shell process, -- thus whether or not it aborts
after 'false', should be independent of the context.

If it was (set -e; { false ; echo x;} || echo y )
Then I could see {} being a type of parenthesis that allows evaluation
linearly, in the same process and would honor such dependencies.

Or is it the case that the "false;echo x", isn't executed in it's own separate 
process?

Of course who knows what it does now with the seeming concerted effort to kill
any use or usefulness for the -e switch...(sigh)...

perl has -w and use strict;  If you don't want -e to do it, maybe the 
"language"** should offer alternatives.

**-- I suppose that's the rub -- is it a language as in programming language,
or is it just supposed to be for the most primitive scripting needs.
Adding integers, arrays and hashes sure makes it seem more like a language than
the latter.








From MAILER-DAEMON Thu Apr 05 08:13:10 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SFlYs-0001kz-75
	for mharc-bug-bash@gnu.org; Thu, 05 Apr 2012 08:13:10 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59006)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SFlYn-0001j4-7z
	for bug-bash@gnu.org; Thu, 05 Apr 2012 08:13:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SFlYi-000177-KA
	for bug-bash@gnu.org; Thu, 05 Apr 2012 08:13:04 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:47306
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SFlYi-00016n-DP
	for bug-bash@gnu.org; Thu, 05 Apr 2012 08:13:00 -0400
Received: (qmail 11100 invoked from network); 5 Apr 2012 12:12:57 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Thu, 05 Apr 2012 08:12:57 -0400
Received: (qmail 5204 invoked by uid 563); 5 Apr 2012 12:12:56 -0000
Date: Thu, 5 Apr 2012 08:12:56 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Linda Walsh <bash@tlinx.org>
Subject: Re: Expanding aliases to full command before execution
Message-ID: <20120405121256.GX22241@eeg.ccf.org>
References: <CAFtv-6b1ibi2CZ+34+fY5g5aUrgiQHWQbAaHF089s6F2YKZw8w@mail.gmail.com>
	<CAFtv-6YZNF57Nr5mkXM5aevQdXsmy8sOjGhLJfvP=zAEa1CTgA@mail.gmail.com>
	<4F7CD454.2090104@tlinx.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F7CD454.2090104@tlinx.org>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 05 Apr 2012 12:13:09 -0000

On Wed, Apr 04, 2012 at 04:08:04PM -0700, Linda Walsh wrote:
> 	function ll { ls -l "$@"}

Just for the record, a one-line function definition requires a ; before
the closing curly brace.

  ll() { ls -l "$@";}


From MAILER-DAEMON Thu Apr 05 15:19:51 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SFsDn-0006fT-U8
	for mharc-bug-bash@gnu.org; Thu, 05 Apr 2012 15:19:51 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55340)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SFsDg-0006fK-T6
	for bug-bash@gnu.org; Thu, 05 Apr 2012 15:19:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SFsDc-0001ZI-1P
	for bug-bash@gnu.org; Thu, 05 Apr 2012 15:19:42 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:15375)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SFsDb-0001Ww-TA
	for bug-bash@gnu.org; Thu, 05 Apr 2012 15:19:39 -0400
Received: from mpv6.cwru.edu (mpv6.tis.CWRU.Edu [129.22.104.221])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJQ65941;
	Thu, 5 Apr 2012 15:19:36 -0400
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AVF00255 (AUTH cpr);
	Thu, 05 Apr 2012 15:19:36 -0400 (EDT)
Message-ID: <4F7DF048.3070304@case.edu>
Date: Thu, 05 Apr 2012 15:19:36 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Yichao Yu <yyc1992@gmail.com>
Subject: Re: COMP_POINT is not set correctly when there is non-ascii characters
	in the command line.
References: <20120322225955.67DB94004E@yyc.yyc-arch.org>
	<4F72002A.5080306@case.edu>
	<CAMvDr+R1TEOj5dr4hpvc75wpL9mTBv6Eiey=tCPKQSzLi1Ov2Q@mail.gmail.com>
	<4F73CD9B.6060001@case.edu>
	<CAMvDr+SXNYSTj68myFx6VVtNBe0Czs95y-ofikEDZQqPjUENeA@mail.gmail.com>
In-Reply-To: <CAMvDr+SXNYSTj68myFx6VVtNBe0Czs95y-ofikEDZQqPjUENeA@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 05 Apr 2012 19:19:51 -0000

On 3/28/12 11:11 PM, Yichao Yu wrote:

>> Pretty much everything else in bash uses characters, which may be bytes
>> depending on the locale.
>>
>> Can someone who's more familiar with the bash completion package tell me
>> whether or not it uses COMP_POINT at all?  That's about that only thing
>> I can think of that would use it.
> 
> It DOES use COMP_POINT. And this is the most annoy thing and also how
> I notice the issue. I reported a bug for bash-completion here
> (https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=313583&group_id=100114)
> and soon discovered this is a bush issue.

Yep, it seems pretty clear that the appropriate fix is to make COMP_POINT
a locale-aware character count rather than a locale-independent byte
count.

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


From MAILER-DAEMON Fri Apr 06 20:38:40 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGJfr-0002ei-VQ
	for mharc-bug-bash@gnu.org; Fri, 06 Apr 2012 20:38:39 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53011)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGJfp-0002eb-JJ
	for bug-bash@gnu.org; Fri, 06 Apr 2012 20:38:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGJfo-0000FI-3u
	for bug-bash@gnu.org; Fri, 06 Apr 2012 20:38:37 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:55794
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGJfn-0000FE-8L
	for bug-bash@gnu.org; Fri, 06 Apr 2012 20:38:36 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q370cSw5028878 for <bug-bash@gnu.org>; Fri, 6 Apr 2012 17:38:30 -0700
Message-ID: <4F7F8C84.9050203@tlinx.org>
Date: Fri, 06 Apr 2012 17:38:28 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: Expanding aliases to full command before execution
References: <CAFtv-6b1ibi2CZ+34+fY5g5aUrgiQHWQbAaHF089s6F2YKZw8w@mail.gmail.com>	<CAFtv-6YZNF57Nr5mkXM5aevQdXsmy8sOjGhLJfvP=zAEa1CTgA@mail.gmail.com>	<4F7CD454.2090104@tlinx.org>
	<20120405121256.GX22241@eeg.ccf.org>
In-Reply-To: <20120405121256.GX22241@eeg.ccf.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 07 Apr 2012 00:38:38 -0000



Greg Wooledge wrote:

> On Wed, Apr 04, 2012 at 04:08:04PM -0700, Linda Walsh wrote:
>> 	function ll { ... }
> 
> Just for the record, a one-line function definition requires a ; before
> the closing curly brace.
> 
>   ll() { ls -l "$@";}
> 

---

Can you say 'irrelevant detail'?

I was discussing an idea -- not focusing on details of syntax.
Are you also correcting people's spelling -- "for the record"?

If this was to be a reference for a record -- an audience I didn't write
for, then you screwed up. It is not true that you must have a semicolon
before the closing curly brace.   An ampersand will do just as well  if one
wants to use such.









From MAILER-DAEMON Sat Apr 07 16:00:42 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGboQ-0003NT-A2
	for mharc-bug-bash@gnu.org; Sat, 07 Apr 2012 16:00:42 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49520)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SGboN-0003Mw-T4
	for bug-bash@gnu.org; Sat, 07 Apr 2012 16:00:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SGboL-0007JN-Vd
	for bug-bash@gnu.org; Sat, 07 Apr 2012 16:00:39 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:33132)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SGboL-0007JI-MJ
	for bug-bash@gnu.org; Sat, 07 Apr 2012 16:00:37 -0400
Received: by bkwq16 with SMTP id q16so3164102bkw.0
	for <bug-bash@gnu.org>; Sat, 07 Apr 2012 13:00:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=FOzrPY4zF7bRwDEyNqBBswx+eKyTKdnIjORmW87vpOE=;
	b=hDPcShyQDKhOinv1nXvKmUtgtVHXamw96UyVa2aR75l2ucSLYk0HBThH29NzXamf5u
	qPiuIrJ0Vj14CcO1kuhGdTdnXJ9HxopGEUTTQm5if2cu+GD69gQWfertHZwUfb+C8meh
	lgwRtGALofLYW8LkBVbsjHypa2avzX+xyACAHmQ7209iJvD7YeuBMqcFo5f7LkWs67Hq
	O9bT4KAonBM3p0SsBB07dV2yI73pqCyqgiI/Ul9KJPAHRuea8e3h5eC8ep7XzlUR3+EL
	fGyZEoqfDsCojz2SbO4nEzTKFJYDFzvDxy7/cP/Ok86h/61vQ1lGpMg6vKOx7uia66UA
	uHCw==
MIME-Version: 1.0
Received: by 10.205.139.77 with SMTP id iv13mr956952bkc.91.1333828834974; Sat,
	07 Apr 2012 13:00:34 -0700 (PDT)
Received: by 10.204.170.196 with HTTP; Sat, 7 Apr 2012 13:00:34 -0700 (PDT)
Date: Sat, 7 Apr 2012 14:00:34 -0600
Message-ID: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
Subject: semicolon at beginning of line
From: Elliott Forney <elliott.forney@gmail.com>
To: bug-bash@gnu.org
Content-Type: text/plain; charset=ISO-8859-1
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 07 Apr 2012 20:00:41 -0000

I wish bash would happily execute lines that begin with a semicolon,
i.e., treat it as a no-op followed by a command.  The following
examples come to mind:

$ infloop& echo hello
[2] 11361
hello
$ infloop&; echo hello
bash: syntax error near unexpected token `;'

$ echo hello; echo world
hello
world
$ echo hello;; echo world
bash: syntax error near unexpected token `;;'

$ ; echo hello world
bash: syntax error near unexpected token `;'

Any thoughts?

Thanks,
  Elliott Forney


From MAILER-DAEMON Sat Apr 07 16:38:52 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGcPM-0007O6-B3
	for mharc-bug-bash@gnu.org; Sat, 07 Apr 2012 16:38:52 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56675)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGcPJ-0007Ny-Rp
	for bug-bash@gnu.org; Sat, 07 Apr 2012 16:38:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGcPI-00088F-7D
	for bug-bash@gnu.org; Sat, 07 Apr 2012 16:38:49 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:48001
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGcPH-00087t-Hr
	for bug-bash@gnu.org; Sat, 07 Apr 2012 16:38:48 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q37KceLu013301 for <bug-bash@gnu.org>; Sat, 7 Apr 2012 13:38:43 -0700
Message-ID: <4F80A5D0.60905@tlinx.org>
Date: Sat, 07 Apr 2012 13:38:40 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: semicolon at beginning of line
References: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
In-Reply-To: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 07 Apr 2012 20:38:51 -0000



Elliott Forney wrote:

> I wish bash would happily execute lines that begin with a semicolon,
> i.e., treat it as a no-op followed by a command.  The following
> examples come to mind:
> 
> $ infloop& echo hello 
> hello 
> $ infloop&; echo hello
> bash: syntax error near unexpected token `;'
> $ echo hello; echo world
> hello       ; > world
> $ echo hello;; echo world
> bash: syntax error near unexpected token `;;' ***
> $ ; echo hello world
> bash: syntax error near unexpected token `;'
> 
> Any thoughts?

---

I like it (which probably isn't good with this crowd) -- but I think
the case I marked with *** could be more challenging -- since ;; is a
language token closing ")" in a case statement.  But other than that,
a semi-colon being a substitute for a "\n", when it would
otherwise return a "semi-colon unexpected" message seems reasonable --
at least in non-posix mode (posix may require it...can't do anything
'different' there or risk incompats)

If it needs a value, a semi-colon wouldn't be a substitute for a value any
more than a newline, so

   while;do;done

wouldn't be expected to work as you need a statement after 'while' and 'done' to 
be eval'ed.

I've often wondered why it wasn't that way myself, but assumed I'd be told "it 
just has to be that way, because....xxyz" (posix, or parser or something...).. 
it makes too much sense not to do it for it not to have been done already..

Linda
(oft' resident contrarian)









From MAILER-DAEMON Sat Apr 07 16:46:04 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGcWK-0008DT-7h
	for mharc-bug-bash@gnu.org; Sat, 07 Apr 2012 16:46:04 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53454)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGcWH-0008Cy-Uv
	for bug-bash@gnu.org; Sat, 07 Apr 2012 16:46:03 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGcWG-0001hY-9n
	for bug-bash@gnu.org; Sat, 07 Apr 2012 16:46:01 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:48157
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGcWF-0001hH-JW
	for bug-bash@gnu.org; Sat, 07 Apr 2012 16:46:00 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q37Kjser020847 for <bug-bash@gnu.org>; Sat, 7 Apr 2012 13:45:57 -0700
Message-ID: <4F80A783.6040900@tlinx.org>
Date: Sat, 07 Apr 2012 13:45:55 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: status on $[arith] for eval arith vsl $((arith))??
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 07 Apr 2012 20:46:03 -0000




In modifying some released code on my distro,    I ran into the 
extensive use
of   $[arith]  as a means for returning arithmetic evaluations of the 
expression.

I vaguely remember something like that from years ago, but never see any 
reference to
it -- yet it works, and old code seems to rely on it -- and
"$[(1+2)/3]"  looks cleaner than "$(((1+2)/3))".  So what's up with that?

If it wasn't designed to run in non-bash environments, I might think it was
an artifact of array evaluation..  I.e. with no array name after $, 
instead of that
number being used as an index for the array, it's returned as a raw 
value...  but
I've seen it in code designed for 'sh'...

Is it an accidental omission from the bash manpage?







From MAILER-DAEMON Sat Apr 07 17:09:10 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGcsg-0001e0-Ia
	for mharc-bug-bash@gnu.org; Sat, 07 Apr 2012 17:09:10 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37872)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SGcsd-0001dr-Q4
	for bug-bash@gnu.org; Sat, 07 Apr 2012 17:09:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SGcsc-0006He-0j
	for bug-bash@gnu.org; Sat, 07 Apr 2012 17:09:07 -0400
Received: from smtp.gentoo.org ([140.211.166.183]:37630)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SGcsb-0006HO-Qv
	for bug-bash@gnu.org; Sat, 07 Apr 2012 17:09:05 -0400
Received: from vapier.localnet (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id 161021B401D;
	Sat,  7 Apr 2012 21:09:04 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: bug-bash@gnu.org
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
Date: Sat, 7 Apr 2012 17:09:15 -0400
User-Agent: KMail/1.13.7 (Linux/3.4.0-rc1; KDE/4.6.5; x86_64; ; )
References: <4F80A783.6040900@tlinx.org>
In-Reply-To: <4F80A783.6040900@tlinx.org>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart1483573.847BlxcvB3";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
Message-Id: <201204071709.16151.vapier@gentoo.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 140.211.166.183
Cc: Linda Walsh <bash@tlinx.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 07 Apr 2012 21:09:09 -0000

--nextPart1483573.847BlxcvB3
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit

On Saturday 07 April 2012 16:45:55 Linda Walsh wrote:
> Is it an accidental omission from the bash manpage?

it's in the man page.  read the "Arithmetic Expansion" section.
-mike

--nextPart1483573.847BlxcvB3
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJPgKz8AAoJEEFjO5/oN/WBLGkP/2y7mk3UeDO2rMYkpbfYT1FU
Nexr7w6v8FwNQxB3+1qiCNsVB+uhMsxOdIVZFTMvDP1casbcMGFcSv+Ooz8L+h2D
25azS0UvliVIBKJdyTzuvMb0HGJ8orJ2OQlVn6NSl5fk3tVrgszzo8rUFJvjcY4G
RR+M8vH5qj+7DL5La77KCQgigJQ1IrIQbd2ycIS6zgO0RSci8ahsq14yieDeAls5
DAsUWH2ne1yo4UTXi3nW2YORI8u8LeUzW7FxXKjBUgZjHevdoNL8Q66+l53ObqZT
rkrUxfvUnzsyyHIooNfUlGZD9e6IklbA3pm/eA0i7wdiwTZ9deeUszBAm/paYrYX
i838/EHV0ZdCamka4q+CblLqhjoXRV2xW75q3O7NjdkFUEfXgKVZbVcOozSJCDTV
kKNWPUXLgZhNXqA9ZYXyU1qJc6BpVI3vXmlAdZGXC/IQ3BrcfiiphYsc3PAVX5tk
HO9wBr1UYkJJww2mknD96dkwLM/3MxSBUkCq07pFSuS5HX9XTND5uaddHHOOFD/o
Uc9bl1myELN6FUfH5YYil12QoP95P41rmpwtSMaL2KFc8CYbJ2dTEycDkQuqCh1m
LOOO+BuRrtR0Z6IC3gsNh6qwj9ixBzseTuL0Hyf2TIu2AQtU+iKRevMNEdEZk9HX
Dm5gj5yG5bvtJkfN9hLC
=mq0d
-----END PGP SIGNATURE-----

--nextPart1483573.847BlxcvB3--


From MAILER-DAEMON Sat Apr 07 17:50:36 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGdWl-0006pq-W8
	for mharc-bug-bash@gnu.org; Sat, 07 Apr 2012 17:50:35 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55341)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGdWj-0006pA-ID
	for bug-bash@gnu.org; Sat, 07 Apr 2012 17:50:34 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGdWh-0007E3-Rm
	for bug-bash@gnu.org; Sat, 07 Apr 2012 17:50:33 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:49134
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SGdWg-0007Dy-Oy
	for bug-bash@gnu.org; Sat, 07 Apr 2012 17:50:31 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q37LoH2r008820; Sat, 7 Apr 2012 14:50:19 -0700
Message-ID: <4F80B699.8040502@tlinx.org>
Date: Sat, 07 Apr 2012 14:50:17 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Mike Frysinger <vapier@gentoo.org>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <201204071709.16151.vapier@gentoo.org>
In-Reply-To: <201204071709.16151.vapier@gentoo.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 07 Apr 2012 21:50:34 -0000



Mike Frysinger wrote:

> On Saturday 07 April 2012 16:45:55 Linda Walsh wrote:
>> Is it an accidental omission from the bash manpage?
> 
> it's in the man page.  read the "Arithmetic Expansion" section.
> -mike


====
My 4.2 manpage says:

    Arithmetic Expansion
        Arithmetic  expansion allows the evaluation of an arithmetic expression
        and the substitution of the result.  The format for  arithmetic  expan-
        sion is:

               $((expression))

        The  expression  is  treated  as if it were within double quotes, but a
        double quote inside the parentheses  is  not  treated  specially.   All
        tokens in the expression undergo parameter expansion, string expansion,
        command substitution, and quote removal.  Arithmetic expansions may  be
        nested.

        The  evaluation  is performed according to the rules listed below under
        ARITHMETIC EVALUATION.  If expression is invalid, bash prints a message
        indicating failure and no substitution occurs.

----------
No mention of square brackets.

What's yours say?




From MAILER-DAEMON Sat Apr 07 18:02:45 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGdiW-0007q7-Vk
	for mharc-bug-bash@gnu.org; Sat, 07 Apr 2012 18:02:44 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52824)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SGdiU-0007q1-5a
	for bug-bash@gnu.org; Sat, 07 Apr 2012 18:02:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SGdiR-0001IB-Rx
	for bug-bash@gnu.org; Sat, 07 Apr 2012 18:02:41 -0400
Received: from mail-iy0-f169.google.com ([209.85.210.169]:49815)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SGdiR-0001Ho-Jy
	for bug-bash@gnu.org; Sat, 07 Apr 2012 18:02:39 -0400
Received: by iajr24 with SMTP id r24so5586571iaj.0
	for <bug-bash@gnu.org>; Sat, 07 Apr 2012 15:02:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type:content-transfer-encoding;
	bh=nSiDZ6H4wYykA/jo2c7fX6MfEG6exjx2fRWiIV63Wo8=;
	b=TU0UFB37xkRq+R7tIU0qCqJTuueLaUX11attNB59Pj4COMTn5DHyjL1zvTiyHrp8Vb
	UqwTlnOwnjt1eyY3Djv15TPR3qEiXkzxSwmWtt7oSg9wXPARi2I73xolC2bRdiseVxSN
	fKqtsgi/1xe/fYic2W7zALzzDLQ8j/yjFIz3dbE8yrG0X+jyrweho5lK2Cf4l3+37XTC
	5rnpPGje+kTAEaraNsILZN6gtdozHTr8RTAllhkXaO+9lUD74S7kXYMGX19CT6g2tFTJ
	Uxk4AenuQi1thDiWzhrswnGXCeFTnE7jk/8/hmSKBc/+d/mE7DEnn9Hit3i/XDhe/pmf
	E5Pg==
Received: by 10.50.153.198 with SMTP id vi6mr1676429igb.0.1333836156783; Sat,
	07 Apr 2012 15:02:36 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.42.28.71 with HTTP; Sat, 7 Apr 2012 15:02:16 -0700 (PDT)
In-Reply-To: <4F80B699.8040502@tlinx.org>
References: <4F80A783.6040900@tlinx.org> <201204071709.16151.vapier@gentoo.org>
	<4F80B699.8040502@tlinx.org>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Sun, 8 Apr 2012 01:02:16 +0300
Message-ID: <CAPSX3sTXOx3LdoSoZ7KXRTfCwJVjOUfvsBifYGCZa7inT-BEGQ@mail.gmail.com>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
To: Linda Walsh <bash@tlinx.org>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.210.169
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 07 Apr 2012 22:02:43 -0000

On Sun, Apr 8, 2012 at 12:50 AM, Linda Walsh <bash@tlinx.org> wrote:
>
>
> Mike Frysinger wrote:
>
>> On Saturday 07 April 2012 16:45:55 Linda Walsh wrote:
>>>
>>> Is it an accidental omission from the bash manpage?
>>
>>
>> it's in the man page. =A0read the "Arithmetic Expansion" section.
>> -mike
>
>
>
> =3D=3D=3D=3D
> My 4.2 manpage says:
>
> =A0 Arithmetic Expansion
> =A0 =A0 =A0 Arithmetic =A0expansion allows the evaluation of an arithmeti=
c
> expression
> =A0 =A0 =A0 and the substitution of the result. =A0The format for =A0arit=
hmetic
> =A0expan-
> =A0 =A0 =A0 sion is:
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0$((expression))
>
> =A0 =A0 =A0 The =A0expression =A0is =A0treated =A0as if it were within do=
uble quotes, but
> a
> =A0 =A0 =A0 double quote inside the parentheses =A0is =A0not =A0treated =
=A0specially.
> All
> =A0 =A0 =A0 tokens in the expression undergo parameter expansion, string
> expansion,
> =A0 =A0 =A0 command substitution, and quote removal. =A0Arithmetic expans=
ions may
> =A0be
> =A0 =A0 =A0 nested.
>
> =A0 =A0 =A0 The =A0evaluation =A0is performed according to the rules list=
ed below
> under
> =A0 =A0 =A0 ARITHMETIC EVALUATION. =A0If expression is invalid, bash prin=
ts a
> message
> =A0 =A0 =A0 indicating failure and no substitution occurs.
>
> ----------
> No mention of square brackets.
>
> What's yours say?
>
Some linux distributions patch the man page and document $[ ] as deprecated=
.

The SUS rationale says:

In early proposals, a form $[expression] was used. It was functionally
equivalent to the "$(())" of the current text, but objections were
lodged that the 1988 KornShell had already implemented "$(())" and
there was no compelling reason to invent yet another syntax.
Furthermore, the "$[]" syntax had a minor incompatibility involving
the patterns in case statements.


From MAILER-DAEMON Sat Apr 07 19:47:22 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGfLm-0000kb-K1
	for mharc-bug-bash@gnu.org; Sat, 07 Apr 2012 19:47:22 -0400
Received: from eggs.gnu.org ([208.118.235.92]:40389)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SGfLj-0000iV-BK
	for bug-bash@gnu.org; Sat, 07 Apr 2012 19:47:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SGfLh-00074S-F9
	for bug-bash@gnu.org; Sat, 07 Apr 2012 19:47:18 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:40502)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SGfLh-00074F-Ae
	for bug-bash@gnu.org; Sat, 07 Apr 2012 19:47:17 -0400
Received: from mpv8.case.edu (mpv8.tis.cwru.edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJR85042;
	Sat, 7 Apr 2012 19:47:14 -0400
Received: from static-acs-24-239-96-141.zoominternet.net (EHLO z4.local)
	([24.239.96.141]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TKJ18254 (AUTH cpr);
	Sat, 07 Apr 2012 19:47:14 -0400 (EDT)
Message-ID: <4F80D201.6010308@case.edu>
Date: Sat, 07 Apr 2012 19:47:13 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Linda Walsh <bash@tlinx.org>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org>
In-Reply-To: <4F80A783.6040900@tlinx.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash <bug-bash@gnu.org>, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 07 Apr 2012 23:47:20 -0000

On 4/7/12 4:45 PM, Linda Walsh wrote:
> 
> 
> 
> In modifying some released code on my distro,    I ran into the extensive use
> of   $[arith]  as a means for returning arithmetic evaluations of the
> expression.
> 
> I vaguely remember something like that from years ago, but never see any
> reference to
> it -- yet it works, and old code seems to rely on it -- and
> "$[(1+2)/3]"  looks cleaner than "$(((1+2)/3))".  So what's up with that?

It dates from Posix circa 1990 (1003.2d9, of which I've lost my paper
copy).  I implemented it after the Berkeley guys, mostly Marc
Teitelbaum, put it into Posix.  It ended up getting dropped in favor
of the ksh $((...)) expansion, at which point everyone deprecated the
old $[...].  I removed it from the manual sometime later, but it still
works as it always has.

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


From MAILER-DAEMON Sun Apr 08 15:03:07 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGxOF-0000ak-HK
	for mharc-bug-bash@gnu.org; Sun, 08 Apr 2012 15:03:07 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41156)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SGxOC-0000Zh-J0
	for bug-bash@gnu.org; Sun, 08 Apr 2012 15:03:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SGxOA-0000tS-Hr
	for bug-bash@gnu.org; Sun, 08 Apr 2012 15:03:04 -0400
Received: from mail-wi0-f177.google.com ([209.85.212.177]:59513)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SGxOA-0000t5-5R
	for bug-bash@gnu.org; Sun, 08 Apr 2012 15:03:02 -0400
Received: by wibhj13 with SMTP id hj13so1442741wib.12
	for <bug-bash@gnu.org>; Sun, 08 Apr 2012 12:02:59 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=9TNArY4RfOR/Ks30zCOJJuxCu/y9ytM1ndTQrXkx8gs=;
	b=LA81tsabe1MZnN/GyUN4AyBmEgJEi1FH5abhBnAC3zL/KMEWXEri9jvJPM6LSrn9a3
	4rt1Mc5L1Ugw8QYd2m6719lsc5WLRVfOmeKAcJGfOyzTagSxFMkJMRRw/GQcFMkqgVFt
	eqbZzFTEXXvDkJcXG77nnIf0Q0k79J4xw70nM=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=9TNArY4RfOR/Ks30zCOJJuxCu/y9ytM1ndTQrXkx8gs=;
	b=eefqk393oQnni6gAEOkqXvmpaol4nrFiqHcLy0HVv/DTeLmXagTEop4d3KH2bQrhON
	i30A32MwFYqHVar9J5F7E5JOeHxVxc9f4LpyrRTV3qH0C8piObhPaacZOSTswOb453BQ
	S4KIHIe9fjo5IM8rcOrQ1fjMhCJSmlsyk8HWF019qbCHJSCs2Wv33tGyawvcSZUQhnKG
	6Kc9Hs0JTfrKPVZBvuIGXtxr43gQtcxk1lG1yqj25DoA3AR4X0BjT4iQDBtWg7MT602S
	VNN+LwgkBShEBrtEm/JCjGnAqIYFBGbSBPuOptplVkqMCPy7NeX+JwRvsapXm/wePtri
	hKZA==
Received: by 10.216.132.151 with SMTP id o23mr2595815wei.120.1333911779015;
	Sun, 08 Apr 2012 12:02:59 -0700 (PDT)
Received: from [10.9.10.6] (c253.adsl.inet-telecom.org. [83.170.109.115])
	by mx.google.com with ESMTPS id gd4sm39481712wib.6.2012.04.08.12.02.56
	(version=TLSv1/SSLv3 cipher=OTHER);
	Sun, 08 Apr 2012 12:02:57 -0700 (PDT)
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_FCC8222B-8CA8-4834-AD17-31A939B9D275";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <4F80D201.6010308@case.edu>
Date: Sun, 8 Apr 2012 21:02:52 +0200
Message-Id: <40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
To: chet.ramey@case.edu
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQm+RhcBWG9GUUBArFcdXMuXQhk7VmZWcq8LV02/RIM7PXVZGzUf5oVp5vtJqZ0a7JWbmIKC
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.212.177
Cc: Linda Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 08 Apr 2012 19:03:06 -0000


--Apple-Mail=_FCC8222B-8CA8-4834-AD17-31A939B9D275
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=iso-8859-1

On 08 Apr 2012, at 01:47, Chet Ramey wrote:
> On 4/7/12 4:45 PM, Linda Walsh wrote:
>>=20
>>=20
>>=20
>> In modifying some released code on my distro,    I ran into the =
extensive use
>> of   $[arith]  as a means for returning arithmetic evaluations of the
>> expression.
>>=20
>> I vaguely remember something like that from years ago, but never see =
any
>> reference to
>> it -- yet it works, and old code seems to rely on it -- and
>> "$[(1+2)/3]"  looks cleaner than "$(((1+2)/3))".  So what's up with =
that?
>=20
> It dates from Posix circa 1990 (1003.2d9, of which I've lost my paper
> copy).  I implemented it after the Berkeley guys, mostly Marc
> Teitelbaum, put it into Posix.  It ended up getting dropped in favor
> of the ksh $((...)) expansion, at which point everyone deprecated the
> old $[...].  I removed it from the manual sometime later, but it still
> works as it always has.
>=20
> Chet


Any particular reason for not removing old undocumented functionality, =
or is that mostly the nature of this beast - dragging along and =
maintaining ancient code for the sake of compatibility?=

--Apple-Mail=_FCC8222B-8CA8-4834-AD17-31A939B9D275
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDA4MTkwMjUzWjAjBgkqhkiG9w0BCQQx
FgQUpm8vE6FEgE5OTHLLZPwkhHbJvXwwgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGAZsgiMnaf6IHNoELuIvfis2pB
cB6Qf8xlJULn4AdcMt3pR7r1iibtQFSn+32ajjrhXFoJA/bcf67dK6PjI/3JpjxF/N6IH+9H8j4+
4iVlZJPHPsZsqEGWq6d1m15O4bOHMPDZOpuqtkVbUQLNaG6ENrKipOu+FJdnI8pF8eMJdmEAAAAA
AAA=

--Apple-Mail=_FCC8222B-8CA8-4834-AD17-31A939B9D275--


From MAILER-DAEMON Sun Apr 08 15:14:20 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGxZ6-0001XM-MI
	for mharc-bug-bash@gnu.org; Sun, 08 Apr 2012 15:14:20 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34794)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chris@cfajohnson.com>) id 1SGxZ3-0001WU-HS
	for bug-bash@gnu.org; Sun, 08 Apr 2012 15:14:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chris@cfajohnson.com>) id 1SGxZ1-00039b-M4
	for bug-bash@gnu.org; Sun, 08 Apr 2012 15:14:17 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.183]:47055)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chris@cfajohnson.com>) id 1SGxZ1-00034T-HT
	for bug-bash@gnu.org; Sun, 08 Apr 2012 15:14:15 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AicFAKU/KE/O+KG9/2dsb2JhbACBX5x7eYhwnhmGGQSbGYQJ
X-IronPort-AV: E=Sophos;i="4.73,1,1325480400"; 
   d="scan'208";a="172758586"
Received: from 206-248-161-189.dsl.teksavvy.com (HELO linux.local)
	([206.248.161.189])
	by ironport2-out.teksavvy.com with ESMTP; 08 Apr 2012 15:14:12 -0400
Date: Sun, 8 Apr 2012 15:11:45 -0400 (EDT)
From: "Chris F.A. Johnson" <chris@cfajohnson.com>
To: Linda Walsh <bash@tlinx.org>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
In-Reply-To: <4F80A783.6040900@tlinx.org>
Message-ID: <alpine.LMD.2.00.1204081509280.741@localhost.localdomain>
References: <4F80A783.6040900@tlinx.org>
User-Agent: Alpine 2.00 (LMD 1167 2008-08-23)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 206.248.154.183
Cc: bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 08 Apr 2012 19:14:18 -0000

On Sat, 7 Apr 2012, Linda Walsh wrote:

> In modifying some released code on my distro,    I ran into the extensive use
> of   $[arith]  as a means for returning arithmetic evaluations of the 
> expression.
>
> I vaguely remember something like that from years ago, but never see any 
> reference to
> it -- yet it works, and old code seems to rely on it -- and
> "$[(1+2)/3]"  looks cleaner than "$(((1+2)/3))".  So what's up with that?

    At the minor expense of a few extra keystrokes, $(( (1+2) / 3 ))
    looks just as clean, and has the added cachet of being portable.

-- 
    Chris F.A. Johnson, <http://cfajohnson.com/>
    Author:
    Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


From MAILER-DAEMON Sun Apr 08 15:30:53 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGxp7-0002YU-BY
	for mharc-bug-bash@gnu.org; Sun, 08 Apr 2012 15:30:53 -0400
Received: from eggs.gnu.org ([208.118.235.92]:32790)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SGxp4-0002YB-WB
	for bug-bash@gnu.org; Sun, 08 Apr 2012 15:30:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SGxp2-00073I-Vf
	for bug-bash@gnu.org; Sun, 08 Apr 2012 15:30:50 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:22379)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SGxp2-000731-R3
	for bug-bash@gnu.org; Sun, 08 Apr 2012 15:30:48 -0400
Received: from mpv7.case.edu (mpv7.tis.cwru.edu [129.22.104.170])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJS09538;
	Sun, 8 Apr 2012 15:30:46 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TED69420 (AUTH cpr);
	Sun, 08 Apr 2012 15:30:46 -0400 (EDT)
Message-ID: <4F81E765.9040200@case.edu>
Date: Sun, 08 Apr 2012 15:30:45 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Maarten Billemont <lhunath@lyndir.com>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
In-Reply-To: <40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: Linda Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>,
	chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 08 Apr 2012 19:30:52 -0000

On 4/8/12 3:02 PM, Maarten Billemont wrote:

> Any particular reason for not removing old undocumented functionality, or is that mostly the nature of this beast - dragging along and maintaining ancient code for the sake of compatibility?=

Because, as Linda discovered, there is still working code out there using
it.  Maybe we'll get to a point where it's all gone, but we're not there
yet.
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


From MAILER-DAEMON Sun Apr 08 17:23:32 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SGza8-000575-1c
	for mharc-bug-bash@gnu.org; Sun, 08 Apr 2012 17:23:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45597)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SGza5-000565-5u
	for bug-bash@gnu.org; Sun, 08 Apr 2012 17:23:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SGza3-0006nL-EU
	for bug-bash@gnu.org; Sun, 08 Apr 2012 17:23:28 -0400
Received: from fmmailgate06.web.de ([217.72.192.247]:34565)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SGza3-0006nE-82
	for bug-bash@gnu.org; Sun, 08 Apr 2012 17:23:27 -0400
Received: from moweb001.kundenserver.de (moweb001.kundenserver.de
	[172.19.20.114])
	by fmmailgate06.web.de (Postfix) with ESMTP id C63591178067
	for <bug-bash@gnu.org>; Sun,  8 Apr 2012 23:17:33 +0200 (CEST)
Received: from [192.168.178.49] ([93.135.143.40]) by smtp.web.de (mrweb002)
	with ESMTPA (Nemesis) id 0LnSKE-1Rp73b2c0M-00haHI;
	Sun, 08 Apr 2012 23:17:33 +0200
Message-ID: <4F82006C.4070908@web.de>
Date: Sun, 08 Apr 2012 23:17:32 +0200
From: dethrophes <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F81E765.9040200@case.edu>
In-Reply-To: <4F81E765.9040200@case.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:C1Ck8oScI4fNmdQsC28M5pFlNdVAsxhvyeWnXujS7Ui
	7Aq6zFWo4o5jX5Norq1O3dkeoUrR22yfGGT7l3PDCdjoQa8EQA
	A9WiSkObODRV3m0ub5sX1ly+wnFO0r3/fH1zxZGCoqOHM2/gsj
	lbCiXw8Injo2WzX3CIQof2JgtHu7tLVOsbO5TaKd7L8ad9vxqN
	crw7ExaYtGFgQ04zJ2kKQ==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.247
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 08 Apr 2012 21:23:30 -0000

ever thought of going the depreciation route.
Something like what microsoft do with vc.

I.e. give a warning for depreciated constructs. With a hint as to how to 
do it better?

Am 08.04.2012 21:30, schrieb Chet Ramey:
> On 4/8/12 3:02 PM, Maarten Billemont wrote:
>
>> Any particular reason for not removing old undocumented functionality, or is that mostly the nature of this beast - dragging along and maintaining ancient code for the sake of compatibility?=
> Because, as Linda discovered, there is still working code out there using
> it.  Maybe we'll get to a point where it's all gone, but we're not there
> yet.



From MAILER-DAEMON Sun Apr 08 20:46:52 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SH2ku-0001R6-DI
	for mharc-bug-bash@gnu.org; Sun, 08 Apr 2012 20:46:52 -0400
Received: from eggs.gnu.org ([208.118.235.92]:46298)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SH2kr-0001PP-CS
	for bug-bash@gnu.org; Sun, 08 Apr 2012 20:46:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SH2kp-000752-EG
	for bug-bash@gnu.org; Sun, 08 Apr 2012 20:46:48 -0400
Received: from saturn.syslang.net ([207.172.210.41]:50496)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SH2kp-00074Y-9Y
	for bug-bash@gnu.org; Sun, 08 Apr 2012 20:46:47 -0400
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by saturn.syslang.net (8.14.5/8.14.5) with ESMTP id q390khEg025384
	for <bug-bash@gnu.org>; Sun, 8 Apr 2012 20:46:43 -0400
Message-ID: <4F823172.5060803@syslang.net>
Date: Sun, 08 Apr 2012 20:46:42 -0400
From: "Steven W. Orr" <steveo@syslang.net>
Organization: SysLang, Inc.
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
	rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: semicolon at beginning of line
References: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
In-Reply-To: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 207.172.210.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 00:46:50 -0000

On 4/7/2012 4:00 PM, Elliott Forney wrote:
> I wish bash would happily execute lines that begin with a semicolon,
> i.e., treat it as a no-op followed by a command.  The following
> examples come to mind:
>
> $ infloop&  echo hello
> [2] 11361
> hello
> $ infloop&; echo hello
> bash: syntax error near unexpected token `;'
>
> $ echo hello; echo world
> hello
> world
> $ echo hello;; echo world
> bash: syntax error near unexpected token `;;'
>
> $ ; echo hello world
> bash: syntax error near unexpected token `;'
>
> Any thoughts?
>
> Thanks,
>    Elliott Forney

Just use a colon.

: echo Hello world.

I use it all the time to 'park' a command in my history. Then when I'm ready, I 
just back up to it and remove the colon.


-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


From MAILER-DAEMON Sun Apr 08 20:49:03 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SH2n1-0001bO-ML
	for mharc-bug-bash@gnu.org; Sun, 08 Apr 2012 20:49:03 -0400
Received: from eggs.gnu.org ([208.118.235.92]:35031)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jfredett@gmail.com>) id 1SH2my-0001bD-Ep
	for bug-bash@gnu.org; Sun, 08 Apr 2012 20:49:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jfredett@gmail.com>) id 1SH2mw-0007FD-Kj
	for bug-bash@gnu.org; Sun, 08 Apr 2012 20:49:00 -0400
Received: from mail-vb0-f41.google.com ([209.85.212.41]:60755)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jfredett@gmail.com>) id 1SH2mw-0007Et-Cz
	for bug-bash@gnu.org; Sun, 08 Apr 2012 20:48:58 -0400
Received: by vbbey12 with SMTP id ey12so2447415vbb.0
	for <bug-bash@gnu.org>; Sun, 08 Apr 2012 17:48:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=Xhf1YHbpN8bOS+RIR5eaDnKDNNU4GO8dWvfpXOfZZNU=;
	b=BG/GblRfRqFibBO6M8WITVcUz6wuOdnrZUj7uZRQXpSLxWE4G68TrQrVvQLt1V91GY
	Y8L9xZexMO7bup9cysstWFyj3osRhnIyHESB/eA4ynIWD9n6xW7dyAkhwk5+1g+zclMS
	unzBpgR8QcZNLnFFxYZmCvcVPD4Dt7/1fJ9vN6yR0gP7gc6r0DH3u0RO900mIroZaCSA
	PsMKUi4yCApkbGlp8JzTVSs4tGhFEq6TZWdt4hRzXYlN61ZLnuehWH3bkvTEzJDQc2Zw
	PBP7U7xOd4gM5RKxyHXp+qLmciYP/DNHq6k4+bO7V8cTdQMAok+X71d3QWR8wXlPdK5J
	uhmA==
MIME-Version: 1.0
Received: by 10.220.214.4 with SMTP id gy4mr2706838vcb.66.1333932535906; Sun,
	08 Apr 2012 17:48:55 -0700 (PDT)
Received: by 10.220.152.1 with HTTP; Sun, 8 Apr 2012 17:48:55 -0700 (PDT)
In-Reply-To: <4F823172.5060803@syslang.net>
References: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
	<4F823172.5060803@syslang.net>
Date: Sun, 8 Apr 2012 20:48:55 -0400
Message-ID: <CAMZJe54+i7kehHySzsZORkxoPWiWypCo=74Eqb+YW11tWPN0oA@mail.gmail.com>
Subject: Re: semicolon at beginning of line
From: Joseph Fredette <jfredett@gmail.com>
To: "Steven W. Orr" <steveo@syslang.net>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.212.41
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 00:49:02 -0000

Could also use a #, no?

On Sun, Apr 8, 2012 at 8:46 PM, Steven W. Orr <steveo@syslang.net> wrote:

> On 4/7/2012 4:00 PM, Elliott Forney wrote:
>
>> I wish bash would happily execute lines that begin with a semicolon,
>> i.e., treat it as a no-op followed by a command.  The following
>> examples come to mind:
>>
>> $ infloop&  echo hello
>> [2] 11361
>> hello
>> $ infloop&; echo hello
>> bash: syntax error near unexpected token `;'
>>
>> $ echo hello; echo world
>> hello
>> world
>> $ echo hello;; echo world
>> bash: syntax error near unexpected token `;;'
>>
>> $ ; echo hello world
>> bash: syntax error near unexpected token `;'
>>
>> Any thoughts?
>>
>> Thanks,
>>   Elliott Forney
>>
>
> Just use a colon.
>
> : echo Hello world.
>
> I use it all the time to 'park' a command in my history. Then when I'm
> ready, I just back up to it and remove the colon.
>
>
> --
> Time flies like the wind. Fruit flies like a banana. Stranger things have
>  .0.
> happened but none stranger than this. Does your driver's license say Organ
> ..0
> Donor?Black holes are where God divided by zero. Listen to me! We are all-
> 000
> individuals! What if this weren't a hypothetical question?
> steveo at syslang.net
>
>

From MAILER-DAEMON Mon Apr 09 02:57:18 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SH8XO-0006df-P4
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 02:57:18 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49238)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SH8XM-0006dE-5v
	for bug-bash@gnu.org; Mon, 09 Apr 2012 02:57:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SH8XK-0006X7-8W
	for bug-bash@gnu.org; Mon, 09 Apr 2012 02:57:15 -0400
Received: from mail-we0-f169.google.com ([74.125.82.169]:49103)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SH8XJ-0006Vt-SC
	for bug-bash@gnu.org; Mon, 09 Apr 2012 02:57:14 -0400
Received: by werj55 with SMTP id j55so3097256wer.0
	for <bug-bash@gnu.org>; Sun, 08 Apr 2012 23:57:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=su9K7OZvSA3V/W0b81+9Vj0ciYFcAHnqvXCS6lSfCV8=;
	b=dnxzzZN3k+Cpywgk1R2bDvmWo71pQ4Lr8WlLO9acXw83W7l6oHfrG62zyN+r125DEL
	6flA8YEBbb757ileBt+ILFmUPZxd3Sd+lXNp01RXfB5go6BJ6Swz7hVZhjn5+zYueSNl
	u7JokRfwFelMbFrhvPSYR1VXgxh++PmJJ2Qgk=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=su9K7OZvSA3V/W0b81+9Vj0ciYFcAHnqvXCS6lSfCV8=;
	b=CrBYBNwYUqrigz6QMZriRKHlBQKNVqi8UCjnvE9nQaqLkbidEZA3GzJ12N7qFowpZu
	V4mP9W0a5I0t+byUUHknl8LJNe2N+0XrDOce9sbbebBzLidigDDTqx3xu8IpUKJRQLwO
	WUqyZBkav47l/73ga7UJ8wE3p8h0w6ZWQ2jKVFnf2JcpWBJ45YUgcHPn3RC8B7BJFoMs
	steoDs/sJzJN4pUZvK/3kGrr4Ndn8vcPCQQ8IHIdn2156NuwGeq7e1eDPAMclarH/538
	OYZlIt7z372jRWEY+LnEQuwulzmCuHlzvE+EEwLS6Lq149ArFyVSPe8wrSwGS0qVtwou
	Q3iA==
Received: by 10.180.104.137 with SMTP id ge9mr13488971wib.20.1333954631680;
	Sun, 08 Apr 2012 23:57:11 -0700 (PDT)
Received: from [10.9.10.6] (c253.adsl.inet-telecom.org. [83.170.109.115])
	by mx.google.com with ESMTPS id e6sm27851997wix.8.2012.04.08.23.57.09
	(version=TLSv1/SSLv3 cipher=OTHER);
	Sun, 08 Apr 2012 23:57:10 -0700 (PDT)
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_F8FE3354-C59B-419B-A1A9-0B10B63D4833";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <4F81E765.9040200@case.edu>
Date: Mon, 9 Apr 2012 08:57:06 +0200
Message-Id: <1515C608-9949-43E8-ACA5-167D2A4010D6@lyndir.com>
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F81E765.9040200@case.edu>
To: chet.ramey@case.edu
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQkPIoNnxm3du4UVH10xFFhoLT8meoP+qd5ldwfRPtocAGswnm9QE4/MKFFvSlMNHSFemBtN
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 74.125.82.169
Cc: Linda Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 06:57:17 -0000


--Apple-Mail=_F8FE3354-C59B-419B-A1A9-0B10B63D4833
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=iso-8859-1

On 08 Apr 2012, at 21:30, Chet Ramey wrote:
> On 4/8/12 3:02 PM, Maarten Billemont wrote:
>=20
>> Any particular reason for not removing old undocumented =
functionality, or is that mostly the nature of this beast - dragging =
along and maintaining ancient code for the sake of compatibility?=3D
>=20
> Because, as Linda discovered, there is still working code out there =
using
> it.  Maybe we'll get to a point where it's all gone, but we're not =
there
> yet.


IMO, the working code out there that relies on $[...] either runs on =
older versions of bash, or if the sysadmin decided to upgrade bash, he =
can assume the responsibility to fix the code.  I suppose a deprecation =
route would make such a scenario least painful.  Though I don't think =
bash has ever taken this approach yet (removal of features), it will be =
unexpected and people will likely complain.  In the end one must decide =
between a lean code base and keeping the 1% happy to upgrade.=

--Apple-Mail=_F8FE3354-C59B-419B-A1A9-0B10B63D4833
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDA5MDY1NzA4WjAjBgkqhkiG9w0BCQQx
FgQUGORbhtwrBNWNoAtJ7lwYDGF1rQowgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGAVofPorkv/M5osvMQXDeMP8Hs
tRhFTk+bOG9yb9jfFwEif1t8/D79hdtsbOgQ/rDWqQC1CxOzEJdXIs9FKsQGp7IKlpiI6WNzoXEY
eG66PODi3vudb4RUztK9WUciOIWX69R2xxlmUqUgRo1k/dV/SDQMuNxhMH6xyHeFrVmx41sAAAAA
AAA=

--Apple-Mail=_F8FE3354-C59B-419B-A1A9-0B10B63D4833--


From MAILER-DAEMON Mon Apr 09 05:47:13 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHBBp-0005lD-EL
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 05:47:13 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44936)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SHBBm-0005l7-VB
	for bug-bash@gnu.org; Mon, 09 Apr 2012 05:47:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SHBBl-0001OT-5F
	for bug-bash@gnu.org; Mon, 09 Apr 2012 05:47:10 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:33813
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SHBBj-0001Nd-MI
	for bug-bash@gnu.org; Mon, 09 Apr 2012 05:47:09 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q399kgAX019209; Mon, 9 Apr 2012 02:46:46 -0700
Message-ID: <4F82B003.2070807@tlinx.org>
Date: Mon, 09 Apr 2012 02:46:43 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Maarten Billemont <lhunath@lyndir.com>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F81E765.9040200@case.edu>
	<1515C608-9949-43E8-ACA5-167D2A4010D6@lyndir.com>
In-Reply-To: <1515C608-9949-43E8-ACA5-167D2A4010D6@lyndir.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash <bug-bash@gnu.org>, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 09:47:12 -0000



Maarten Billemont wrote:

> On 08 Apr 2012, at 21:30, Chet Ramey wrote:
>> On 4/8/12 3:02 PM, Maarten Billemont wrote:
>>
>>> Any particular reason for not removing old undocumented functionality, or is that mostly the nature of this beast - dragging along and maintaining ancient code for the sake of compatibility?=
>> Because, as Linda discovered, there is still working code out there using
>> it.  Maybe we'll get to a point where it's all gone, but we're not there
>> yet.
> 
> 
> IMO, the working code out there that relies on $[...] either runs on older versions of bash.

Actually it was a version of 'sh',

Seems like it it's also in 'zsh'. I note.



 or if the sysadmin decided to upgrade bash, he can assume the responsibility to fix the code.

Might be a good reason to ditch bash and stick with something that supports a 
syntax that's been around for 20 years.

Like it costs how much?  I would **bet** that it cost more code to support (()) 
than to support [] as arith ops .. so if you want my opinion, lets toss (())...
(like that'll happen)...

[] is 1 token -- (()) is a double token.  (()) is much less legible because it 
is used IN the expressions [] isn't a grouping operator in an arith expression.

Also if you start with $((, that doesn't mean what follows is a arith 
expression...as in
$(((1)) && echo ok) -- only arith expression is after the 3rd paren.

$(()) for arith expressions is ugly!.... -- since the $ on the outside of (()) 
changes it meaning visually it is more ambiguous...  Why $[] wasn't used makes
no sense -- unless someone did it the other way just to make political waves...
as seems to often be the outlet of frustrated and unimportant people -- if they 
can make others lives more miserable, then they have created their own importance.

*plegh*...





From MAILER-DAEMON Mon Apr 09 09:05:10 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHEHO-00076A-BM
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 09:05:10 -0400
Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!feeder1-2.proxad.net!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From: arnold@skeeve.com (Aharon Robbins)
Newsgroups: gnu.bash.bug
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
Date: Mon, 9 Apr 2012 13:03:16 +0000 (UTC)
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <jlummj$6dm$1@dont-email.me>
References: <4F80A783.6040900@tlinx.org> <4F81E765.9040200@case.edu>
	<1515C608-9949-43E8-ACA5-167D2A4010D6@lyndir.com>
	<mailman.795.1333964833.20052.bug-bash@gnu.org>
Injection-Date: Mon, 9 Apr 2012 13:03:16 +0000 (UTC)
Injection-Info: mx04.eternal-september.org;
	posting-host="+jbH58RxFiBBWVnLF1aHAg"; 
	logging-data="6582"; mail-complaints-to="abuse@eternal-september.org";
	posting-account="U2FsdGVkX1/AqTArQpg/vID0agyr8kBT6L+E06+Gnks="
Originator: arnold@skeeve.com (Aharon Robbins)
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Cancel-Lock: sha1:3e9hv7jK2/60EsA2iE5F4lDfwjw=
Xref: usenet.stanford.edu gnu.bash.bug:24414
To: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 13:05:08 -0000

In article <mailman.795.1333964833.20052.bug-bash@gnu.org>,
Linda Walsh  <bash@tlinx.org> wrote:
>>> Because, as Linda discovered, there is still working code out there using
>>> it.  Maybe we'll get to a point where it's all gone, but we're not there
>>> yet.
>> 
>> IMO, the working code out there that relies on $[...] either runs on
>>older versions of bash.
>
>Actually it was a version of 'sh',

On many GNU/Linux systems, sh is a link to bash.

>Might be a good reason to ditch bash and stick with something that supports a 
>syntax that's been around for 20 years.

You might want to start at http://www2.research.att.com/~gsf/download/ to
get the current source code for ksh93.

> Like it costs how much?  I would **bet** that it cost more code to support
> (()) than to support [] as arith ops .. so if you want my opinion,
> lets toss (())...

As has been pointed out, for better or for worse, $((...)), is existing
practice (from ksh93) and is what is standardized by POSIX.  I suspect
that many people would agree with you w.r.t. aethestics, code maintainability,
and so on.

Unfortunately, in the case of the shell language, and many other nooks
and crannies of the Unix toolset, it's just plain too late to change.
(You might want to find a copy of the Unix version of the 'rc' shell,
which shows the results of one person's starting over from scratch.)

As has also been pointed out, although possibly not too recently in
this forum, membership in the POSIX working groups is open to anyone
who wishes to participate. It is a worthwhile experience (I was involved
in POSIX in the early 1990s), and *that* truly is the way to influence
the standards and the code that implements them.
-- 
Aharon (Arnold) Robbins 			arnold AT skeeve DOT com
P.O. Box 354		Home Phone: +972  8 979-0381
Nof Ayalon		Cell Phone: +972 50 729-7545
D.N. Shimshon 99785	ISRAEL

From MAILER-DAEMON Mon Apr 09 13:35:10 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHIUg-0007IG-4Y
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 13:35:10 -0400
Path: usenet.stanford.edu!postnews.google.com!pg2g2000pbb.googlegroups.com!not-for-mail
From: Dan Stromberg <drsalists@gmail.com>
Newsgroups: comp.unix.shell,gnu.bash.bug
Subject: Exit status of "if" statement?
Date: Mon, 9 Apr 2012 10:31:36 -0700 (PDT)
Organization: http://groups.google.com
Lines: 22
Message-ID: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
NNTP-Posting-Host: 153.65.16.10
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1333992800 7919 127.0.0.1 (9 Apr 2012 17:33:20 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 9 Apr 2012 17:33:20 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: pg2g2000pbb.googlegroups.com; posting-host=153.65.16.10;
	posting-account=9hYMCAoAAAAYQqneyjRUiFwlGE-Cp-jx
User-Agent: G2/1.0
X-HTTP-Via: 1.1 cusxteradata2.td.teradata.com:80 (IronPort-WSA/7.1.3-021)
X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML,
	like Gecko) Chrome/17.0.963.56 Safari/535.11,gzip(gfe)
Xref: usenet.stanford.edu comp.unix.shell:254725 gnu.bash.bug:24415
To: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 17:35:08 -0000


What should be the behavior of the following?

if cmd1
then
    cmd2
fi && if cmd3
then
   cmd4
fi

I've not joined two if's with a short-circuit boolean before, but I'm
suddenly working on a script where someone else has.

Playing around, it appears that cmd1 and cmd3 have no direct impact on
the exit codes of the two if's, while cmd2 and cmd4 do (if cmd1 or
cmd3 evaluate true).  Is this the defined behavior in POSIX shell?  In
bash?  In bash symlinked to /bin/sh?  In dash?

TIA!



From MAILER-DAEMON Mon Apr 09 13:41:21 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHIaf-00014g-KK
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 13:41:21 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39070)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SHIad-00014N-NG
	for bug-bash@gnu.org; Mon, 09 Apr 2012 13:41:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SHIac-0006ql-1B
	for bug-bash@gnu.org; Mon, 09 Apr 2012 13:41:19 -0400
Received: from mail-iy0-f169.google.com ([209.85.210.169]:54676)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SHIab-0006pp-PN
	for bug-bash@gnu.org; Mon, 09 Apr 2012 13:41:17 -0400
Received: by iajr24 with SMTP id r24so7668597iaj.0
	for <bug-bash@gnu.org>; Mon, 09 Apr 2012 10:41:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type:content-transfer-encoding;
	bh=4N1vb87b6g39NXEq/HMs3hJ4qOxkpnjonWMfA0NJP58=;
	b=ILCLH7LSsjCb7ni5JWubIzFtanfPKRl52KqK2NnAohD34Y0WyWoZ4aAbiWeam/5sDq
	7Mg3IKUHv9e0n5aA2XmnsEamnu7z1xnA/sbd2/WvUEdC2CpaUAYm4B6PLOYW7MdJtDlD
	NCJY2rlAfZoR+A2SVlIAs267Az7lrZPSIEKmRNSiM+o5P/3CdLVUgQQbZ1vs1bfIOHPH
	rGIWDm1QQO3tfFwkqZcwYNbzLBHMvGrrxZDOSWbgQXlw+hfXGPsiavdTxJLDgdN6FtXq
	PaVs8UHTMNABCPdurBOENud2N0E92eXz6Uh640iGBPve7HQYDPEa8opDJ/rnN8Qz3HXt
	NMgw==
Received: by 10.50.153.198 with SMTP id vi6mr5768201igb.0.1333993271879; Mon,
	09 Apr 2012 10:41:11 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.42.233.11 with HTTP; Mon, 9 Apr 2012 10:40:51 -0700 (PDT)
In-Reply-To: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
References: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Mon, 9 Apr 2012 20:40:51 +0300
Message-ID: <CAPSX3sRiVCKArXpqJh91okYV9eGP4Jc+XQ++s7M8ejSFAD9KEw@mail.gmail.com>
Subject: Re: Exit status of "if" statement?
To: Dan Stromberg <drsalists@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.210.169
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 17:41:21 -0000

On Mon, Apr 9, 2012 at 8:31 PM, Dan Stromberg <drsalists@gmail.com> wrote:
>
> What should be the behavior of the following?
>
> if cmd1
> then
> =A0 =A0cmd2
> fi && if cmd3
> then
> =A0 cmd4
> fi
>
> I've not joined two if's with a short-circuit boolean before, but I'm
> suddenly working on a script where someone else has.
>
> Playing around, it appears that cmd1 and cmd3 have no direct impact on
> the exit codes of the two if's, while cmd2 and cmd4 do (if cmd1 or
> cmd3 evaluate true). =A0Is this the defined behavior in POSIX shell? =A0I=
n
> bash? =A0In bash symlinked to /bin/sh? =A0In dash?
>
> TIA!
>
posix says "The exit status of the if command shall be the exit status
of the then or else compound-list that was executed, or zero, if none
was executed."

The bash documentation says essentialy the same.


From MAILER-DAEMON Mon Apr 09 14:14:13 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHJ6T-0001qx-RO
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 14:14:13 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49578)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SHJ6R-0001qk-V3
	for bug-bash@gnu.org; Mon, 09 Apr 2012 14:14:13 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SHJ6Q-0001B6-4Y
	for bug-bash@gnu.org; Mon, 09 Apr 2012 14:14:11 -0400
Received: from mail-yx0-f169.google.com ([209.85.213.169]:65463)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SHJ6P-00016H-Th
	for bug-bash@gnu.org; Mon, 09 Apr 2012 14:14:10 -0400
Received: by yenm8 with SMTP id m8so2328924yen.0
	for <bug-bash@gnu.org>; Mon, 09 Apr 2012 11:14:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=PvkSLNtJvUht6CD3oYCPHkWs2idob0+nkjQbGp4M3C4=;
	b=Bf6bt2Li9bCAW7rMHkR79mMfWYGEcadxZu/R+hzNIQhBdYUb9b0lTmvZyzDFLffe4p
	aMrebp0A2fUWbrz0tTmoj7Up8qTAG+HnB5z8qllaQKSvL32DKXecCQF7jPwRt0d0lPsZ
	N2G/OBl9nH9teFU4iW4lU+l6oKvohslLNXwBFHB+8Mhacoty6csA/H4g46PkksUMiXD4
	Ldvrn3HdiEMc3eT50XAKsV4Ff3F2OZ1XlYbIf6SXCtgXt8eaan97FNhz6EB3qpqN2KLH
	efRkWcahk15v03oDU/1Ok7TSD1VhN/5uiG3pENlcdJftxsFXpYHvkjqCH+tlAGqgVP81
	JsIQ==
MIME-Version: 1.0
Received: by 10.60.28.137 with SMTP id b9mr11665455oeh.57.1333995248101; Mon,
	09 Apr 2012 11:14:08 -0700 (PDT)
Sender: pyroinajar@gmail.com
Received: by 10.60.33.199 with HTTP; Mon, 9 Apr 2012 11:14:08 -0700 (PDT)
In-Reply-To: <CAPSX3sRiVCKArXpqJh91okYV9eGP4Jc+XQ++s7M8ejSFAD9KEw@mail.gmail.com>
References: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
	<CAPSX3sRiVCKArXpqJh91okYV9eGP4Jc+XQ++s7M8ejSFAD9KEw@mail.gmail.com>
Date: Mon, 9 Apr 2012 14:14:08 -0400
X-Google-Sender-Auth: Z6CP4i5_wsDStUtFaTb9bITws6U
Message-ID: <CAPg6Z0-=beDDbp+NgWj_fARznyvFj+GifjEUf1WSkfU7yafF0A@mail.gmail.com>
Subject: Re: Exit status of "if" statement?
From: DJ Mills <danielmills1@gmail.com>
To: Pierre Gaston <pierre.gaston@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.213.169
Cc: Dan Stromberg <drsalists@gmail.com>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 18:14:13 -0000

On Mon, Apr 9, 2012 at 1:40 PM, Pierre Gaston <pierre.gaston@gmail.com> wro=
te:
> On Mon, Apr 9, 2012 at 8:31 PM, Dan Stromberg <drsalists@gmail.com> wrote=
:
>>
>> What should be the behavior of the following?
>>
>> if cmd1
>> then
>> =A0 =A0cmd2
>> fi && if cmd3
>> then
>> =A0 cmd4
>> fi
>>
>> I've not joined two if's with a short-circuit boolean before, but I'm
>> suddenly working on a script where someone else has.
>>
>> Playing around, it appears that cmd1 and cmd3 have no direct impact on
>> the exit codes of the two if's, while cmd2 and cmd4 do (if cmd1 or
>> cmd3 evaluate true). =A0Is this the defined behavior in POSIX shell? =A0=
In
>> bash? =A0In bash symlinked to /bin/sh? =A0In dash?
>>
>> TIA!
>>
> posix says "The exit status of the if command shall be the exit status
> of the then or else compound-list that was executed, or zero, if none
> was executed."
>
> The bash documentation says essentialy the same.
>

>From ''help if'':
The exit status of the entire construct is the exit status of the last
command executed, or zero if no condition tested true.

It wouldn't make sense if the conditions affected the exit status. The
whole purpose of 'if' is to check the exit status of a command. If
that status persisted, things like set -e and the ERR trap would still
trigger. That would be a nightmare.


From MAILER-DAEMON Mon Apr 09 14:15:21 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHJ7Z-00024C-1l
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 14:15:21 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49742)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SHJ7W-000245-LU
	for bug-bash@gnu.org; Mon, 09 Apr 2012 14:15:19 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SHJ7V-0001oG-0y
	for bug-bash@gnu.org; Mon, 09 Apr 2012 14:15:18 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:35015)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SHJ7U-0001nT-P2
	for bug-bash@gnu.org; Mon, 09 Apr 2012 14:15:16 -0400
Received: by obbta14 with SMTP id ta14so7256198obb.0
	for <bug-bash@gnu.org>; Mon, 09 Apr 2012 11:15:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=zOm+grUjhIS8zDCBZM0SG1HtXlj5A/QB36L+O8xplh0=;
	b=B5L4542Xh9h1wctZrS1m/5fEM/BKIbFxjSofRsmFR4LCZPhp22kQk60J1XnwK1QFuD
	yWDNgQ2dLI5AKr94hGyMkS5BnRIu7OAJgFPsYsrKW5NjoqfprpYWunPm5/U9swDUVv2W
	/fpYFx4O7nROrDbN6Nl2RHvVYb/zFkLcCwMsqE1ngCqX9ou3s6BOI4soy4osszD1jAFO
	zDSfrRMWVcNrOTjjqj3nfOLUG2xnlqes7AR5IYNpFolwkPse5Td1n5x3sYsCjJ5nneXc
	2Qs3dw2xCtfYcSpDg101Y4/MqUEWMh+ppE35eXsj3dse4brky+00sQbJVFv0RdoeijnX
	LEIA==
MIME-Version: 1.0
Received: by 10.182.119.6 with SMTP id kq6mr11767659obb.67.1333995315039; Mon,
	09 Apr 2012 11:15:15 -0700 (PDT)
Sender: pyroinajar@gmail.com
Received: by 10.60.33.199 with HTTP; Mon, 9 Apr 2012 11:15:14 -0700 (PDT)
In-Reply-To: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
References: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
Date: Mon, 9 Apr 2012 14:15:14 -0400
X-Google-Sender-Auth: 5ybhq9xYlOwfybIFP_MaGUvdIZg
Message-ID: <CAPg6Z09vamv34qmTdPkRkvJQg5TDgngirthhwBPmAeX=-3WbCQ@mail.gmail.com>
Subject: Re: Exit status of "if" statement?
From: DJ Mills <danielmills1@gmail.com>
To: Dan Stromberg <drsalists@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 18:15:20 -0000

On Mon, Apr 9, 2012 at 1:31 PM, Dan Stromberg <drsalists@gmail.com> wrote:
>
> What should be the behavior of the following?
>
> if cmd1
> then
> =A0 =A0cmd2
> fi && if cmd3
> then
> =A0 cmd4
> fi
>
> I've not joined two if's with a short-circuit boolean before, but I'm
> suddenly working on a script where someone else has.
>
> Playing around, it appears that cmd1 and cmd3 have no direct impact on
> the exit codes of the two if's, while cmd2 and cmd4 do (if cmd1 or
> cmd3 evaluate true). =A0Is this the defined behavior in POSIX shell? =A0I=
n
> bash? =A0In bash symlinked to /bin/sh? =A0In dash?
>
> TIA!
>
>

Also, this is not a bug. Questions like this belong in the help-bash
mailing list.


From MAILER-DAEMON Mon Apr 09 14:45:10 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHJaQ-0000NV-Jr
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 14:45:10 -0400
Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!news.nosignal.org!cs.uu.nl!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.kamp.net!newsfeed.kamp.net!newspeer1.de.telia.net!newspeer4.de.telia.net!de.telia.net!news.m-online.net!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou@hotmail.com>
Newsgroups: comp.unix.shell,gnu.bash.bug
Subject: Re: Exit status of "if" statement?
Date: Mon, 09 Apr 2012 20:40:15 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 42
Message-ID: <jlvaeg$3g4$1@news.m-online.net>
References: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
NNTP-Posting-Host: ppp-188-174-102-72.dynamic.mnet-online.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: news.m-online.net 1333996816 3588 188.174.102.72 (9 Apr 2012 18:40:16
	GMT)
X-Complaints-To: news@news.m-online.net
NNTP-Posting-Date: Mon, 9 Apr 2012 18:40:16 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB;
	rv:1.9.2.28) Gecko/20120313 Thunderbird/3.1.20
In-Reply-To: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
Xref: usenet.stanford.edu comp.unix.shell:254728 gnu.bash.bug:24419
To: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 09 Apr 2012 18:45:08 -0000

On 09.04.2012 19:31, Dan Stromberg wrote:
> 
> What should be the behavior of the following?
> 
> if cmd1
> then
>     cmd2
> fi && if cmd3
> then
>    cmd4
> fi

If cmd1 is true then execute cmd2;
  cmd2 defines the exit code for the first if
depending on cmd2 return value,
  if true then the subsequent if is executed
    if cmd3 is true then execute cmd4;
      cmd4 defines the exit code for the second if

> 
> I've not joined two if's with a short-circuit boolean before, but I'm
> suddenly working on a script where someone else has.
> 
> Playing around, it appears that cmd1 and cmd3 have no direct impact on
> the exit codes of the two if's, while cmd2 and cmd4 do (if cmd1 or
> cmd3 evaluate true).

Yes. cmd1 and cmd3 control the if condition, and the resulting exit code
is defined by the last command executed, either cmd2 or cmd4.

>  Is this the defined behavior in POSIX shell?  In
> bash?  In bash symlinked to /bin/sh?  In dash?

I think it is defined that way in all POSIX complient shells.

Janis

> 
> TIA!
> 
> 


From MAILER-DAEMON Mon Apr 09 21:07:16 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHPYC-0007xx-Ln
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 21:07:16 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39124)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SHPY9-0007xp-EH
	for bug-bash@gnu.org; Mon, 09 Apr 2012 21:07:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SHPY7-00055T-Ps
	for bug-bash@gnu.org; Mon, 09 Apr 2012 21:07:12 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:51853
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SHPY7-00054u-6m
	for bug-bash@gnu.org; Mon, 09 Apr 2012 21:07:11 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3A173Ll003885; Mon, 9 Apr 2012 18:07:05 -0700
Message-ID: <4F8387B7.2060108@tlinx.org>
Date: Mon, 09 Apr 2012 18:07:03 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Maarten Billemont <lhunath@lyndir.com>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
In-Reply-To: <40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash <bug-bash@gnu.org>, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 01:07:14 -0000



Maarten Billemont wrote:

> Any particular reason for not removing old undocumented functionality,


 or is that mostly the nature of this beast - dragging along and maintaining


 ancient code for the sake of compatibility?


----

So 'yesturday' is "ancient" for you?... that's really means something.

In doing a scan over my /usr partition,
I see MANY examples in bash 4.1 in it's examples of using $[] -- I would hardly 
call 4.1 "ancient".


Other packages that make use of the syntax:

* wondershaper
* cifs file system
* alsa (sound)
* fonts-config   (this is a new project within the past few years)
* QT4
* GoogleBrowser (chromium)
* RPM
* YP
* PM Utils
* RPMrebuild
* iproute2 (almost all modern internet functions on linux)...
* dhcp-client
- (zsh -- not a real example, but might become alternate system shell if bash
  killed $[] support)
* Opera - ? (has comment "TODO use $(()) instead of $[] whenever possible;...) 
"whenever possible??"
* samba
    and a HUGE number in
** linux-kernel -- all over the place...

At that point, I was getting too many to keep up with ... so I stopped searching...

$[] has is -- I would bet, Universally, used MORE than $(())...

Chet -- you should get back to the posix folks and tell them posix is to be 
'descriptive of usage' (their words), not prescriptive.   Just because ksh did 
it differently from everyone else's usage doesn't mean they should go with that
syntax...

Geez.






From MAILER-DAEMON Mon Apr 09 22:30:09 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHQqP-0002w4-Ev
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 22:30:09 -0400
Path: usenet.stanford.edu!postnews.google.com!ri8g2000pbc.googlegroups.com!not-for-mail
From: bsh <brian_hiles@rocketmail.com>
Newsgroups: comp.unix.shell,gnu.bash.bug
Subject: Re: Exit status of "if" statement?
Date: Mon, 9 Apr 2012 19:26:08 -0700 (PDT)
Organization: http://groups.google.com
Lines: 72
Message-ID: <dd6183e6-29e2-4f7a-865d-0e085ca9f156@ri8g2000pbc.googlegroups.com>
References: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
	<jlvaeg$3g4$1@news.m-online.net>
NNTP-Posting-Host: 153.18.25.36
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1334024768 16911 127.0.0.1 (10 Apr 2012 02:26:08
	GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 10 Apr 2012 02:26:08 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: ri8g2000pbc.googlegroups.com; posting-host=153.18.25.36;
	posting-account=zdZowwkAAACeiPG04OD5Kq57J3HIid1o
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
	Trident/4.0; .NET4.0C; .NET4.0E),gzip(gfe)
Xref: usenet.stanford.edu comp.unix.shell:254737 gnu.bash.bug:24421
To: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 02:30:07 -0000

Janis Papanagnou <janis_papanag...@hotmail.com> wrote:
> Dan Stromberg wrote:
> > What should be the behavior of the following?
> > if cmd1
> > then
> > =A0 =A0 cmd2
> > fi && if cmd3
> > then
> > =A0 =A0cmd4
> > fi

Hello Daniel and Janis!

> If cmd1 is true then execute cmd2;
> =A0 cmd2 defines the exit code for the first if
> depending on cmd2 return value,
> =A0 if true then the subsequent if is executed
> =A0 =A0 if cmd3 is true then execute cmd4;
> =A0 =A0 =A0 cmd4 defines the exit code for the second if

I see a problem, which I cannot immediate test on a
command line available to me now.

First of all, the manpage plainly indicates:

"Usage: if if-list;then list[;elif list;then list]... [;else list];fi
... If the if-list has a non-zero exit status and there is
no else-list, then the if command returns a zero exit status."

> > Playing around, it appears that cmd1 and cmd3 have no
> > direct impact on the exit codes of the two if's, while
> > cmd2 and cmd4 do (if cmd1 or cmd3 evaluate true).
> Yes. cmd1 and cmd3 control the if condition, and the resulting
> exit code is defined by the last command executed, either cmd2
> or cmd4.

... And because of this, it is impossible to discern whether
the return code is the result of a failed if-list or the
last command in the if-body code. This strikes me as poor
programming discipline.

BTW, the reason that the manpage keeps talking about command
"lists", instead of individual commands, is because the "if"
criterion is the return code of the _last_ command in a command
_list_. That is to say, the following is possible and even
recommended:

if    cmd1
      cmd2
      cmd3
then  ...
fi

It is the return code of cmd3 which determines the flow-of-
control. This construction reinforces readable and structured
localization of code.

> > Is this the defined behavior in POSIX shell? =A0In
> > bash? =A0In bash symlinked to /bin/sh? In dash?
> I think it is defined that way in all POSIX complient shells.

Yes:

POSIX XSH: (2.9.4) Compound Commands: The if Conditional Construct:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#ta=
g_18_04

"The exit status of the 'if' command shall be the exit status of
the 'then' or 'else' compound-list that was executed, or zero,
if none was executed."

=3DBrian

From MAILER-DAEMON Mon Apr 09 22:47:33 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHR7F-0005fw-Fa
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 22:47:33 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49521)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHR7C-0005fi-Mp
	for bug-bash@gnu.org; Mon, 09 Apr 2012 22:47:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHR79-0004Sr-MA
	for bug-bash@gnu.org; Mon, 09 Apr 2012 22:47:30 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:44123)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHR79-0004SX-HK
	for bug-bash@gnu.org; Mon, 09 Apr 2012 22:47:27 -0400
Received: from mpv7.tis.CWRU.Edu (EHLO mpv7.case.edu) ([129.22.104.170])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXN51192; Mon, 09 Apr 2012 22:47:25 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TER05496 (AUTH cpr);
	Mon, 09 Apr 2012 22:47:25 -0400 (EDT)
Message-ID: <4F839F3C.8020807@case.edu>
Date: Mon, 09 Apr 2012 22:47:24 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Linda Walsh <bash@tlinx.org>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F8387B7.2060108@tlinx.org>
In-Reply-To: <4F8387B7.2060108@tlinx.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: chet.ramey@case.edu, bug-bash <bug-bash@gnu.org>,
	Maarten Billemont <lhunath@lyndir.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 10 Apr 2012 02:47:32 -0000

On 4/9/12 9:07 PM, Linda Walsh wrote:
> 
> 
> Maarten Billemont wrote:
> 
>> Any particular reason for not removing old undocumented functionality,
>> or is that mostly the nature of this beast - dragging along and maintaining
>> ancient code for the sake of compatibility?

> 
> So 'yesturday' is "ancient" for you?... that's really means something.

You have a peculiar view of history (spelling and grammar, too, but we'll
leave that aside).

> 
> In doing a scan over my /usr partition,
> I see MANY examples in bash 4.1 in it's examples of using $[] -- I would
> hardly call 4.1 "ancient".

True, I never went back and changed the examples.

> 
> 
> Other packages that make use of the syntax:
> 
> * wondershaper
> * cifs file system
> * alsa (sound)
> * fonts-config   (this is a new project within the past few years)
> * QT4
> * GoogleBrowser (chromium)
> * RPM
> * YP
> * PM Utils
> * RPMrebuild
> * iproute2 (almost all modern internet functions on linux)...
> * dhcp-client
> - (zsh -- not a real example, but might become alternate system shell if bash
>  killed $[] support)
> * Opera - ? (has comment "TODO use $(()) instead of $[] whenever
> possible;...) "whenever possible??"
> * samba
>    and a HUGE number in
> ** linux-kernel -- all over the place...
> 
> At that point, I was getting too many to keep up with ... so I stopped
> searching...
> 
> $[] has is -- I would bet, Universally, used MORE than $(())...

I believe you'd lose, but it's unprovable either way.  Consider the fact,
though, that bash and zsh support $[...], ksh93 and dash support only
$((...)), but that all four support $((...)).

> Chet -- you should get back to the posix folks and tell them posix is to be
> 'descriptive of usage' (their words), not prescriptive.   Just because ksh
> did it differently from everyone else's usage doesn't mean they should go
> with that syntax...

You have got to be kidding.  Don't you realize you're talking about
decisions that are nearly 20 years old?  That $[...] was a Posix
invention that only ever appeared in P1003.2d9?  That the $((...))
syntax was adopted officially for P1003.2-1992?  That's 1992.  Twenty
years ago.

Bash, and later zsh, implemented $[...] because there was no other
syntax at the time, and to gain some operational experience with
arithmetic expansion in the shell.  Bash-1.14 (the oldest I have
readily available) lists both forms of arithmetic expansion, but by
the time bash-2.0 was released in 1995, the manual referred only to
the $((...)) form.  That's 17 years ago.  Hardly "yesterday".

Now, it's hardly any problem to keep dragging the $[...] syntax along.
It takes only a few dozen bytes of code.  I have no plans to remove it.
But let's not kid ourselves: it's revisionist history to think that
$[...] was widespread before Posix so callously stamped it out.

> Geez.

Indeed.

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


From MAILER-DAEMON Mon Apr 09 22:54:04 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHRDX-0006qk-VP
	for mharc-bug-bash@gnu.org; Mon, 09 Apr 2012 22:54:03 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56896)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SHRDV-0006qc-E6
	for bug-bash@gnu.org; Mon, 09 Apr 2012 22:54:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SHRDT-0005gt-Cs
	for bug-bash@gnu.org; Mon, 09 Apr 2012 22:54:00 -0400
Received: from fmmailgate06.web.de ([217.72.192.247]:34741)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SHRDT-0005go-3A
	for bug-bash@gnu.org; Mon, 09 Apr 2012 22:53:59 -0400
Received: from moweb001.kundenserver.de (moweb001.kundenserver.de
	[172.19.20.114])
	by fmmailgate06.web.de (Postfix) with ESMTP id CB40C11A7904
	for <bug-bash@gnu.org>; Tue, 10 Apr 2012 04:53:56 +0200 (CEST)
Received: from [192.168.178.49] ([93.135.158.50]) by smtp.web.de (mrweb002)
	with ESMTPA (Nemesis) id 0MbyZa-1SZf5W1vYk-00JMH0;
	Tue, 10 Apr 2012 04:53:56 +0200
Message-ID: <4F83A0C5.7050300@web.de>
Date: Tue, 10 Apr 2012 04:53:57 +0200
From: dethrophes <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: Exit status of "if" statement?
References: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
	<jlvaeg$3g4$1@news.m-online.net>
	<dd6183e6-29e2-4f7a-865d-0e085ca9f156@ri8g2000pbc.googlegroups.com>
In-Reply-To: <dd6183e6-29e2-4f7a-865d-0e085ca9f156@ri8g2000pbc.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:rh0feIjCEt9Q2IO4zXW/kBZLANuOyYoWEw+JmsYZ+3q
	ULtAaMusFq2f71t5DnTbTYxmF7OAT8K9hgVdM+ig4zHMr6udZb
	18c8PUkbfw4YVCj0dqEEujwTJOJZWFSiccRV35B212itqdcymF
	GAprYmCSPCB8HgL8PLgJYMe6um8mlE+5ukHD4NdZOXBAA/Fmm5
	c7cI/tHV0qumKe9H3x2jQ==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.247
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 02:54:03 -0000

If false; then
echo jj
fi
always has to return 0 otherwise a lot of code using ERREXIT/ERRTRACE 
would break.

if you want to handle an error case you should use elif or else

your example could be written like this

if cmd1
then
     cmd2
elif cmd3
then
    cmd4
fi

or possibly like this

if cmd1
then
     cmd2
else
   if cmd3
   then
      cmd4
   fi
fi

or if you wanted to be more cryptic
cmd1&&  { cmd3 || true  ; } || { cmd3&&  cmd4 ; }


though it would be advisable to append a "|| true" to cmd2 and cmd4, 
showing explicitly that you are ignoring the return value.

if cmd1
then
     cmd2 || true
elif cmd3
then
    cmd4 || true
fi

hth
John

Am 10.04.2012 04:26, schrieb bsh:
> Janis Papanagnou<janis_papanag...@hotmail.com>  wrote:
>> Dan Stromberg wrote:
>>> What should be the behavior of the following?
>>> if cmd1
>>> then
>>>      cmd2
>>> fi&&  if cmd3
>>> then
>>>     cmd4
>>> fi
Hello Daniel and Janis!
>> If cmd1 is true then execute cmd2;
>>    cmd2 defines the exit code for the first if
>> depending on cmd2 return value,
>>    if true then the subsequent if is executed
>>      if cmd3 is true then execute cmd4;
>>        cmd4 defines the exit code for the second if
> I see a problem, which I cannot immediate test on a
> command line available to me now.
>
> First of all, the manpage plainly indicates:
>
> "Usage: if if-list;then list[;elif list;then list]... [;else list];fi
> ... If the if-list has a non-zero exit status and there is
> no else-list, then the if command returns a zero exit status."
>
>>> Playing around, it appears that cmd1 and cmd3 have no
>>> direct impact on the exit codes of the two if's, while
>>> cmd2 and cmd4 do (if cmd1 or cmd3 evaluate true).
>> Yes. cmd1 and cmd3 control the if condition, and the resulting
>> exit code is defined by the last command executed, either cmd2
>> or cmd4.
> ... And because of this, it is impossible to discern whether
> the return code is the result of a failed if-list or the
> last command in the if-body code. This strikes me as poor
> programming discipline.
>
> BTW, the reason that the manpage keeps talking about command
> "lists", instead of individual commands, is because the "if"
> criterion is the return code of the _last_ command in a command
> _list_. That is to say, the following is possible and even
> recommended:
>
> if    cmd1
>        cmd2
>        cmd3
> then  ...
> fi
>
> It is the return code of cmd3 which determines the flow-of-
> control. This construction reinforces readable and structured
> localization of code.
>
>>> Is this the defined behavior in POSIX shell?  In
>>> bash?  In bash symlinked to /bin/sh? In dash?
>> I think it is defined that way in all POSIX complient shells.
> Yes:
>
> POSIX XSH: (2.9.4) Compound Commands: The if Conditional Construct:
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_04
>
> "The exit status of the 'if' command shall be the exit status of
> the 'then' or 'else' compound-list that was executed, or zero,
> if none was executed."
>
> =Brian





From MAILER-DAEMON Tue Apr 10 00:02:25 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHSHh-00034F-RM
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 00:02:25 -0400
Received: from eggs.gnu.org ([208.118.235.92]:32925)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSHf-00033T-Ix
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:02:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSHd-0005EA-LV
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:02:23 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:52653)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSHd-0005Dt-CU
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:02:21 -0400
Received: by bkwq16 with SMTP id q16so4555135bkw.0
	for <bug-bash@gnu.org>; Mon, 09 Apr 2012 21:02:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:content-type:content-transfer-encoding;
	bh=l7/mFYzhB+C0spPhbWyOUG63miQOBMGNVU0zsdjbpMQ=;
	b=RdInukwJwTtHtSKVyWDnYZupuqtBuKFRTNR9eHnhqH3T+fxBUxlw6K1H1UhS6Jm2uL
	GdMDWoKlEIyB2c/mF7st0NdYN9el5g4jyfwVu32O2z73EKYCl+pJazoDS8LCuL2IhPJy
	FAxZYUdeJDh4XGuTidFSaKnH1y7b08BqRxFYv/NFsd9nd9J1kyIOmoyADlWbSUAZzv2T
	NsGCvBK0/LjvdZPEVN3n+kLtFZA0iPSTDz1sLLHb77xUqPLIa0T+5hE/9EzGQobQ6cn9
	MfvhyvTxHrhaafod8zS+AzjbEh04mvQg02peJM22uFsoVgAyPv/JTqkJ/8Fx1WWLCwF4
	37gg==
MIME-Version: 1.0
Received: by 10.204.128.75 with SMTP id j11mr3766897bks.2.1334030538632; Mon,
	09 Apr 2012 21:02:18 -0700 (PDT)
Received: by 10.204.170.196 with HTTP; Mon, 9 Apr 2012 21:02:18 -0700 (PDT)
In-Reply-To: <CAMZJe54+i7kehHySzsZORkxoPWiWypCo=74Eqb+YW11tWPN0oA@mail.gmail.com>
References: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
	<4F823172.5060803@syslang.net>
	<CAMZJe54+i7kehHySzsZORkxoPWiWypCo=74Eqb+YW11tWPN0oA@mail.gmail.com>
Date: Mon, 9 Apr 2012 22:02:18 -0600
Message-ID: <CAMTFtYLtrnY-kMMrGn2p-76BjrU7HyD44Xiegtn6HVVUk=ZW5g@mail.gmail.com>
Subject: Re: semicolon at beginning of line
From: Elliott Forney <elliott.forney@gmail.com>
To: bug-bash@gnu.org
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 04:02:25 -0000

Sure, a comment can be used to place a line in your history but that
doesn't really address the examples I had.  Just seems to me like a
lone semicolon could be treated as a newline/noop.  I can't seem to
think of anything that this would break but, of course, that doesn't
mean it wouldn't.  The end of a case in a switch statement is
certainly an interesting one, hadn't thought of that, but it should be
possible to handle that by checking for ;; as a token before ;.

I might mention that ksh, zsh and tcsh all allow lines to begin with a
semicolon.  zsh even allows "; ; ; echo hello world ; ; ;" although
ksh only allows a single ; at the beginning of a line.

On Sun, Apr 8, 2012 at 6:48 PM, Joseph Fredette <jfredett@gmail.com> wrote:
> Could also use a #, no?
>
> On Sun, Apr 8, 2012 at 8:46 PM, Steven W. Orr <steveo@syslang.net> wrote:
>
>> On 4/7/2012 4:00 PM, Elliott Forney wrote:
>>
>>> I wish bash would happily execute lines that begin with a semicolon,
>>> i.e., treat it as a no-op followed by a command. =A0The following
>>> examples come to mind:
>>>
>>> $ infloop& =A0echo hello
>>> [2] 11361
>>> hello
>>> $ infloop&; echo hello
>>> bash: syntax error near unexpected token `;'
>>>
>>> $ echo hello; echo world
>>> hello
>>> world
>>> $ echo hello;; echo world
>>> bash: syntax error near unexpected token `;;'
>>>
>>> $ ; echo hello world
>>> bash: syntax error near unexpected token `;'
>>>
>>> Any thoughts?
>>>
>>> Thanks,
>>> =A0 Elliott Forney
>>>
>>
>> Just use a colon.
>>
>> : echo Hello world.
>>
>> I use it all the time to 'park' a command in my history. Then when I'm
>> ready, I just back up to it and remove the colon.
>>
>>
>> --
>> Time flies like the wind. Fruit flies like a banana. Stranger things hav=
e
>> =A0.0.
>> happened but none stranger than this. Does your driver's license say Org=
an
>> ..0
>> Donor?Black holes are where God divided by zero. Listen to me! We are al=
l-
>> 000
>> individuals! What if this weren't a hypothetical question?
>> steveo at syslang.net
>>
>>


From MAILER-DAEMON Tue Apr 10 00:03:53 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHSJ7-0003Cd-75
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 00:03:53 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34516)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSJ4-0003CW-Qk
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:03:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSJ2-0005O9-Uh
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:03:50 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:35144)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSJ2-0005O5-L7
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:03:48 -0400
Received: by bkwq16 with SMTP id q16so4555821bkw.0
	for <bug-bash@gnu.org>; Mon, 09 Apr 2012 21:03:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:content-type:content-transfer-encoding;
	bh=bvXvIHebSQ0i9wPNkUNUWzOY1aLWJjyJyFjwCtOvZVY=;
	b=tWqLBGgHYq3KMkuUSOQ8FbMNGhumi0qacRPRWvI5umUZhUPUH3+gPIguZQPEfsMXUQ
	SU7RKDJyx3Z3/zzFPuTG9ZePPk/qEQ3VBnixw8L7k43vDZfzfpVuSwTR+3LApnlu1knO
	2Ck9Dg+WRxGss7SQ8Fkymc68QGUXiWKcEclWTl2bG+HywILf8dg2xyfFaS4Qab0WhGii
	yaFiIxcI1XZhQMwqH1Mjiz3P08Q+oJQQ1I3bVTiEqZt9nkVCO16fWPz7pXQTHnP7Nq/L
	XE5PIcEK1iQGZil9ZS66gSxDpgCdOnnqey4uEnAptS0q4Ih1oZFxa37kbcajvDR1z81C
	dtTA==
MIME-Version: 1.0
Received: by 10.204.133.212 with SMTP id g20mr4069080bkt.71.1334030626586;
	Mon, 09 Apr 2012 21:03:46 -0700 (PDT)
Received: by 10.204.170.196 with HTTP; Mon, 9 Apr 2012 21:03:46 -0700 (PDT)
In-Reply-To: <CAMTFtYLtrnY-kMMrGn2p-76BjrU7HyD44Xiegtn6HVVUk=ZW5g@mail.gmail.com>
References: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
	<4F823172.5060803@syslang.net>
	<CAMZJe54+i7kehHySzsZORkxoPWiWypCo=74Eqb+YW11tWPN0oA@mail.gmail.com>
	<CAMTFtYLtrnY-kMMrGn2p-76BjrU7HyD44Xiegtn6HVVUk=ZW5g@mail.gmail.com>
Date: Mon, 9 Apr 2012 22:03:46 -0600
Message-ID: <CAMTFtYLG2fkLdCUAowod+VZPoyukW+Eqi87McrAL2Tf6+ww-Zg@mail.gmail.com>
Subject: Re: semicolon at beginning of line
From: Elliott Forney <elliott.forney@gmail.com>
To: bug-bash@gnu.org
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 04:03:52 -0000

Here is another example that appears to defy my expectations.  In this
case, the semicolon is allowed:

sine:~$ hello=3D'echo hello'
sine:~$ world=3D'echo world'
sine:~$ ${hello};${world}
hello
world
sine:~$ unset hello
sine:~$ ${hello};${world}
world
sine:~$ unset world
sine:~$ ${hello};${world}

Thanks!
  Elliott Forney

On Mon, Apr 9, 2012 at 10:02 PM, Elliott Forney
<elliott.forney@gmail.com> wrote:
> Sure, a comment can be used to place a line in your history but that
> doesn't really address the examples I had. =A0Just seems to me like a
> lone semicolon could be treated as a newline/noop. =A0I can't seem to
> think of anything that this would break but, of course, that doesn't
> mean it wouldn't. =A0The end of a case in a switch statement is
> certainly an interesting one, hadn't thought of that, but it should be
> possible to handle that by checking for ;; as a token before ;.
>
> I might mention that ksh, zsh and tcsh all allow lines to begin with a
> semicolon. =A0zsh even allows "; ; ; echo hello world ; ; ;" although
> ksh only allows a single ; at the beginning of a line.
>
> On Sun, Apr 8, 2012 at 6:48 PM, Joseph Fredette <jfredett@gmail.com> wrot=
e:
>> Could also use a #, no?
>>
>> On Sun, Apr 8, 2012 at 8:46 PM, Steven W. Orr <steveo@syslang.net> wrote=
:
>>
>>> On 4/7/2012 4:00 PM, Elliott Forney wrote:
>>>
>>>> I wish bash would happily execute lines that begin with a semicolon,
>>>> i.e., treat it as a no-op followed by a command. =A0The following
>>>> examples come to mind:
>>>>
>>>> $ infloop& =A0echo hello
>>>> [2] 11361
>>>> hello
>>>> $ infloop&; echo hello
>>>> bash: syntax error near unexpected token `;'
>>>>
>>>> $ echo hello; echo world
>>>> hello
>>>> world
>>>> $ echo hello;; echo world
>>>> bash: syntax error near unexpected token `;;'
>>>>
>>>> $ ; echo hello world
>>>> bash: syntax error near unexpected token `;'
>>>>
>>>> Any thoughts?
>>>>
>>>> Thanks,
>>>> =A0 Elliott Forney
>>>>
>>>
>>> Just use a colon.
>>>
>>> : echo Hello world.
>>>
>>> I use it all the time to 'park' a command in my history. Then when I'm
>>> ready, I just back up to it and remove the colon.
>>>
>>>
>>> --
>>> Time flies like the wind. Fruit flies like a banana. Stranger things ha=
ve
>>> =A0.0.
>>> happened but none stranger than this. Does your driver's license say Or=
gan
>>> ..0
>>> Donor?Black holes are where God divided by zero. Listen to me! We are a=
ll-
>>> 000
>>> individuals! What if this weren't a hypothetical question?
>>> steveo at syslang.net
>>>
>>>


From MAILER-DAEMON Tue Apr 10 00:10:25 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHSPR-0004OI-HV
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 00:10:25 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49664)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSPP-0004Ng-4h
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:10:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSPN-0007bi-Ji
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:10:22 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:50674)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSPN-0007bV-A5
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:10:21 -0400
Received: by bkwq16 with SMTP id q16so4558821bkw.0
	for <bug-bash@gnu.org>; Mon, 09 Apr 2012 21:10:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=6/4lyB8LKPe0aH/QGEoJ5yLCPnCBaMaUjVkDRAvwSBQ=;
	b=fjIMbkXYY/ON664sJyKxsxrMwUvUSqLYXGyIEXLFs329sJOEzHbnGPJJ+8sLUlTVf+
	/Z4DylyAREgYXoTRqqBZOtQJTfyJyIzO/u9xLr7V9N3WLCdKEWCdkfqxNQA6fZIfkunP
	P9Sf76c7iyumK1yyBP1wIgeSEmPy2uoOoWuKsEbCQ7lIws4Jyq9PNTm4Hv9/chM9FaK6
	MYdIym770VqRJUIVjAyQT6s7GtxfDPgL2eKI/eKUJNsusYTAfcroLe8x++DsrSfKPVWx
	WPbymcceLmS6wsch7IXCNTuwp8L4cfja0/6UZQ+zSttecCuufclf2l3t7DBm8f7glNgB
	xAfg==
MIME-Version: 1.0
Received: by 10.204.133.212 with SMTP id g20mr4075364bkt.71.1334031019183;
	Mon, 09 Apr 2012 21:10:19 -0700 (PDT)
Received: by 10.204.170.196 with HTTP; Mon, 9 Apr 2012 21:10:19 -0700 (PDT)
Date: Mon, 9 Apr 2012 22:10:19 -0600
Message-ID: <CAMTFtYJE03ArQf+Dhqm1uEJqDbJM0aL5bjE+ZBXGG00pm1CoGw@mail.gmail.com>
Subject: Thanks!
From: Elliott Forney <elliott.forney@gmail.com>
To: bug-bash@gnu.org
Content-Type: text/plain; charset=ISO-8859-1
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 04:10:24 -0000

Also, I just wanted to send out a thanks to Chet Ramey and everyone
else that has contributed to bash.  I am a bash junkie and use it
every day.  Not only is bash my primary interactive shell, it is also
the scripting language that I write many of my programs in... and it
glues together many of the rest.

Thank you, you all rock!


From MAILER-DAEMON Tue Apr 10 00:22:12 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHSaq-00051r-Ht
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 00:22:12 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47609)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSao-00051L-3I
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:22:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSal-0001er-Mf
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:22:09 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:65257)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHSal-0001eR-Ci
	for bug-bash@gnu.org; Tue, 10 Apr 2012 00:22:07 -0400
Received: by bkwq16 with SMTP id q16so4564199bkw.0
	for <bug-bash@gnu.org>; Mon, 09 Apr 2012 21:22:05 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	bh=hjb4iwJl1+MJMkqZDxWrJaavbcIvHjYzpMvuM+Amazw=;
	b=CbykcAs/ikFsqu2AfPur2wJCGt5YAW5kbogZKB2CJMSv4am6xp7Y7AMYiCHvZoWJht
	HTWnrHgX6v3NuJyyNA0UBS3KwQN1x5HMCpAid0kxIbgOrjqzwmL+Qe1ec4WKtWV3xZeY
	Ahlozkz0JmOj//sM3IP8l2gu1uy+Fjucn/Llhmyz9cgs4/qjXMSJXVjcQVLAl/QKcorj
	PUl1d/RmQd3KInrDOoG+NiW06fyWZzjRW9pAScabi8P2YeNwp9+F1CTUJtDgBwjI3bVz
	gGPxZsbXOZxo8fk/1ZLZytoSiYifhdqk4S90iFQgZexk7sqaG5Kvcrt3GF/LNoGt+Zlq
	ue2Q==
MIME-Version: 1.0
Received: by 10.204.133.212 with SMTP id g20mr4086412bkt.71.1334031725170;
	Mon, 09 Apr 2012 21:22:05 -0700 (PDT)
Received: by 10.204.170.196 with HTTP; Mon, 9 Apr 2012 21:22:05 -0700 (PDT)
In-Reply-To: <4F839F3C.8020807@case.edu>
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F8387B7.2060108@tlinx.org> <4F839F3C.8020807@case.edu>
Date: Mon, 9 Apr 2012 22:22:05 -0600
Message-ID: <CAMTFtYK3arV1OcmrCt_5i5hmsuQ4Nhd1WzqarnJqjRPygCX6-Q@mail.gmail.com>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
From: Elliott Forney <elliott.forney@gmail.com>
To: chet.ramey@case.edu
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.41
Cc: Linda Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>,
	Maarten Billemont <lhunath@lyndir.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 04:22:11 -0000

My two cents, would be to add a bit to the man page that says something lik=
e:

-------
For historical reasons, the following format is also supported for
arithmetic evaluation:

$[expression]

Note, however, that this format is non-standard and that
$((expression)) is preferred.
-------

At least that way there won't be an undocumented feature.

Thanks,
  Elliott Forney

On Mon, Apr 9, 2012 at 8:47 PM, Chet Ramey <chet.ramey@case.edu> wrote:
> On 4/9/12 9:07 PM, Linda Walsh wrote:
>>
>>
>> Maarten Billemont wrote:
>>
>>> Any particular reason for not removing old undocumented functionality,
>>> or is that mostly the nature of this beast - dragging along and maintai=
ning
>>> ancient code for the sake of compatibility?
>
>>
>> So 'yesturday' is "ancient" for you?... that's really means something.
>
> You have a peculiar view of history (spelling and grammar, too, but we'll
> leave that aside).
>
>>
>> In doing a scan over my /usr partition,
>> I see MANY examples in bash 4.1 in it's examples of using $[] -- I would
>> hardly call 4.1 "ancient".
>
> True, I never went back and changed the examples.
>
>>
>>
>> Other packages that make use of the syntax:
>>
>> * wondershaper
>> * cifs file system
>> * alsa (sound)
>> * fonts-config =A0 (this is a new project within the past few years)
>> * QT4
>> * GoogleBrowser (chromium)
>> * RPM
>> * YP
>> * PM Utils
>> * RPMrebuild
>> * iproute2 (almost all modern internet functions on linux)...
>> * dhcp-client
>> - (zsh -- not a real example, but might become alternate system shell if=
 bash
>> =A0killed $[] support)
>> * Opera - ? (has comment "TODO use $(()) instead of $[] whenever
>> possible;...) "whenever possible??"
>> * samba
>> =A0 =A0and a HUGE number in
>> ** linux-kernel -- all over the place...
>>
>> At that point, I was getting too many to keep up with ... so I stopped
>> searching...
>>
>> $[] has is -- I would bet, Universally, used MORE than $(())...
>
> I believe you'd lose, but it's unprovable either way. =A0Consider the fac=
t,
> though, that bash and zsh support $[...], ksh93 and dash support only
> $((...)), but that all four support $((...)).
>
>> Chet -- you should get back to the posix folks and tell them posix is to=
 be
>> 'descriptive of usage' (their words), not prescriptive. =A0 Just because=
 ksh
>> did it differently from everyone else's usage doesn't mean they should g=
o
>> with that syntax...
>
> You have got to be kidding. =A0Don't you realize you're talking about
> decisions that are nearly 20 years old? =A0That $[...] was a Posix
> invention that only ever appeared in P1003.2d9? =A0That the $((...))
> syntax was adopted officially for P1003.2-1992? =A0That's 1992. =A0Twenty
> years ago.
>
> Bash, and later zsh, implemented $[...] because there was no other
> syntax at the time, and to gain some operational experience with
> arithmetic expansion in the shell. =A0Bash-1.14 (the oldest I have
> readily available) lists both forms of arithmetic expansion, but by
> the time bash-2.0 was released in 1995, the manual referred only to
> the $((...)) form. =A0That's 17 years ago. =A0Hardly "yesterday".
>
> Now, it's hardly any problem to keep dragging the $[...] syntax along.
> It takes only a few dozen bytes of code. =A0I have no plans to remove it.
> But let's not kid ourselves: it's revisionist history to think that
> $[...] was widespread before Posix so callously stamped it out.
>
>> Geez.
>
> Indeed.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU =A0 =A0chet@case.edu =A0 =A0http://cnswww.cns.cwru.=
edu/~chet/
>


From MAILER-DAEMON Tue Apr 10 02:30:09 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHUaf-000707-Ch
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 02:30:09 -0400
Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!news.nosignal.org!cs.uu.nl!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Barry Margolin <barmar@alum.mit.edu>
Newsgroups: comp.unix.shell,gnu.bash.bug
Subject: Re: Exit status of "if" statement?
Date: Tue, 10 Apr 2012 02:26:24 -0400
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <barmar-993346.02262410042012@news.eternal-september.org>
References: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
	<jlvaeg$3g4$1@news.m-online.net>
	<dd6183e6-29e2-4f7a-865d-0e085ca9f156@ri8g2000pbc.googlegroups.com>
Injection-Info: barmar.motzarella.org; posting-host="ePtxJaRXJPFeIWBMlKfZaA"; 
	logging-data="14761";
	mail-complaints-to="abuse@eternal-september.org";
	posting-account="U2FsdGVkX18EhbkdAf2W4d/ffE4DppyE"
User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)
Cancel-Lock: sha1:HEgNS0b+AzLAUcbNQbQF02d8oJc=
Xref: usenet.stanford.edu comp.unix.shell:254741 gnu.bash.bug:24428
To: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 06:30:08 -0000

In article 
<dd6183e6-29e2-4f7a-865d-0e085ca9f156@ri8g2000pbc.googlegroups.com>,
 bsh <brian_hiles@rocketmail.com> wrote:

> Janis Papanagnou <janis_papanag...@hotmail.com> wrote:
> > Dan Stromberg wrote:
> > > What should be the behavior of the following?
> > > if cmd1
> > > then
> > >     cmd2
> > > fi && if cmd3
> > > then
> > >    cmd4
> > > fi
> 
> Hello Daniel and Janis!
> 
> > If cmd1 is true then execute cmd2;
> >   cmd2 defines the exit code for the first if
> > depending on cmd2 return value,
> >   if true then the subsequent if is executed
> >     if cmd3 is true then execute cmd4;
> >       cmd4 defines the exit code for the second if
> 
> I see a problem, which I cannot immediate test on a
> command line available to me now.
> 
> First of all, the manpage plainly indicates:
> 
> "Usage: if if-list;then list[;elif list;then list]... [;else list];fi
> ... If the if-list has a non-zero exit status and there is
> no else-list, then the if command returns a zero exit status."
> 
> > > Playing around, it appears that cmd1 and cmd3 have no
> > > direct impact on the exit codes of the two if's, while
> > > cmd2 and cmd4 do (if cmd1 or cmd3 evaluate true).
> > Yes. cmd1 and cmd3 control the if condition, and the resulting
> > exit code is defined by the last command executed, either cmd2
> > or cmd4.
> 
> ... And because of this, it is impossible to discern whether
> the return code is the result of a failed if-list or the
> last command in the if-body code. This strikes me as poor
> programming discipline.

If you care about the exit status of the if-list, run it separately and 
save it.  I.e. instead of:

if cmd1; cmd2; ...
then ...
fi

write:

cmd1; cmd2; ...
status=$?
if [ $status = 0 ]
then ...
fi

The assumption behind the design of "if" is that you only care about the 
success or failure of the if-list, not the specific kind of failure.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

From MAILER-DAEMON Tue Apr 10 03:22:34 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHVPO-0008Pf-Q6
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 03:22:34 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56074)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SHVPI-0008PX-SP
	for bug-bash@gnu.org; Tue, 10 Apr 2012 03:22:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SHVPD-0002LH-7X
	for bug-bash@gnu.org; Tue, 10 Apr 2012 03:22:28 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:51316)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SHVPC-0002Kg-QI
	for bug-bash@gnu.org; Tue, 10 Apr 2012 03:22:23 -0400
Received: by bkwq16 with SMTP id q16so4661630bkw.0
	for <bug-bash@gnu.org>; Tue, 10 Apr 2012 00:22:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=WcSwPAbWYTGE7c+x4mUdrK3FuzLNfsGBlOC4S2Hq3hU=;
	b=gFq2K8CLjBMTuWYOqLHwEc5dU4oTU19OS93Wu5IiSgb6Iojpb8bRHaraKivn9U7EKs
	9aJcwIr8OiLMzjbL4F7hlgcFND0xWfXBuxuPzXEuzQ6TYxv1uz7i6NldJd1DLf3zYcqQ
	x/MT+tuV0Bpa7hFyYsW6y7LHi0ZfD8RA4uia4=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=WcSwPAbWYTGE7c+x4mUdrK3FuzLNfsGBlOC4S2Hq3hU=;
	b=cqj+U0kEV7tmVLCd76C+MH5c3uiYNz/ChPwFOXUZhL8qns2ZN4XFicwZS4PePhWax0
	UOD7RmoZmReGzKpdjijWwhL64HpeOYxVCkmmFLE6BpDUa7j00Cb3a8fqCMGi0FueSbBa
	dw4dj5j5nzJNHSrOIvt5gY3v4DPURDl37hYllKZTHuycuaS0LYffbAtuOeFiQCdyNMdv
	kSkAAJ5q+Yth1FzSVzV31EUaxcfjWeOAitVuQkOWg816kluQsy1meW9jClhIfMr/BqHj
	jyGHYjNyXp6tyeHKtGln4ISfVZZONZjniqzQJbT4ghaRf+qVoIFR+D9mMK51/bgeZiqR
	rTpA==
Received: by 10.205.133.10 with SMTP id hw10mr4196635bkc.61.1334042539582;
	Tue, 10 Apr 2012 00:22:19 -0700 (PDT)
Received: from [10.9.10.30] (c253.adsl.inet-telecom.org. [83.170.109.115])
	by mx.google.com with ESMTPS id
	zx16sm33954305bkb.13.2012.04.10.00.22.17
	(version=TLSv1/SSLv3 cipher=OTHER);
	Tue, 10 Apr 2012 00:22:18 -0700 (PDT)
Subject: Re: semicolon at beginning of line
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_4247215C-B85A-4196-8FC5-7337DE090D1F";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <CAMTFtYLG2fkLdCUAowod+VZPoyukW+Eqi87McrAL2Tf6+ww-Zg@mail.gmail.com>
Date: Tue, 10 Apr 2012 09:22:16 +0200
Message-Id: <83AA68EE-F0BC-4753-80F9-B42165E67670@lyndir.com>
References: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
	<4F823172.5060803@syslang.net>
	<CAMZJe54+i7kehHySzsZORkxoPWiWypCo=74Eqb+YW11tWPN0oA@mail.gmail.com>
	<CAMTFtYLtrnY-kMMrGn2p-76BjrU7HyD44Xiegtn6HVVUk=ZW5g@mail.gmail.com>
	<CAMTFtYLG2fkLdCUAowod+VZPoyukW+Eqi87McrAL2Tf6+ww-Zg@mail.gmail.com>
To: Elliott Forney <elliott.forney@gmail.com>
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQlPHhpha5aJvhjB5kuQwyHmba7KNtGxq6dPTvCwGEPWMLhgm2ReX+UStU3U4D2kzHHCvY6b
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.41
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 07:22:33 -0000


--Apple-Mail=_4247215C-B85A-4196-8FC5-7337DE090D1F
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=iso-8859-1

On 10 Apr 2012, at 06:03, Elliott Forney wrote:
> Here is another example that appears to defy my expectations.  In this
> case, the semicolon is allowed:
>=20
> sine:~$ hello=3D'echo hello'
> sine:~$ world=3D'echo world'
> sine:~$ ${hello};${world}
> hello
> world
> sine:~$ unset hello
> sine:~$ ${hello};${world}
> world
> sine:~$ unset world
> sine:~$ ${hello};${world}

Those are not empty statements.  It's important to understand the =
difference between:
$var
and:
eval "$var"

People should stop trying to execute code by parameter expansion, and =
specifically stop thinking that parameter-expanded words are evaluated =
as bash code.

>=20
> Thanks!
>  Elliott Forney
>=20
> On Mon, Apr 9, 2012 at 10:02 PM, Elliott Forney
> <elliott.forney@gmail.com> wrote:
>> Sure, a comment can be used to place a line in your history but that
>> doesn't really address the examples I had.  Just seems to me like a
>> lone semicolon could be treated as a newline/noop.  I can't seem to
>> think of anything that this would break but, of course, that doesn't
>> mean it wouldn't.  The end of a case in a switch statement is
>> certainly an interesting one, hadn't thought of that, but it should =
be
>> possible to handle that by checking for ;; as a token before ;.

OK, so you're saying, let's change bash so that an empty statement =
becomes a noop statement.  Except for when that empty statement is =
preceded by a semicolon and happens to have no whitespace, because then =
it could be a case delimiter.

Frankly, what are you hoping to gain from this?  This will just =
introduce new rules with new exceptions and inconsistencies.  If it were =
possible to do a blanket rule: empty statements before a semicolon are =
noops, I might be OK with it, but if it requires adding additional =
addendums to the rule, "oh wait, except for this and that case", my vote =
is out.

>>=20
>> I might mention that ksh, zsh and tcsh all allow lines to begin with =
a
>> semicolon.  zsh even allows "; ; ; echo hello world ; ; ;" although
>> ksh only allows a single ; at the beginning of a line.
>>=20
>> On Sun, Apr 8, 2012 at 6:48 PM, Joseph Fredette <jfredett@gmail.com> =
wrote:
>>> Could also use a #, no?
>>>=20
>>> On Sun, Apr 8, 2012 at 8:46 PM, Steven W. Orr <steveo@syslang.net> =
wrote:
>>>=20
>>>> On 4/7/2012 4:00 PM, Elliott Forney wrote:
>>>>=20
>>>>> I wish bash would happily execute lines that begin with a =
semicolon,
>>>>> i.e., treat it as a no-op followed by a command.  The following
>>>>> examples come to mind:
>>>>>=20
>>>>> $ infloop&  echo hello
>>>>> [2] 11361
>>>>> hello
>>>>> $ infloop&; echo hello
>>>>> bash: syntax error near unexpected token `;'
>>>>>=20
>>>>> $ echo hello; echo world
>>>>> hello
>>>>> world
>>>>> $ echo hello;; echo world
>>>>> bash: syntax error near unexpected token `;;'
>>>>>=20
>>>>> $ ; echo hello world
>>>>> bash: syntax error near unexpected token `;'
>>>>>=20
>>>>> Any thoughts?
>>>>>=20
>>>>> Thanks,
>>>>>   Elliott Forney
>>>>>=20
>>>>=20
>>>> Just use a colon.
>>>>=20
>>>> : echo Hello world.
>>>>=20
>>>> I use it all the time to 'park' a command in my history. Then when =
I'm
>>>> ready, I just back up to it and remove the colon.
>>>>=20
>>>>=20
>>>> --
>>>> Time flies like the wind. Fruit flies like a banana. Stranger =
things have
>>>>  .0.
>>>> happened but none stranger than this. Does your driver's license =
say Organ
>>>> ..0
>>>> Donor?Black holes are where God divided by zero. Listen to me! We =
are all-
>>>> 000
>>>> individuals! What if this weren't a hypothetical question?
>>>> steveo at syslang.net
>>>>=20
>>>>=20
>=20



--Apple-Mail=_4247215C-B85A-4196-8FC5-7337DE090D1F
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDEwMDcyMjE3WjAjBgkqhkiG9w0BCQQx
FgQU8SNJyoT22pQlQXRPxxX5Qd/cu00wgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGAlFIWoCaoyYFamDYbWE8SwZ1X
BpsXwPY8ZYniPXS5rV4uFBCAzxG782lWPjyc/0jU20WYjQi9jKiGIQUMaL3PdqL+14hsAfANureg
n0SZxryBUXve3UJ89c1Q4y7YdJXxUZo16oyd1g4DK6PCUCicuQtwCNJ9Mb8JsA6SjoX6basAAAAA
AAA=

--Apple-Mail=_4247215C-B85A-4196-8FC5-7337DE090D1F--


From MAILER-DAEMON Tue Apr 10 03:33:48 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHVaG-0000z6-Dz
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 03:33:48 -0400
Received: from eggs.gnu.org ([208.118.235.92]:46359)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SHVaD-0000yb-OS
	for bug-bash@gnu.org; Tue, 10 Apr 2012 03:33:47 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SHVa7-0004U2-EB
	for bug-bash@gnu.org; Tue, 10 Apr 2012 03:33:45 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:59049)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SHVa7-0004Tt-1K
	for bug-bash@gnu.org; Tue, 10 Apr 2012 03:33:39 -0400
Received: by bkwq16 with SMTP id q16so4669804bkw.0
	for <bug-bash@gnu.org>; Tue, 10 Apr 2012 00:33:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=74YBuYmG3D3PWF1bkGoPRygncAy3C9o74j4nBHXzOUs=;
	b=Qf5GWKpeakc7RQBBA7YeJIWFgi+fI1l2mVDeNwRQg+dONBqxyx6bh5j4OeFNuvKeHA
	m6Gsji96BUYpp0RVEuwycwV2rJIsH9wFX6ef0mV0UrsI2hd+S9zJUILurdOLaiovwb6R
	0Qz6udEZGFbIrG4NY9doVQx84PMyL3fSXOhgc=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=74YBuYmG3D3PWF1bkGoPRygncAy3C9o74j4nBHXzOUs=;
	b=PsjQlSR0bwY4g/7hyakZsi4ViBbW8BbE0/Z62IITxwPBnknhAP9DGdGCSwclAKphiP
	3krfo+dD+tqCVycMPyNRq4MqKF6NhGCpcnAGT41JpJ1iGXg9wUSq9dhLTa7551YMBbrT
	mn8KV5i6dr8nk3zYbXTvse3k6oWIp6e2PDQbRZ+92anwhDvMn4zngvkzwOCmBJhaTvri
	FhsBHQTDLcAFLc50r8LQQ1MotpJZwHqkRDl/594/N6DFp8fUyOQFRQMPQleK0ju28M+5
	+Y9iilWzwgRilMHREJFpXG1iqGG9Sl3zCstBriTCfv9/xgv06kGx0HWib64gD0QcseNF
	Nq2A==
Received: by 10.204.149.204 with SMTP id u12mr4313662bkv.45.1334043216722;
	Tue, 10 Apr 2012 00:33:36 -0700 (PDT)
Received: from [10.9.10.30] (c253.adsl.inet-telecom.org. [83.170.109.115])
	by mx.google.com with ESMTPS id f11sm23180509bkw.6.2012.04.10.00.33.34
	(version=TLSv1/SSLv3 cipher=OTHER);
	Tue, 10 Apr 2012 00:33:35 -0700 (PDT)
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_23D6AFCA-EB66-4C72-B6C6-163D3DB97455";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <4F82B003.2070807@tlinx.org>
Date: Tue, 10 Apr 2012 09:33:34 +0200
Message-Id: <98C04B75-7968-4768-A1BE-26E35354AF0B@lyndir.com>
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F81E765.9040200@case.edu>
	<1515C608-9949-43E8-ACA5-167D2A4010D6@lyndir.com>
	<4F82B003.2070807@tlinx.org>
To: Linda Walsh <bash@tlinx.org>
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQngTsgqQRim4SnNiYhGi3dmudwmiwHX6EebsSXJRi2lpH5dp31KRz2QT+vqcRBBTt3WTWMy
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.41
Cc: bug-bash <bug-bash@gnu.org>, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 07:33:47 -0000


--Apple-Mail=_23D6AFCA-EB66-4C72-B6C6-163D3DB97455
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 09 Apr 2012, at 11:46, Linda Walsh wrote:
>=20
> Like it costs how much?  I would **bet** that it cost more code to =
support (()) than to support [] as arith ops .. so if you want my =
opinion, lets toss (())...
> (like that'll happen)...

Just thought I'd add that I personally prefer $((...)) mostly because of =
consistency with other syntax.  $ is always an indicator of expansion, =
and since we have (( ... )) to perform an arithmetic evaluation (on its =
own as a statement or in a for etc.), I'm very happy that putting a $ in =
front of that is all it takes to expand the result of it.  Just like =
putting a dollar in front of a subshell construct expands the output of =
it and putting a dollar in front of a parameter name expands the =
contents of it.

If we were to move to $[ ... ], then to keep that consistency, we'd have =
to change (( ... )) to [ ... ], and it so happens that this command is =
already taken for a different type of test entirely.  (Don't give me the =
spiel about how [...] is already arithmetic evaluation inside array =
indices, that's a different syntax entirely, and perfectly fine - unless =
you'd prefer to turn it into arr[ (( ... )) ], which is rather =
overkill.)=

--Apple-Mail=_23D6AFCA-EB66-4C72-B6C6-163D3DB97455
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDEwMDczMzM0WjAjBgkqhkiG9w0BCQQx
FgQUAlNgyYk1+pwxTBQWbMSG3ix2/EIwgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGARvpP/GzCsc01C3H+gEJIcxqz
uhImmbiWQ03dleKmQdfE2vNN0a/O1KN3CP9917ado7p7S3WKBcc9BAaSbPIa7wNF9G289QZzKCSg
5DDSdQWWpg5c4nn5EJO23G4QXupoYQ8duNy7InTRd7skfMLSG4If3nFf97EygDS0qe461DwAAAAA
AAA=

--Apple-Mail=_23D6AFCA-EB66-4C72-B6C6-163D3DB97455--


From MAILER-DAEMON Tue Apr 10 03:38:28 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHVem-0001Nk-2Z
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 03:38:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47392)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SHVef-0001NV-IQ
	for bug-bash@gnu.org; Tue, 10 Apr 2012 03:38:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SHVed-0005qB-N5
	for bug-bash@gnu.org; Tue, 10 Apr 2012 03:38:21 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:62853)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SHVed-0005q0-Da
	for bug-bash@gnu.org; Tue, 10 Apr 2012 03:38:19 -0400
Received: by bkwq16 with SMTP id q16so4673458bkw.0
	for <bug-bash@gnu.org>; Tue, 10 Apr 2012 00:38:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=6xQJtWV4azwF/6CZHk9iEipSSIj0YXmYwCV+SLOySCo=;
	b=Msa93xsqCWbEP88pp8Sftoa5XsK/iesEESnqy661bCOcllWXpAb416gWOFu+ntRxOs
	//MUcJF4FkpoPvrK2fpsJPdb4Qcq21IaLqttY3KdLKc5jauRFDpM1nGVcZ5jxLHe40+T
	l0JCtQyiUdd2chmYSs4cIXvHm6oYyIELNHW0E=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=6xQJtWV4azwF/6CZHk9iEipSSIj0YXmYwCV+SLOySCo=;
	b=EYSO+aCCHbfs2lfCXIC9LbIlPjrvDSZ5xAlEpa3BJwZSQw/15S/CaivzR0O7wReb6O
	B3z7LmZOsPv4zHzxpc1dySKWXRMR9vyMQ3Tf8iWiLbWBe5g8QndWj1zsDQ6omcofHB2C
	+YoTd5vrBO6jB/cF5AAXVx8D3xKdDmkd1f4Mg6uQTuwGVeyZlJdJM80t14MsuVP/Y7/f
	EsaMQH0OUAmnG0CzmPBPXkK+dtJs2xxx/t6NomZEpkymhjrf3v9fLiBihhSxKzA1doAX
	vHJAx6MHpcYcz78jUoclfyhfPAHM/GH6oIAwYt6QLcgBO+Nduaij3RidMzLGIOHUfpro
	/iHg==
Received: by 10.204.156.206 with SMTP id y14mr4320229bkw.14.1334043497101;
	Tue, 10 Apr 2012 00:38:17 -0700 (PDT)
Received: from [10.9.10.30] (c253.adsl.inet-telecom.org. [83.170.109.115])
	by mx.google.com with ESMTPS id f11sm23203663bkw.6.2012.04.10.00.38.15
	(version=TLSv1/SSLv3 cipher=OTHER);
	Tue, 10 Apr 2012 00:38:16 -0700 (PDT)
Subject: Re: Exit status of "if" statement?
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_79B51AC0-FDF7-4389-911B-077F5AC8784B";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <barmar-993346.02262410042012@news.eternal-september.org>
Date: Tue, 10 Apr 2012 09:38:14 +0200
Message-Id: <7973F0A6-8E92-49AA-A87B-0E24078C5912@lyndir.com>
References: <3360b939-5d82-4258-90a2-58c2d5545943@pg2g2000pbb.googlegroups.com>
	<jlvaeg$3g4$1@news.m-online.net>
	<dd6183e6-29e2-4f7a-865d-0e085ca9f156@ri8g2000pbc.googlegroups.com>
	<barmar-993346.02262410042012@news.eternal-september.org>
To: Barry Margolin <barmar@alum.mit.edu>
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQk8wo07TggRUXQpeatEJAjPn5LFjsxOd4ETPeMmphjdtXeu74cng/a0S63aLdrmGp3VU7d5
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.41
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 07:38:27 -0000


--Apple-Mail=_79B51AC0-FDF7-4389-911B-077F5AC8784B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 10 Apr 2012, at 08:26, Barry Margolin wrote:
>=20
> if [ $status =3D 0 ]

As an aside, I don't think it's a good idea to recommend comparing =
numbers using string comparison operators.

if (( status =3D=3D 0 ))

But if you wanted to treat them as strings for the sake of code =
simplicity, just go the case route:

case $status in
0) ... ;;
1) ... ;;
*) ... ;;
esac=

--Apple-Mail=_79B51AC0-FDF7-4389-911B-077F5AC8784B
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDEwMDczODE1WjAjBgkqhkiG9w0BCQQx
FgQUIf9lDHBEWBSf+KSTx1wHjVCQUnQwgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGAPM+rRZqPH1I3uNNr/DWcol5x
ELoyWLWQHKQsaeizS+v6mAXrMzea6rm/Y+wihv516QXQcxiHitvgQT2JANbTIECx9n/VWsADHeDq
CMIXIShdpuo0+Zq0oYj5VFvaojdify0U5gmhg/ScZii4wtwhmrbwaGZeTQVW2VnQV0IQ2FIAAAAA
AAA=

--Apple-Mail=_79B51AC0-FDF7-4389-911B-077F5AC8784B--


From MAILER-DAEMON Tue Apr 10 04:38:44 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHWb6-0000Fn-TM
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 04:38:44 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39743)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHWb4-0000FH-9A
	for bug-bash@gnu.org; Tue, 10 Apr 2012 04:38:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHWaw-0004mR-OQ
	for bug-bash@gnu.org; Tue, 10 Apr 2012 04:38:41 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:36823)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <elliott.forney@gmail.com>) id 1SHWaw-0004m7-FD
	for bug-bash@gnu.org; Tue, 10 Apr 2012 04:38:34 -0400
Received: by bkwq16 with SMTP id q16so4725247bkw.0
	for <bug-bash@gnu.org>; Tue, 10 Apr 2012 01:38:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	bh=0/03TYn2drwhyLVMbpHe+gAA8/mECca0px6MbzGqoQM=;
	b=wLKRBmLxmfJQwXwWo582vMg0KsxyB/9/QNAq73033DSleaKGEizSBue3bsbzdqavG+
	mugJTCVwatRMbHd36CkuK+KpdSSMt6pP0oMNOSaxWAZcBDTZ4bOwlXD4DNdWJ+NG5nmz
	Hpau8glRtY1sYpgSi6QchtkHLoDHbxu7psQqobuQ1Spb8D2MXol5o8mNrFpSwccqXqtX
	xoqu0CyCgWOqb2dISOE1EKO3/F4Nr71giHRFB7M6HsDoehkiglY7LnRpNueP79rw07mN
	oyCbC83zSYOf43aO+rbAAEtxtLeNBuTJtdom+yTfpnDSnLfgP9faULdJtO8WhZUj1h/9
	THQA==
MIME-Version: 1.0
Received: by 10.205.127.130 with SMTP id ha2mr4419696bkc.28.1334047110811;
	Tue, 10 Apr 2012 01:38:30 -0700 (PDT)
Received: by 10.204.170.196 with HTTP; Tue, 10 Apr 2012 01:38:30 -0700 (PDT)
In-Reply-To: <83AA68EE-F0BC-4753-80F9-B42165E67670@lyndir.com>
References: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
	<4F823172.5060803@syslang.net>
	<CAMZJe54+i7kehHySzsZORkxoPWiWypCo=74Eqb+YW11tWPN0oA@mail.gmail.com>
	<CAMTFtYLtrnY-kMMrGn2p-76BjrU7HyD44Xiegtn6HVVUk=ZW5g@mail.gmail.com>
	<CAMTFtYLG2fkLdCUAowod+VZPoyukW+Eqi87McrAL2Tf6+ww-Zg@mail.gmail.com>
	<83AA68EE-F0BC-4753-80F9-B42165E67670@lyndir.com>
Date: Tue, 10 Apr 2012 02:38:30 -0600
Message-ID: <CAMTFtYL_gzKuPjmUoJqHyPOusgFz-eqbBjZXUb8BHnZwFny9Qw@mail.gmail.com>
Subject: Re: semicolon at beginning of line
From: Elliott Forney <elliott.forney@gmail.com>
To: Maarten Billemont <lhunath@lyndir.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.41
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 08:38:43 -0000

On Tue, Apr 10, 2012 at 1:22 AM, Maarten Billemont <lhunath@lyndir.com> wro=
te:
> People should stop trying to execute code by parameter expansion, and spe=
cifically stop thinking that parameter-expanded words are evaluated as bash=
 code.

I still think the behavior is interesting.  The statement may not be
empty but nothing other than the expansion is executed.

> OK, so you're saying, let's change bash so that an empty statement become=
s a noop statement.

Yes.  It already is when a newline is received.  Why not when an empty
statement is terminated with a semicolon?

>Except for when that empty statement is preceded by a semicolon and happen=
s to have no whitespace, because then it could be a case delimiter.

Yes.  Just like "$(" differs from "$((" and "[" from "[[" and ">" from
">>".  This would not be unique syntax in bash.

> Frankly, what are you hoping to gain from this?

I simply believe it is intuitive; this is the behavior I would expect
before trying it.

> This will just introduce new rules with new exceptions and inconsistencie=
s. =A0If it were possible to do a blanket rule: empty statements before a s=
emicolon are noops, I might be OK with it, but if it requires adding additi=
onal addendums to the rule, "oh wait, except for this and that case", my vo=
te is out.

I really don't think it would cause lots of problems.  This belief is
supported by the fact that this is already implemented in other
shells.  Try the examples I have given in zsh and you will see the
behavior I would expect.  Try it in ksh and you will see something
closer to the blanket rule you suggest.

If no one else agrees then that's cool but my vote is to change it.

Thanks,
  Elliott Forney


From MAILER-DAEMON Tue Apr 10 10:59:32 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHcXc-0004Dz-NK
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 10:59:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:36830)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHcXU-0004Ci-SA
	for bug-bash@gnu.org; Tue, 10 Apr 2012 10:59:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHcXS-00043S-P2
	for bug-bash@gnu.org; Tue, 10 Apr 2012 10:59:24 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:15667)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHcXS-00040Q-KG
	for bug-bash@gnu.org; Tue, 10 Apr 2012 10:59:22 -0400
Received: from mpv8.tis.CWRU.Edu (EHLO mpv8.case.edu) ([129.22.105.116])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXN88063; Tue, 10 Apr 2012 10:59:18 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TLH78603 (AUTH cpr);
	Tue, 10 Apr 2012 10:59:15 -0400 (EDT)
Message-ID: <4F844AC1.8040208@case.edu>
Date: Tue, 10 Apr 2012 10:59:13 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Maarten Billemont <lhunath@lyndir.com>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F81E765.9040200@case.edu>
	<1515C608-9949-43E8-ACA5-167D2A4010D6@lyndir.com>
	<4F82B003.2070807@tlinx.org>
	<98C04B75-7968-4768-A1BE-26E35354AF0B@lyndir.com>
In-Reply-To: <98C04B75-7968-4768-A1BE-26E35354AF0B@lyndir.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: Linda Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>,
	chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 10 Apr 2012 14:59:30 -0000

On 4/10/12 3:33 AM, Maarten Billemont wrote:

> If we were to move to $[ ... ]

But we're not.  It's ludicrous to think we would.  How far down the rabbit
hole are we going to go on this?

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


From MAILER-DAEMON Tue Apr 10 11:01:17 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHcZI-0004UL-VJ
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 11:01:16 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37142)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHcZA-0004Sp-RO
	for bug-bash@gnu.org; Tue, 10 Apr 2012 11:01:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHcYz-0004dt-LC
	for bug-bash@gnu.org; Tue, 10 Apr 2012 11:01:08 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:7024)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHcYz-0004dk-GP
	for bug-bash@gnu.org; Tue, 10 Apr 2012 11:00:57 -0400
Received: from mpv8.case.edu (mpv8.tis.cwru.edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJT47375;
	Tue, 10 Apr 2012 11:00:53 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TLH79626 (AUTH cpr);
	Tue, 10 Apr 2012 11:00:53 -0400 (EDT)
Message-ID: <4F844B24.4040100@case.edu>
Date: Tue, 10 Apr 2012 11:00:52 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Elliott Forney <elliott.forney@gmail.com>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F8387B7.2060108@tlinx.org> <4F839F3C.8020807@case.edu>
	<CAMTFtYK3arV1OcmrCt_5i5hmsuQ4Nhd1WzqarnJqjRPygCX6-Q@mail.gmail.com>
In-Reply-To: <CAMTFtYK3arV1OcmrCt_5i5hmsuQ4Nhd1WzqarnJqjRPygCX6-Q@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: Linda Walsh <bash@tlinx.org>, Maarten Billemont <lhunath@lyndir.com>,
	bug-bash <bug-bash@gnu.org>, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 10 Apr 2012 15:01:15 -0000

On 4/10/12 12:22 AM, Elliott Forney wrote:
> My two cents, would be to add a bit to the man page that says something like:
> 
> -------
> For historical reasons, the following format is also supported for
> arithmetic evaluation:
> 
> $[expression]
> 
> Note, however, that this format is non-standard and that
> $((expression)) is preferred.
> -------
> 
> At least that way there won't be an undocumented feature.

I don't mind an undocumented feature in this case, since the only reason
it's there is being carried along for backwards compatibility.

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


From MAILER-DAEMON Tue Apr 10 12:04:50 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHdYo-0003eN-2K
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 12:04:50 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34153)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHdYi-0003dK-5m
	for bug-bash@gnu.org; Tue, 10 Apr 2012 12:04:48 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHdYf-0006gk-Mj
	for bug-bash@gnu.org; Tue, 10 Apr 2012 12:04:43 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:46617)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHdYf-0006gN-II
	for bug-bash@gnu.org; Tue, 10 Apr 2012 12:04:41 -0400
Received: from mpv8.case.edu (mpv8.tis.cwru.edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJT54238;
	Tue, 10 Apr 2012 12:04:38 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TLJ02292 (AUTH cpr);
	Tue, 10 Apr 2012 12:04:37 -0400 (EDT)
Message-ID: <4F845A14.5060009@case.edu>
Date: Tue, 10 Apr 2012 12:04:36 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: dave reisner <d@falconindy.com>
Subject: Re: Behavior of calling return from a trap
References: <5c3f26e4-2d5a-4f60-8f0d-074bf32d297d@w9g2000vbv.googlegroups.com>
In-Reply-To: <5c3f26e4-2d5a-4f60-8f0d-074bf32d297d@w9g2000vbv.googlegroups.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 10 Apr 2012 16:04:48 -0000

On 2/15/12 7:51 PM, dave reisner wrote:
> Hi all,
> 
> I'm noticing some odd behavior in an ERR trap with errtrace. It's
> present in bash 3.2 and as well as 4.2. The simplest reproduction is
> as follows:
> 
> ------8<----------------------
> #!/bin/bash
> 
> somefunc() {
>   false
>   echo "shouldn't see this"
> }
> 
> set -E
> trap -- 'return 1' ERR
> 
> somefunc
> echo "should see this"
> ------8<----------------------
> 
> Both versions of bash throw an error, though fwiw the line number
> differs: bash4 blames the line of where the trap is fired versus bash3
> which blames the line where the trap is declared. The entire output of
> the script is:
> 
> foo: line 4: return: can only `return' from a function or sourced
> script
> should see this
> 
> So, both versions give the intended behavior of returning from the
> function despite the error. imo, there's a bug here somewhere, I'm
> just not sure if it's the faulty error being thrown or if I shouldn't
> be expecting the trap to work as it is when it's declared outside of a
> function.

You're calling the error trap twice.  The first time you call it is after
the `false' in the body of the function, and the `return' works as intended
there.  Since you return 1, the call to `somefunc' fails, triggering the
error trap again.  The second time you call it, you're not executing in a
function context, and `return' throws an error.

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


From MAILER-DAEMON Tue Apr 10 12:20:42 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHdoA-0007Qt-1s
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 12:20:42 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55218)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHdo2-0007Ot-Gu
	for bug-bash@gnu.org; Tue, 10 Apr 2012 12:20:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHdnw-000369-2Y
	for bug-bash@gnu.org; Tue, 10 Apr 2012 12:20:34 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:57016)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHdnv-00035v-Tn
	for bug-bash@gnu.org; Tue, 10 Apr 2012 12:20:27 -0400
Received: from mpv8.case.edu (mpv8.tis.cwru.edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJT55839;
	Tue, 10 Apr 2012 12:20:23 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TLJ12467 (AUTH cpr);
	Tue, 10 Apr 2012 12:20:23 -0400 (EDT)
Message-ID: <4F845DC6.1080309@case.edu>
Date: Tue, 10 Apr 2012 12:20:22 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: George <gnachman@gmail.com>
Subject: Re: Writing to bash's tty too fast: workarounds?
References: <e4f419d3-06ed-475e-a714-7908f46b28cf@r33g2000prh.googlegroups.com>
In-Reply-To: <e4f419d3-06ed-475e-a714-7908f46b28cf@r33g2000prh.googlegroups.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 10 Apr 2012 16:20:40 -0000

On 6/13/11 1:45 AM, George wrote:
> I'm the maintainer of a terminal emulator on Mac OS and a user
> reported that if he pastes a large string of the form:
> 
> cat << EOF > whatever.txt
> blah blah blah
> blah blah blah
> ... etc for 100k ...
> EOF
> 
> That the output is badly mangled. I can reproduce this consistently
> with a smallish test program. Having traced into readline, the culprit
> seems to be that readline fiddles with the terminal between lines of
> input (I'm pretty sure the things done in set_tty_settings() are
> responsible, but I haven't proved it yet). This seems to cause it to
> drop some or all of the input that's in the input buffer.

Since readline is intended to read a single line of input at a time, it's
natural that it modifies the terminal settings before it reads any data
and after it's read a complete line.  The code is careful to use flags to
tcsetattr(3) that force the system to wait until all output has drained
and does not throw away input characters.

I suspect that the cause is the kernel's behavior when the input queue
is full.  Readline doesn't use IXON/IXOFF, so there won't be any
stopping when the queue is full (see the description of IXOFF in
termios(4)).

If you want to paste large amounts of data, you're not interested in any
input line editing, so it makes sense to turn off editing as a workaround
(set +o emacs +o vi) before running the command using the here document.

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


From MAILER-DAEMON Tue Apr 10 13:31:49 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHeuz-0004aF-Cm
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 13:31:49 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51089)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHeuw-0004Yb-3T
	for bug-bash@gnu.org; Tue, 10 Apr 2012 13:31:47 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHeut-0006jz-TM
	for bug-bash@gnu.org; Tue, 10 Apr 2012 13:31:45 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:27039)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SHeut-0006jh-OW
	for bug-bash@gnu.org; Tue, 10 Apr 2012 13:31:43 -0400
Received: from mpv8.case.edu (mpv8.tis.cwru.edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJT62200;
	Tue, 10 Apr 2012 13:31:41 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TLK05941 (AUTH cpr);
	Tue, 10 Apr 2012 13:31:41 -0400 (EDT)
Message-ID: <4F846E7C.3030508@case.edu>
Date: Tue, 10 Apr 2012 13:31:40 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: gnachman@llamas.org
Subject: Re: Writing to bash's tty too fast: workarounds?
References: <e4f419d3-06ed-475e-a714-7908f46b28cf@r33g2000prh.googlegroups.com>
	<4F845DC6.1080309@case.edu>
	<CAB5RqomjRh9zzS5_M_vkGLO1S5fg6XE77BmW+J9FGSjsZto7Qg@mail.gmail.com>
In-Reply-To: <CAB5RqomjRh9zzS5_M_vkGLO1S5fg6XE77BmW+J9FGSjsZto7Qg@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: George Nachman <gnachman@gmail.com>, bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 10 Apr 2012 17:31:47 -0000

On 4/10/12 1:22 PM, George Nachman wrote:
> Thanks for getting back to me, Chet. The theory about the kernel's handling
> of a full input queue seems likely. In the case of bash + readline, would
> it be feasible to avoid readline changing the terminal settings while
> reading a here document? Seems like the only remedy if the kernel is
> misbehaving in this case.

But how would bash or readline know whether or not the user intends to
enter here-document lines individually, or cut and paste a large amount
of data?  Only the user knows that for certain, and there is already a
workaround available to him.

Chet

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


From MAILER-DAEMON Tue Apr 10 20:27:19 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHlP5-000752-9A
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 20:27:19 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57656)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnachman@gmail.com>) id 1SHemJ-0001oV-SQ
	for bug-bash@gnu.org; Tue, 10 Apr 2012 13:22:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnachman@gmail.com>) id 1SHemD-0003e3-GG
	for bug-bash@gnu.org; Tue, 10 Apr 2012 13:22:51 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:41660)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnachman@gmail.com>) id 1SHemD-0003db-6t
	for bug-bash@gnu.org; Tue, 10 Apr 2012 13:22:45 -0400
Received: by obbta14 with SMTP id ta14so53329obb.0
	for <bug-bash@gnu.org>; Tue, 10 Apr 2012 10:22:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:reply-to:in-reply-to:references:from:date:message-id
	:subject:to:cc:content-type;
	bh=AvsZ03nsmfqlgmbSnP2l+NEGf5b2kAWQr4+qiskmLpw=;
	b=XDOGcys4fZHpVY4q38dVr9g1PW9ww5/BXeu2dXZ9KGM5ESmELUsBt7vK+eZaUowwMP
	bB1dndyrn7nYJWeH6hjlayDSa7fNSGYqLEAjsBqCTrE0or5iGFdA2nAL0bgPlsFRByFO
	yyICYd1SMup5mu3YLyO8cHUpHkdbk13q44WudGSui1BSaSEBIbFut+vIG5ZEZ9bgpNvu
	NRgfjwFLgWFVWQFwud9ZcdIGIxcH/3CdnqsrjyI0f8UZD8A4b6LhQ87NvAQcf6bsfuSP
	SIQIXfTzZfotQVtSRkQsuAnKPsHepKys1FzB9Qc9B2ke6TDCLoVaTtlGy/GZxJ+6XqDY
	jz3w==
Received: by 10.60.21.103 with SMTP id u7mr17173497oee.11.1334078559430; Tue,
	10 Apr 2012 10:22:39 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.182.147.7 with HTTP; Tue, 10 Apr 2012 10:22:19 -0700 (PDT)
In-Reply-To: <4F845DC6.1080309@case.edu>
References: <e4f419d3-06ed-475e-a714-7908f46b28cf@r33g2000prh.googlegroups.com>
	<4F845DC6.1080309@case.edu>
From: George Nachman <gnachman@gmail.com>
Date: Tue, 10 Apr 2012 10:22:19 -0700
Message-ID: <CAB5RqomjRh9zzS5_M_vkGLO1S5fg6XE77BmW+J9FGSjsZto7Qg@mail.gmail.com>
Subject: Re: Writing to bash's tty too fast: workarounds?
To: chet.ramey@case.edu
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
X-Mailman-Approved-At: Tue, 10 Apr 2012 20:27:17 -0400
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: gnachman@llamas.org
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, 10 Apr 2012 17:22:56 -0000

Thanks for getting back to me, Chet. The theory about the kernel's handling
of a full input queue seems likely. In the case of bash + readline, would
it be feasible to avoid readline changing the terminal settings while
reading a here document? Seems like the only remedy if the kernel is
misbehaving in this case.

On Tue, Apr 10, 2012 at 9:20 AM, Chet Ramey <chet.ramey@case.edu> wrote:

> On 6/13/11 1:45 AM, George wrote:
> > I'm the maintainer of a terminal emulator on Mac OS and a user
> > reported that if he pastes a large string of the form:
> >
> > cat << EOF > whatever.txt
> > blah blah blah
> > blah blah blah
> > ... etc for 100k ...
> > EOF
> >
> > That the output is badly mangled. I can reproduce this consistently
> > with a smallish test program. Having traced into readline, the culprit
> > seems to be that readline fiddles with the terminal between lines of
> > input (I'm pretty sure the things done in set_tty_settings() are
> > responsible, but I haven't proved it yet). This seems to cause it to
> > drop some or all of the input that's in the input buffer.
>
> Since readline is intended to read a single line of input at a time, it's
> natural that it modifies the terminal settings before it reads any data
> and after it's read a complete line.  The code is careful to use flags to
> tcsetattr(3) that force the system to wait until all output has drained
> and does not throw away input characters.
>
> I suspect that the cause is the kernel's behavior when the input queue
> is full.  Readline doesn't use IXON/IXOFF, so there won't be any
> stopping when the queue is full (see the description of IXOFF in
> termios(4)).
>
> If you want to paste large amounts of data, you're not interested in any
> input line editing, so it makes sense to turn off editing as a workaround
> (set +o emacs +o vi) before running the command using the here document.
>
> Chet
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                 ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU    chet@case.edu
> http://cnswww.cns.cwru.edu/~chet/
>

From MAILER-DAEMON Tue Apr 10 20:27:23 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHlP9-0007Dh-7n
	for mharc-bug-bash@gnu.org; Tue, 10 Apr 2012 20:27:23 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57841)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <d@falconindy.com>) id 1SHhct-0000yL-RF
	for bug-bash@gnu.org; Tue, 10 Apr 2012 16:25:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <d@falconindy.com>) id 1SHhcs-0002uE-4M
	for bug-bash@gnu.org; Tue, 10 Apr 2012 16:25:19 -0400
Received: from mail-qc0-f169.google.com ([209.85.216.169]:64314)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <d@falconindy.com>) id 1SHhcs-0002tw-0D
	for bug-bash@gnu.org; Tue, 10 Apr 2012 16:25:18 -0400
Received: by qcsd16 with SMTP id d16so159487qcs.0
	for <bug-bash@gnu.org>; Tue, 10 Apr 2012 13:25:15 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=date:from:to:cc:subject:message-id:references:mime-version
	:content-type:content-disposition:in-reply-to:user-agent
	:x-gm-message-state;
	bh=7y4Foaq0MC7jPGS65NAUfbc/CXKZbNy9E16XIgVR3To=;
	b=otgQZPcOCL1UD8M+QAO+ySvagab+BPPLBldMNbjLnhwPpBebPWkwCqy7Zl4RGL+Kfa
	Jh4K8XNhFbuFJ9joMimufBNNt0SNMJXPT993GIBa3+RLOjn6CErTycVKTSRI7qCUbsY4
	3y/WL8ly3ui8/E7o2G6Jjx81vdKEXZLRyKAluuwt6H6uX4LUD6HVFU+El8G9QosBMMbN
	2oSbT9/RJbfnkryZXYJnH6fNvx+Fg9EMM3L4vhVXOk4tmUMzSVYsiEMNnwSi/NTAyreT
	aGAsX0lQulkolfrgKduZX7oot3+nSSstD/61X7pH9QCNspJtWEu0q9DLkmfMYwub7e8T
	gJRg==
Received: by 10.224.223.76 with SMTP id ij12mr16484221qab.11.1334089515243;
	Tue, 10 Apr 2012 13:25:15 -0700 (PDT)
Received: from localhost (ool-4a5aad93.dyn.optonline.net. [74.90.173.147])
	by mx.google.com with ESMTPS id ha3sm1600378qab.13.2012.04.10.13.25.13
	(version=TLSv1/SSLv3 cipher=OTHER);
	Tue, 10 Apr 2012 13:25:14 -0700 (PDT)
Date: Tue, 10 Apr 2012 16:25:13 -0400
From: dave reisner <d@falconindy.com>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Behavior of calling return from a trap
Message-ID: <20120410202513.GB843@rampage>
References: <5c3f26e4-2d5a-4f60-8f0d-074bf32d297d@w9g2000vbv.googlegroups.com>
	<4F845A14.5060009@case.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F845A14.5060009@case.edu>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQmphVegSNhr8MvVQiQeAzLIumsxURkQCgiwzpZAFjlOWLc0c624UIRRRwJQCWzkoJdmTUsH
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.216.169
X-Mailman-Approved-At: Tue, 10 Apr 2012 20:27:20 -0400
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 10 Apr 2012 20:25:21 -0000

On Tue, Apr 10, 2012 at 12:04:36PM -0400, Chet Ramey wrote:
> You're calling the error trap twice.  The first time you call it is after
> the `false' in the body of the function, and the `return' works as intended
> there.  Since you return 1, the call to `somefunc' fails, triggering the
> error trap again.  The second time you call it, you're not executing in a
> function context, and `return' throws an error.

Ah, of course. That makes a lot of sense. Thanks for clarifying.

dave


From MAILER-DAEMON Wed Apr 11 02:23:24 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHqxg-00016i-3B
	for mharc-bug-bash@gnu.org; Wed, 11 Apr 2012 02:23:24 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37823)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SHmkr-0006Qa-FC
	for bug-bash@gnu.org; Tue, 10 Apr 2012 21:53:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SHmkp-0006J0-Ee
	for bug-bash@gnu.org; Tue, 10 Apr 2012 21:53:53 -0400
Received: from rcsinet15.oracle.com ([148.87.113.117]:42777)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SHmko-0006I6-Vx
	for bug-bash@gnu.org; Tue, 10 Apr 2012 21:53:51 -0400
Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237])
	by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with
	ESMTP id q3B1rj1L000668
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Wed, 11 Apr 2012 01:53:46 GMT
Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157])
	by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
	q3B1rjoU027519
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <bug-bash@gnu.org>; Wed, 11 Apr 2012 01:53:45 GMT
Received: from abhmt106.oracle.com (abhmt106.oracle.com [141.146.116.58])
	by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id
	q3B1riZU019182
	for <bug-bash@gnu.org>; Tue, 10 Apr 2012 20:53:45 -0500
Received: from mail-gy0-f169.google.com (/209.85.160.169)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Tue, 10 Apr 2012 18:53:44 -0700
Received: by ghrr18 with SMTP id r18so295033ghr.0
	for <bug-bash@gnu.org>; Tue, 10 Apr 2012 18:53:44 -0700 (PDT)
Received: by 10.236.154.35 with SMTP id g23mr11435167yhk.107.1334109224348;
	Tue, 10 Apr 2012 18:53:44 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.100.167.6 with HTTP; Tue, 10 Apr 2012 18:53:24 -0700 (PDT)
In-Reply-To: <CAMTFtYL_gzKuPjmUoJqHyPOusgFz-eqbBjZXUb8BHnZwFny9Qw@mail.gmail.com>
References: <CAMTFtYKV+VwViZ81oQsX=rsNni7Wgc1nw7QWM3=aBLyZVrQJkA@mail.gmail.com>
	<4F823172.5060803@syslang.net>
	<CAMZJe54+i7kehHySzsZORkxoPWiWypCo=74Eqb+YW11tWPN0oA@mail.gmail.com>
	<CAMTFtYLtrnY-kMMrGn2p-76BjrU7HyD44Xiegtn6HVVUk=ZW5g@mail.gmail.com>
	<CAMTFtYLG2fkLdCUAowod+VZPoyukW+Eqi87McrAL2Tf6+ww-Zg@mail.gmail.com>
	<83AA68EE-F0BC-4753-80F9-B42165E67670@lyndir.com>
	<CAMTFtYL_gzKuPjmUoJqHyPOusgFz-eqbBjZXUb8BHnZwFny9Qw@mail.gmail.com>
From: Clark Wang <clark.wang@oracle.com>
Date: Wed, 11 Apr 2012 09:53:24 +0800
Message-ID: <CADv8-ohBUDSuMQfS766ceuuybLmRq6XDEYnObqi4zJAxccmVjw@mail.gmail.com>
Subject: Re: semicolon at beginning of line
To: Elliott Forney <elliott.forney@gmail.com>
X-Source-IP: acsinet21.oracle.com [141.146.126.237]
X-CT-RefId: str=0001.0A090201.4F84E42A.0076,ss=1,re=0.000,fgs=0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1)
X-Received-From: 148.87.113.117
X-Mailman-Approved-At: Wed, 11 Apr 2012 02:23:23 -0400
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: "bash.bug list" <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 11 Apr 2012 01:53:55 -0000

On Tue, Apr 10, 2012 at 16:38, Elliott Forney <elliott.forney@gmail.com>wrote:

> On Tue, Apr 10, 2012 at 1:22 AM, Maarten Billemont <lhunath@lyndir.com>
> wrote:
> > People should stop trying to execute code by parameter expansion, and
> specifically stop thinking that parameter-expanded words are evaluated as
> bash code.
>
> I still think the behavior is interesting.  The statement may not be
> empty but nothing other than the expansion is executed.
>
> > OK, so you're saying, let's change bash so that an empty statement
> becomes a noop statement.
>
> Yes.  It already is when a newline is received.  Why not when an empty
> statement is terminated with a semicolon?
>
> >Except for when that empty statement is preceded by a semicolon and
> happens to have no whitespace, because then it could be a case delimiter.
>
> Yes.  Just like "$(" differs from "$((" and "[" from "[[" and ">" from
> ">>".  This would not be unique syntax in bash.
>
> > Frankly, what are you hoping to gain from this?
>
> I simply believe it is intuitive; this is the behavior I would expect
> before trying it.
>

+1

>
> > This will just introduce new rules with new exceptions and
> inconsistencies.  If it were possible to do a blanket rule: empty
> statements before a semicolon are noops, I might be OK with it, but if it
> requires adding additional addendums to the rule, "oh wait, except for this
> and that case", my vote is out.
>
> I really don't think it would cause lots of problems.  This belief is
> supported by the fact that this is already implemented in other
> shells.  Try the examples I have given in zsh and you will see the
> behavior I would expect.  Try it in ksh and you will see something
> closer to the blanket rule you suggest.
>
> If no one else agrees then that's cool but my vote is to change it.
>
> Thanks,
>  Elliott Forney
>
>

From MAILER-DAEMON Wed Apr 11 03:19:15 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHrpj-00063D-TK
	for mharc-bug-bash@gnu.org; Wed, 11 Apr 2012 03:19:15 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41056)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SHrpc-0005ys-AB
	for bug-bash@gnu.org; Wed, 11 Apr 2012 03:19:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SHrpV-000857-Vd
	for bug-bash@gnu.org; Wed, 11 Apr 2012 03:19:07 -0400
Received: from mail-out.m-online.net ([212.18.0.10]:38364)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SHrpV-00084u-PC
	for bug-bash@gnu.org; Wed, 11 Apr 2012 03:19:01 -0400
Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net
	[192.168.8.180])
	by mail-out.m-online.net (Postfix) with ESMTP id 3VSGnv4d0bz3hhXf;
	Wed, 11 Apr 2012 09:18:59 +0200 (CEST)
Received: from igel.home (ppp-88-217-97-6.dynamic.mnet-online.de [88.217.97.6])
	by mail.mnet-online.de (Postfix) with ESMTPA id 3VSGnv4C4Nz4KK4V;
	Wed, 11 Apr 2012 09:18:59 +0200 (CEST)
Received: by igel.home (Postfix, from userid 501)
	id 5139ACA2A9; Wed, 11 Apr 2012 09:18:59 +0200 (CEST)
From: Andreas Schwab <schwab@linux-m68k.org>
To: gnachman@llamas.org
Subject: Re: Writing to bash's tty too fast: workarounds?
References: <e4f419d3-06ed-475e-a714-7908f46b28cf@r33g2000prh.googlegroups.com>
	<4F845DC6.1080309@case.edu>
	<CAB5RqomjRh9zzS5_M_vkGLO1S5fg6XE77BmW+J9FGSjsZto7Qg@mail.gmail.com>
X-Yow: ..  this must be what it's like to be a COLLEGE GRADUATE!!
Date: Wed, 11 Apr 2012 09:18:59 +0200
In-Reply-To: <CAB5RqomjRh9zzS5_M_vkGLO1S5fg6XE77BmW+J9FGSjsZto7Qg@mail.gmail.com>
	(George Nachman's message of "Tue, 10 Apr 2012 10:22:19 -0700")
Message-ID: <m2iph6ybvg.fsf@igel.home>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	4)
X-Received-From: 212.18.0.10
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 11 Apr 2012 07:19:14 -0000

George Nachman <gnachman@gmail.com> writes:

> In the case of bash + readline, would it be feasible to avoid readline
> changing the terminal settings while reading a here document?

>From the view of readline there is no difference between reading a
line inside or outside of a here-document.  Both should allow full
access to the editing capabilities of readline.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


From MAILER-DAEMON Wed Apr 11 05:34:21 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHtwT-0000m9-F0
	for mharc-bug-bash@gnu.org; Wed, 11 Apr 2012 05:34:21 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50431)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SHtwM-0000lR-3T
	for bug-bash@gnu.org; Wed, 11 Apr 2012 05:34:19 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SHtwG-0006BB-La
	for bug-bash@gnu.org; Wed, 11 Apr 2012 05:34:13 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:36098
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SHtwG-00064q-8X
	for bug-bash@gnu.org; Wed, 11 Apr 2012 05:34:08 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3B9Y1jV031279
	for <bug-bash@gnu.org>; Wed, 11 Apr 2012 02:34:04 -0700
Message-ID: <4F855009.3060705@tlinx.org>
Date: Wed, 11 Apr 2012 02:34:01 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F8387B7.2060108@tlinx.org> <4F839F3C.8020807@case.edu>
In-Reply-To: <4F839F3C.8020807@case.edu>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 11 Apr 2012 09:34:20 -0000



Chet Ramey wrote:

> On 4/9/12 9:07 PM, Linda Walsh wrote:
>>
>> ** linux-kernel -- all over the place...
>>
>> At that point, I was getting too many to keep up with ... so I stopped
>> searching...
>>
>> $[] has is -- I would bet, Universally, used MORE than $(())...
> 
> I believe you'd lose, but it's unprovable either way.  Consider the fact,
> though, that bash and zsh support $[...], ksh93 and dash support only
> $((...)), but that all four support $((...)).

----

Well, I think you are probably right -- looks like alot of newer more
bash-specific, and 'clever' code uses (())...  but it isn't easy on the eyes...


But the examples of use of $(()) are leaning far more toward the perverse side
than simple use of $[]...

Maybe lisp programmers prefer (())??

a few examples:


- options="$(expr "${options}" : "\(.\{$((${last_option_index}-1))\}\)")"
- YESTERDAY=$(date -r $((`date +%s` - 86400 )) +%d/%m/%Y
- PREGAP=$(($(echo $OFFSETS | cut -f1 -d' ')))

- for ((vl=$((v_level - 1)); $vl > 0; --vl))

Using [] in expressions provides a distinct visual feature that is
different from the content....   There's no unclarity in confusing it
with $(xxx) $((xxx)) if xxx is a var and a function, which did they mean?

You don't hae that issue with $[], as to confuse it with an array, you'd
have to leave off the array name and the curly brackets...
======================================================================
Maarten Billemont wrote:

 > (Don't give

 >  me the spiel about how [...] is already arithmetic evaluation
 > inside array indices, that's a different syntax  entirely,

How is that?  I thought it WAS the syntax.

${xxx[yyy]}  => remove the array base, and you just get a calculated
offset as a result

=> $[yyy]...

It is similar to C in that regard.   You can put [xxx] after an ID, and it
means it is an array # of items past the array's start.  but if the array was
missing.  (well besides the syntax errors), it would just be the offset.



 >>> BTW, in case there is any doubt, I am not pushing for removal of $(()), or 
a change of the status quo, but I am taking issue with the idea of removing $[],
as some proposed...




>> Chet -- you should get back to the posix folks and tell them posix is to be
>> 'descriptive of usage' (their words), not prescriptive.   Just because ksh
>> did it differently from everyone else's usage doesn't mean they should go
>> with that syntax...
> 
> You have got to be kidding.  Don't you realize you're talking about
> decisions that are nearly 20 years old?  That $[...] was a Posix
> invention that only ever appeared in P1003.2d9?  That the $((...))
> syntax was adopted officially for P1003.2-1992?  That's 1992.  Twenty
> years ago.

====


> Now, it's hardly any problem to keep dragging the $[...] syntax along.
> It takes only a few dozen bytes of code.  I have no plans to remove it.
> But let's not kid ourselves: it's revisionist history to think that
> $[...] was widespread before Posix so callously stamped it out.

----
	I've seen it more often in portable code than the $(()) -- but I
could be remembering it more because it stands out too...


> 
>> Geez.
> 
> Indeed.

> 

	Indubitably.
:-)



From MAILER-DAEMON Wed Apr 11 08:11:57 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SHwOz-00079Q-GC
	for mharc-bug-bash@gnu.org; Wed, 11 Apr 2012 08:11:57 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57383)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SHwOr-00076F-Ix
	for bug-bash@gnu.org; Wed, 11 Apr 2012 08:11:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SHwOp-0007z8-TM
	for bug-bash@gnu.org; Wed, 11 Apr 2012 08:11:49 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:37613
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SHwOp-0007xD-MO
	for bug-bash@gnu.org; Wed, 11 Apr 2012 08:11:47 -0400
Received: (qmail 18392 invoked from network); 11 Apr 2012 12:11:20 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 11 Apr 2012 08:11:20 -0400
Received: (qmail 12743 invoked by uid 563); 11 Apr 2012 12:11:20 -0000
Date: Wed, 11 Apr 2012 08:11:19 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Linda Walsh <bash@tlinx.org>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
Message-ID: <20120411121119.GF22241@eeg.ccf.org>
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F8387B7.2060108@tlinx.org> <4F839F3C.8020807@case.edu>
	<4F855009.3060705@tlinx.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F855009.3060705@tlinx.org>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 11 Apr 2012 12:11:55 -0000

On Wed, Apr 11, 2012 at 02:34:01AM -0700, Linda Walsh wrote:
> - for ((vl=$((v_level - 1)); $vl > 0; --vl))

The inside of the for ((...)) is already a math context.  You don't need
another $((...)) inside it.

for ((vl = v_level - 1; vl > 0; --vl))

Or is that another "irrelevant detail"?


From MAILER-DAEMON Wed Apr 11 14:50:33 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SI2ci-0007DC-Ri
	for mharc-bug-bash@gnu.org; Wed, 11 Apr 2012 14:50:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48214)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SI2cX-0006ce-K9
	for bug-bash@gnu.org; Wed, 11 Apr 2012 14:50:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SI2cV-0005El-W1
	for bug-bash@gnu.org; Wed, 11 Apr 2012 14:50:21 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:37699
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SI2cV-0005EB-Sh
	for bug-bash@gnu.org; Wed, 11 Apr 2012 14:50:19 -0400
Received: (qmail 22089 invoked from network); 11 Apr 2012 18:50:15 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 11 Apr 2012 14:50:15 -0400
Received: (qmail 13063 invoked by uid 563); 11 Apr 2012 18:50:14 -0000
Date: Wed, 11 Apr 2012 14:50:14 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: bug-bash@gnu.org
Subject: inconsistency with "readonly" and scope
Message-ID: <20120411185014.GG22241@eeg.ccf.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 11 Apr 2012 18:50:28 -0000

"declare" when used in a function acts like "local", and creates a variable
with scope local to that function.  So does "declare -r".  But "readonly",
which is otherwise the same as "declare -r", creates variables with global
scope.

Is this intended?

Tested with 2.05b, 3.something, and 4.2.20.


From MAILER-DAEMON Wed Apr 11 16:12:17 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SI3tp-0006mJ-5G
	for mharc-bug-bash@gnu.org; Wed, 11 Apr 2012 16:12:17 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58780)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SI3tn-0006lZ-4Y
	for bug-bash@gnu.org; Wed, 11 Apr 2012 16:12:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SI3tl-0004nM-Gw
	for bug-bash@gnu.org; Wed, 11 Apr 2012 16:12:14 -0400
Received: from fmmailgate07.web.de ([217.72.192.248]:59712)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SI3tl-0004n0-AW
	for bug-bash@gnu.org; Wed, 11 Apr 2012 16:12:13 -0400
Received: from moweb001.kundenserver.de (moweb001.kundenserver.de
	[172.19.20.114])
	by fmmailgate07.web.de (Postfix) with ESMTP id 1D49211534CF
	for <bug-bash@gnu.org>; Wed, 11 Apr 2012 22:12:11 +0200 (CEST)
Received: from [192.168.178.49] ([93.134.93.221]) by smtp.web.de (mrweb001)
	with ESMTPA (Nemesis) id 0Le4fk-1Rx0pK3cHU-00pt5K;
	Wed, 11 Apr 2012 22:12:10 +0200
Message-ID: <4F85E59C.4020702@web.de>
Date: Wed, 11 Apr 2012 22:12:12 +0200
From: dethrophes <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>
In-Reply-To: <20120411185014.GG22241@eeg.ccf.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:IpGXhiHFDrcfVUsNwS8Bd8zYkVEMq4yVk4xxTc1opxv
	k40Oe48lSjOrAteE9xBHid0O94tRbRhgXQKQ6ZRN2/7864zYAp
	alIq6oOjcWGtpQ0adON5kqZYVjKJ/q5C8yU9vcNDzB+9pysGa/
	AV4VWWtNnjQN89lAXjNhG6yyBR5CW/8z/v7wY2xua7WTvJT5Hb
	bpFpqeiY2ganfiIdE4aeQ==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.248
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 11 Apr 2012 20:12:16 -0000

Am 11.04.2012 20:50, schrieb Greg Wooledge:
> "declare" when used in a function acts like "local", and creates a variable
> with scope local to that function.  So does "declare -r".  But "readonly",
> which is otherwise the same as "declare -r", creates variables with global
> scope.
>
> Is this intended?
>
> Tested with 2.05b, 3.something, and 4.2.20.
>
I've also noticed weird behavior with "declare -gr" the r sometimes 
seems to override the g, but not specific to functions It seems to be 
specific either to the source file or to the compound statement. I 
haven't been able to figure out exactly whats going on there. I haven't 
been able to reproduce it in a simple example. this is most readily 
noticeable with set -o nounset


From MAILER-DAEMON Thu Apr 12 01:01:28 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIC9w-0004GP-0R
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 01:01:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53290)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIC9t-0004Fm-9q
	for bug-bash@gnu.org; Thu, 12 Apr 2012 01:01:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIC9q-0005zE-O9
	for bug-bash@gnu.org; Thu, 12 Apr 2012 01:01:24 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:56195
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIC9q-0005yn-AF
	for bug-bash@gnu.org; Thu, 12 Apr 2012 01:01:22 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3C51DoR024579; Wed, 11 Apr 2012 22:01:15 -0700
Message-ID: <4F866198.1050008@tlinx.org>
Date: Wed, 11 Apr 2012 22:01:12 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F8387B7.2060108@tlinx.org> <4F839F3C.8020807@case.edu>
	<4F855009.3060705@tlinx.org> <20120411121119.GF22241@eeg.ccf.org>
In-Reply-To: <20120411121119.GF22241@eeg.ccf.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 12 Apr 2012 05:01:26 -0000



Greg Wooledge wrote:

> On Wed, Apr 11, 2012 at 02:34:01AM -0700, Linda Walsh wrote:
>> - for ((vl=$((v_level - 1)); $vl > 0; --vl))
> 
> The inside of the for ((...)) is already a math context.  You don't need
> another $((...)) inside it.
> 
> for ((vl = v_level - 1; vl > 0; --vl))
> 
> Or is that another "irrelevant detail"?



Um... Why do you think I included it --
I NEVER saw anything like that where [] was used... people
seem to not understand the (()) is arith, but you need $(()) to get
the value out of the insides...



But the examples of use of $(()) are leaning far more toward the perverse side
than simple use of $[]..
a few examples:

- options="$(expr "${options}" : "\(.\{$((${last_option_index}-1))\}\)")"
- YESTERDAY=$(date -r $((`date +%s` - 86400 )) +%d/%m/%Y
- PREGAP=$(($(echo $OFFSETS | cut -f1 -d' ')))

- for ((vl=$((v_level - 1)); $vl > 0; --vl))

---------------------

It's irrelevant to 'function', but not to efficiency or readability.

But hey, gold star for paying attention! ;-)

(those are all examples from various system scripts in /usr...






From MAILER-DAEMON Thu Apr 12 03:48:40 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIElk-0000f1-EC
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 03:48:40 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41267)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SIEld-0000ei-No
	for bug-bash@gnu.org; Thu, 12 Apr 2012 03:48:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SIElb-0001Zv-Pm
	for bug-bash@gnu.org; Thu, 12 Apr 2012 03:48:33 -0400
Received: from mail-out.m-online.net ([212.18.0.9]:46163)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SIElb-0001Zi-JR
	for bug-bash@gnu.org; Thu, 12 Apr 2012 03:48:31 -0400
Received: from frontend1.mail.m-online.net (unknown [192.168.8.180])
	by mail-out.m-online.net (Postfix) with ESMTP id 3VSvPT0Gc0z4Kn8Z;
	Thu, 12 Apr 2012 09:48:28 +0200 (CEST)
Received: from igel.home (ppp-88-217-109-29.dynamic.mnet-online.de
	[88.217.109.29])
	by mail.mnet-online.de (Postfix) with ESMTPA id 3VSvPS37hvz4KK7J;
	Thu, 12 Apr 2012 09:48:28 +0200 (CEST)
Received: by igel.home (Postfix, from userid 501)
	id 1ADC2CA2AA; Thu, 12 Apr 2012 09:48:28 +0200 (CEST)
From: Andreas Schwab <schwab@linux-m68k.org>
To: Linda Walsh <bash@tlinx.org>
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
References: <4F80A783.6040900@tlinx.org> <4F80D201.6010308@case.edu>
	<40C5EE3A-8D5E-4718-966F-8922B809ECE9@lyndir.com>
	<4F8387B7.2060108@tlinx.org> <4F839F3C.8020807@case.edu>
	<4F855009.3060705@tlinx.org> <20120411121119.GF22241@eeg.ccf.org>
	<4F866198.1050008@tlinx.org>
X-Yow: Did you GAIN WEIGHT in th' past 5 MINUTES or am I just DREAMING of two
	BROCCOLI FLORETS lying in an empty GAS TANK?
Date: Thu, 12 Apr 2012 09:48:27 +0200
In-Reply-To: <4F866198.1050008@tlinx.org> (Linda Walsh's message of "Wed, 11
	Apr 2012 22:01:12 -0700")
Message-ID: <m2d37dz8z8.fsf@igel.home>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	4)
X-Received-From: 212.18.0.9
Cc: Greg Wooledge <wooledg@eeg.ccf.org>, bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 12 Apr 2012 07:48:39 -0000

Linda Walsh <bash@tlinx.org> writes:

> - YESTERDAY=$(date -r $((`date +%s` - 86400 )) +%d/%m/%Y

This fails around autumn DST transition (assuming s/-r /-d @/).

    YESTERDAY=$(date -d '12:00 yesterday' +%d/%m/%Y)

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


From MAILER-DAEMON Thu Apr 12 08:27:38 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIJ7i-0002zk-Gd
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 08:27:38 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50983)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIJ7c-0002yU-CK
	for bug-bash@gnu.org; Thu, 12 Apr 2012 08:27:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIJ7V-0004xh-S1
	for bug-bash@gnu.org; Thu, 12 Apr 2012 08:27:31 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:28170)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIJ7V-0004xN-Ng
	for bug-bash@gnu.org; Thu, 12 Apr 2012 08:27:25 -0400
Received: from mpv5.tis.CWRU.Edu (EHLO mpv5.cwru.edu) ([129.22.105.51])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXP51838; Thu, 12 Apr 2012 08:27:23 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AVW51294 (AUTH cpr);
	Thu, 12 Apr 2012 08:27:23 -0400 (EDT)
Message-ID: <4F86CA2B.4010400@case.edu>
Date: Thu, 12 Apr 2012 08:27:23 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: dethrophes <dethrophes@web.de>
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org> <4F85E59C.4020702@web.de>
In-Reply-To: <4F85E59C.4020702@web.de>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 12 Apr 2012 12:27:36 -0000

On 4/11/12 4:12 PM, dethrophes wrote:

> I've also noticed weird behavior with "declare -gr" the r sometimes seems
> to override the g, but not specific to functions It seems to be specific
> either to the source file or to the compound statement. I haven't been able
> to figure out exactly whats going on there. I haven't been able to
> reproduce it in a simple example. this is most readily noticeable with set
> -o nounset

An example would help.  The above is supposed to create a global readonly
variable.  I suspect that you see the `global' as being `overridden'
because it's being created in a subshell environment.

Chet



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


From MAILER-DAEMON Thu Apr 12 08:33:58 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIJDq-0004xr-8E
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 08:33:58 -0400
Received: from eggs.gnu.org ([208.118.235.92]:38678)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIJDn-0004wX-CU
	for bug-bash@gnu.org; Thu, 12 Apr 2012 08:33:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIJDd-0006ap-CA
	for bug-bash@gnu.org; Thu, 12 Apr 2012 08:33:54 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:28426)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIJDd-0006ae-8w
	for bug-bash@gnu.org; Thu, 12 Apr 2012 08:33:45 -0400
Received: from mpv5.tis.CWRU.Edu (EHLO mpv5.cwru.edu) ([129.22.105.51])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXP52170; Thu, 12 Apr 2012 08:33:44 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AVW51793 (AUTH cpr);
	Thu, 12 Apr 2012 08:33:43 -0400 (EDT)
Message-ID: <4F86CBA7.9030305@case.edu>
Date: Thu, 12 Apr 2012 08:33:43 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>
In-Reply-To: <20120411185014.GG22241@eeg.ccf.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 12 Apr 2012 12:33:56 -0000

On 4/11/12 2:50 PM, Greg Wooledge wrote:
> "declare" when used in a function acts like "local", and creates a variable
> with scope local to that function.  So does "declare -r".  But "readonly",
> which is otherwise the same as "declare -r", creates variables with global
> scope.
> 
> Is this intended?

Yes.  `readonly' is part of Posix, and behaves as Posix specifies.
`declare' is not, and can do what it likes.

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


From MAILER-DAEMON Thu Apr 12 13:07:01 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SINU5-0008RX-2L
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 13:07:01 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41780)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SIMqB-0005ZR-LD
	for bug-bash@gnu.org; Thu, 12 Apr 2012 12:25:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SIMq5-0001bW-CN
	for bug-bash@gnu.org; Thu, 12 Apr 2012 12:25:47 -0400
Received: from rcsinet15.oracle.com ([148.87.113.117]:25717)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SIMq5-0001ao-5n
	for bug-bash@gnu.org; Thu, 12 Apr 2012 12:25:41 -0400
Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237])
	by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with
	ESMTP id q3CGPa2i004511
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Thu, 12 Apr 2012 16:25:36 GMT
Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156])
	by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
	q3CGPZtD026183
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <bug-bash@gnu.org>; Thu, 12 Apr 2012 16:25:35 GMT
Received: from abhmt105.oracle.com (abhmt105.oracle.com [141.146.116.57])
	by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id
	q3CGPYN6014566
	for <bug-bash@gnu.org>; Thu, 12 Apr 2012 11:25:35 -0500
Received: from [10.163.101.52] (/10.163.101.52)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Thu, 12 Apr 2012 09:25:34 -0700
Message-ID: <4F8701F3.6000002@oracle.com>
Date: Thu, 12 Apr 2012 18:25:23 +0200
From: Petr Sumbera <petr.sumbera@oracle.com>
User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US;
	rv:1.9.2.13) Gecko/20110117 Lightning/1.0b2 Thunderbird/3.1.7
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: small fix for lib/sh/snprintf.c
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Source-IP: acsinet21.oracle.com [141.146.126.237]
X-CT-RefId: str=0001.0A090209.4F870201.004F,ss=1,re=0.000,fgs=0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1)
X-Received-From: 148.87.113.117
X-Mailman-Approved-At: Thu, 12 Apr 2012 13:06:59 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 12 Apr 2012 16:25:53 -0000

Hi,

we are running Bash 3.2.38 on Solaris 10 where asprintf() isn't 
available. Thus code in snprintf.c is used.

There is a problem with following command:

bash -c 'printf "x%10.0fx\n" 123'
x0000000123x

Where correct output should be:
x       123x

It seems that '0' after '.' enables zero padding. Please see proposed 
patch bellow:

--- bash-3.2.48/lib/sh/snprintf.c       Tue Dec 12 12:10:18 2006
+++ bash-3.2.48/lib/sh/snprintf.c       Thu Apr 12 08:55:44 2012
@@ -1277,6 +1277,8 @@
                 data->flags |= PF_ALTFORM;
                 continue;
               case '0':
+               if (data->flags & PF_DOT)
+                 continue;
                 data->flags |= PF_ZEROPAD;
                 data->pad = '0';
                 continue;

The same code seems to be also in Bash 4.1 so I guess the problem is 
still there.

Any comments?

Thanks,

Petr



From MAILER-DAEMON Thu Apr 12 13:16:17 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SINd3-0001ia-At
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 13:16:17 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49941)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <news@schlund.de>) id 1SINcx-0001gm-L3
	for bug-bash@gnu.org; Thu, 12 Apr 2012 13:16:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <news@schlund.de>) id 1SINct-0008Uw-12
	for bug-bash@gnu.org; Thu, 12 Apr 2012 13:16:11 -0400
Received: from moderators.schnuerpel.eu ([178.63.61.184]:46379
	helo=four.schnuerpel.eu) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <news@schlund.de>) id 1SINcs-0008Ug-Qq
	for bug-bash@gnu.org; Thu, 12 Apr 2012 13:16:06 -0400
Received: from mxintern.schlund.de (mxintern.schlund.de [212.227.126.205])
	by moderators.schnuerpel.eu (Postfix) with ESMTP id 9B89546B
	for <gnu-bash-bug@moderators.isc.org>;
	Thu, 12 Apr 2012 19:16:03 +0200 (CEST)
Received: from [195.20.224.124] (helo=news.schlund.de)
	by mxintern.schlund.de with esmtp (envelope-from <news@schlund.de>)
	id 1SINcp-000dny-7n
	for gnu-bash-bug@moderators.isc.org; Thu, 12 Apr 2012 19:16:03 +0200
Received: from news by news.schlund.de with local (Exim 3.35 #1 (Debian))
	id 1SINco-0004Qo-00
	for <gnu-bash-bug@moderators.isc.org>; Thu, 12 Apr 2012 19:16:02 +0200
To: gnu-bash-bug@moderators.isc.org
Path: news.online.de!not-for-mail
From: "Joachim Schmitz" <nospam.jojo@schmitz-digital.de>
Newsgroups: gnu.bash.bug
Subject: Re: small fix for lib/sh/snprintf.c
Date: Thu, 12 Apr 2012 19:15:42 +0200
Organization: 1&1 Internet AG
Lines: 33
Message-ID: <jm72ki$gkd$1@online.de>
References: <mailman.1178.1334250420.20052.bug-bash@gnu.org>
NNTP-Posting-Host: dsdf-4db506ca.pool.mediaways.net
Mime-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
	reply-type=response
Content-Transfer-Encoding: 7bit
X-Trace: online.de 1334250962 17037 77.181.6.202 (12 Apr 2012 17:16:02 GMT)
X-Complaints-To: abuse@einsundeins.com
NNTP-Posting-Date: Thu, 12 Apr 2012 17:16:02 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157
Sender: news <news@schlund.de>
X-Virus-Scanned: Symantec AntiVirus Scan Engine
X-UI-Msg-Verification: fc4dcfece7d39d0d93dc8f1b0d7c663b
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 178.63.61.184
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: Joachim Schmitz <jojo@schmitz-digital.de>
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, 12 Apr 2012 17:16:16 -0000

Petr Sumbera wrote:
> Hi,
> 
> we are running Bash 3.2.38 on Solaris 10 where asprintf() isn't
> available. Thus code in snprintf.c is used.
> 
> There is a problem with following command:
> 
> bash -c 'printf "x%10.0fx\n" 123'
> x0000000123x
> 
> Where correct output should be:
> x       123x
> 
> It seems that '0' after '.' enables zero padding. Please see proposed
> patch bellow:
> 
> --- bash-3.2.48/lib/sh/snprintf.c       Tue Dec 12 12:10:18 2006
> +++ bash-3.2.48/lib/sh/snprintf.c       Thu Apr 12 08:55:44 2012
> @@ -1277,6 +1277,8 @@
>                 data->flags |= PF_ALTFORM;
>                 continue;
>               case '0':
> +               if (data->flags & PF_DOT)
> +                 continue;
>                 data->flags |= PF_ZEROPAD;
>                 data->pad = '0';
>                 continue;
> 
> The same code seems to be also in Bash 4.1 so I guess the problem is
> still there.

Same code is in bash-4.2.24, the latest currently


From MAILER-DAEMON Thu Apr 12 14:16:41 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIOZV-0004IP-AG
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 14:16:41 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45635)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SIOZS-0004II-W6
	for bug-bash@gnu.org; Thu, 12 Apr 2012 14:16:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SIOZR-0000TT-BX
	for bug-bash@gnu.org; Thu, 12 Apr 2012 14:16:38 -0400
Received: from fmmailgate06.web.de ([217.72.192.247]:43013)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SIOZR-0000TK-26
	for bug-bash@gnu.org; Thu, 12 Apr 2012 14:16:37 -0400
Received: from moweb001.kundenserver.de (moweb001.kundenserver.de
	[172.19.20.114])
	by fmmailgate06.web.de (Postfix) with ESMTP id 7069811FE303
	for <bug-bash@gnu.org>; Thu, 12 Apr 2012 20:16:35 +0200 (CEST)
Received: from [192.168.178.49] ([77.13.105.141]) by smtp.web.de (mrweb001)
	with ESMTPA (Nemesis) id 0Mb8h9-1SbQtM0edv-00Kik0;
	Thu, 12 Apr 2012 20:16:35 +0200
Message-ID: <4F871C05.10204@web.de>
Date: Thu, 12 Apr 2012 20:16:37 +0200
From: dethrophes <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org> <4F85E59C.4020702@web.de>
	<4F86CA2B.4010400@case.edu>
In-Reply-To: <4F86CA2B.4010400@case.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:FSYduXUJ8Dle/S0Mlvsvc7Qiz+9+wb9AnQG87q2flJe
	/jeHtSmadA0ocSNyq/GJ0N9dW8ixhCVDxbIjCBeoIfV0wA6inH
	rV1+Y1jp5bvsFmIdNr6iq89fQC/l9791ieEs4ciYi8PwzjoKbj
	EgyC7psK7cd/EIPHDusBl4y6UImwRSccyjZSpeUEfWP2nOciRw
	UVCWoAuNKbZjiDlwc61mA==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.247
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 12 Apr 2012 18:16:40 -0000

Am 12.04.2012 14:27, schrieb Chet Ramey:
> On 4/11/12 4:12 PM, dethrophes wrote:
>
>> I've also noticed weird behavior with "declare -gr" the r sometimes seems
>> to override the g, but not specific to functions It seems to be specific
>> either to the source file or to the compound statement. I haven't been able
>> to figure out exactly whats going on there. I haven't been able to
>> reproduce it in a simple example. this is most readily noticeable with set
>> -o nounset
> An example would help.  The above is supposed to create a global readonly
> variable.  I suspect that you see the `global' as being `overridden'
> because it's being created in a subshell environment.
>
> Chet
>
>
>
I only see the problem in large complex cases, I've tried to reproduce a 
simple example a couple of times but without success.
no its not a subshell problem, I avoid subshells as much as possible.
also when I expereimented with the problem a couple of times I 
discovered the following-
declare -g                     works
declare -gr                     doesn't work
my current workaround is I've just stopped using the readonly attribute 
which works. or just stopped using declare altogether.
or do something like this
var=x
typeset -r var

I've also seen some strange behavior with
declare in a conditional sourced global context. it only seems to happen 
when the code size is 10000s+ lines long.
I think this is exasperated by the fact that i source my files inside 
conditional statements. the result is that I now even in a global 
context set the global flag.

any ideas what could be causing it would help me try to figure out how 
to test for it.

Sorry about the weak description but I've been working around it now for 
months waiting for it to make sense and I'm no closer to figuring out 
whats going on.
the problem is so erratic it has to be some sort of partial lost context 
or something.

can you give me any tips on how to debug it if I can reproduce it again? 
is their an easy way to track the validity of a variable?








From MAILER-DAEMON Thu Apr 12 16:11:59 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIQN5-0006WH-Mi
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 16:11:59 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55377)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SIQN3-0006W8-5G
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:11:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SIQN1-000281-0v
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:11:56 -0400
Received: from saturn.syslang.net ([207.172.210.41]:44587)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SIQN0-00027k-SC
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:11:54 -0400
Received: from [IPv6:::1] (localhost [127.0.0.1])
	by saturn.syslang.net (8.14.5/8.14.5) with ESMTP id q3CKBpqa028129
	for <bug-bash@gnu.org>; Thu, 12 Apr 2012 16:11:52 -0400
Message-ID: <4F873708.10207@syslang.net>
Date: Thu, 12 Apr 2012 16:11:52 -0400
From: "Steven W. Orr" <steveo@syslang.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
	rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>
	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>
	<4F871C05.10204@web.de>
In-Reply-To: <4F871C05.10204@web.de>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 207.172.210.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 12 Apr 2012 20:11:58 -0000

On 4/12/2012 2:16 PM, dethrophes wrote:
> Am 12.04.2012 14:27, schrieb Chet Ramey:
>> On 4/11/12 4:12 PM, dethrophes wrote:
>>
>>> I've also noticed weird behavior with "declare -gr" the r sometimes seems
>>> to override the g, but not specific to functions It seems to be specific
>>> either to the source file or to the compound statement. I haven't been able
>>> to figure out exactly whats going on there. I haven't been able to
>>> reproduce it in a simple example. this is most readily noticeable with set
>>> -o nounset
>> An example would help. The above is supposed to create a global readonly
>> variable. I suspect that you see the `global' as being `overridden'
>> because it's being created in a subshell environment.
>>
>> Chet

It took me a second to reproduce it, but here it is:

----------------------
#! /bin/bash

A()
{
     typeset v1=Hello

     B
     echo "IN B:$v1"
}

B()
{
     typeset -r v1=Goodbye

     :
}
typeset -r v1=abc
A
echo "v1:$v1"
--------------------------

This is 4.0.35(1).

The v1 that's set to abc is the global one.
A defines a local copy that's not readonly and B defines one that is. When I 
run it I get:

950 > ./foo.sh
./foo.sh: line 5: typeset: v1: readonly variable
./foo.sh: line 13: typeset: v1: readonly variable
IN B:abc
v1:abc

This means that the typeset failed is both A and B and the references in the 
routines fell back to the global instance of v1.

Does this help?

>>
>>
>>
> I only see the problem in large complex cases, I've tried to reproduce a
> simple example a couple of times but without success.
> no its not a subshell problem, I avoid subshells as much as possible.
> also when I expereimented with the problem a couple of times I discovered the
> following-
> declare -g works
> declare -gr doesn't work
> my current workaround is I've just stopped using the readonly attribute which
> works. or just stopped using declare altogether.
> or do something like this
> var=x
> typeset -r var
>
> I've also seen some strange behavior with
> declare in a conditional sourced global context. it only seems to happen when
> the code size is 10000s+ lines long.
> I think this is exasperated by the fact that i source my files inside
> conditional statements. the result is that I now even in a global context set
> the global flag.
>
> any ideas what could be causing it would help me try to figure out how to test
> for it.
>
> Sorry about the weak description but I've been working around it now for
> months waiting for it to make sense and I'm no closer to figuring out whats
> going on.
> the problem is so erratic it has to be some sort of partial lost context or
> something.
>
> can you give me any tips on how to debug it if I can reproduce it again? is
> their an easy way to track the validity of a variable?
>
>
>
>
>
>


-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


From MAILER-DAEMON Thu Apr 12 16:21:26 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIQWE-0007Im-SD
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 16:21:26 -0400
Received: from eggs.gnu.org ([208.118.235.92]:43328)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SIQWC-0007HT-9F
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:21:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SIQW9-0004pi-4z
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:21:23 -0400
Received: from fmmailgate07.web.de ([217.72.192.248]:56232)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SIQW8-0004pF-Ro
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:21:21 -0400
Received: from moweb001.kundenserver.de (moweb001.kundenserver.de
	[172.19.20.114])
	by fmmailgate07.web.de (Postfix) with ESMTP id A053B116BDF9
	for <bug-bash@gnu.org>; Thu, 12 Apr 2012 22:21:18 +0200 (CEST)
Received: from [192.168.178.49] ([77.13.105.141]) by smtp.web.de (mrweb002)
	with ESMTPA (Nemesis) id 0MOj14-1SLAKm1jE6-0066gi;
	Thu, 12 Apr 2012 22:21:18 +0200
Message-ID: <4F873941.2030800@web.de>
Date: Thu, 12 Apr 2012 22:21:21 +0200
From: dethrophes <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>
	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>
	<4F871C05.10204@web.de> <4F873708.10207@syslang.net>
In-Reply-To: <4F873708.10207@syslang.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:oRaInUNMZ6Wkr5deY/OcarvvW7eDyABoIg1Xb+48niq
	Z1MAeFsOyxHtq6zB/1YPIRcQMnja2XSrV0r2wR8/A0Mkvlvjyd
	B5reO1JqiLgSoBP8YBfNyboC+84GvzIF4y8IhYLpsN1hWvDWBN
	cD45gqSXNgYPPlMLfS0nUicHTeSTXpxyLyx5AWJ1Lr46AZC+I9
	DziTpblBbIVTqIO/xao4g==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.248
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 12 Apr 2012 20:21:25 -0000

Am 12.04.2012 22:11, schrieb Steven W. Orr:
> On 4/12/2012 2:16 PM, dethrophes wrote:
>> Am 12.04.2012 14:27, schrieb Chet Ramey:
>>> On 4/11/12 4:12 PM, dethrophes wrote:
>>>
>>>> I've also noticed weird behavior with "declare -gr" the r sometimes 
>>>> seems
>>>> to override the g, but not specific to functions It seems to be 
>>>> specific
>>>> either to the source file or to the compound statement. I haven't 
>>>> been able
>>>> to figure out exactly whats going on there. I haven't been able to
>>>> reproduce it in a simple example. this is most readily noticeable 
>>>> with set
>>>> -o nounset
>>> An example would help. The above is supposed to create a global 
>>> readonly
>>> variable. I suspect that you see the `global' as being `overridden'
>>> because it's being created in a subshell environment.
>>>
>>> Chet
>
> It took me a second to reproduce it, but here it is:
>
> ----------------------
> #! /bin/bash
>
> A()
> {
>     typeset v1=Hello
>
>     B
>     echo "IN B:$v1"
> }
>
> B()
> {
>     typeset -r v1=Goodbye
>
>     :
> }
> typeset -r v1=abc
> A
> echo "v1:$v1"
> --------------------------
>
> This is 4.0.35(1).
>
> The v1 that's set to abc is the global one.
> A defines a local copy that's not readonly and B defines one that is. 
> When I run it I get:
>
> 950 > ./foo.sh
> ./foo.sh: line 5: typeset: v1: readonly variable
> ./foo.sh: line 13: typeset: v1: readonly variable
> IN B:abc
> v1:abc
>
> This means that the typeset failed is both A and B and the references 
> in the routines fell back to the global instance of v1.
>
> Does this help?
>
>>>
>>>
>>>
>> I only see the problem in large complex cases, I've tried to reproduce a
>> simple example a couple of times but without success.
>> no its not a subshell problem, I avoid subshells as much as possible.
>> also when I expereimented with the problem a couple of times I 
>> discovered the
>> following-
>> declare -g works
>> declare -gr doesn't work
>> my current workaround is I've just stopped using the readonly 
>> attribute which
>> works. or just stopped using declare altogether.
>> or do something like this
>> var=x
>> typeset -r var
>>
>> I've also seen some strange behavior with
>> declare in a conditional sourced global context. it only seems to 
>> happen when
>> the code size is 10000s+ lines long.
>> I think this is exasperated by the fact that i source my files inside
>> conditional statements. the result is that I now even in a global 
>> context set
>> the global flag.
>>
>> any ideas what could be causing it would help me try to figure out 
>> how to test
>> for it.
>>
>> Sorry about the weak description but I've been working around it now for
>> months waiting for it to make sense and I'm no closer to figuring out 
>> whats
>> going on.
>> the problem is so erratic it has to be some sort of partial lost 
>> context or
>> something.
>>
>> can you give me any tips on how to debug it if I can reproduce it 
>> again? is
>> their an easy way to track the validity of a variable?
>>
>>
>>
>>
>>
>>
>
>
I don't think it helps me but thanks for the try.
I would say zhats correct behavior. the code in the functions is only 
executed when you call the functions. So the first executed readonly 
variable is preserved.
Anyway my problem isn't with how readonly is preserved, its with how 
when I set readonly the variable seems to have a limited context even if 
I declare it explicitly global.




From MAILER-DAEMON Thu Apr 12 16:32:17 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIQgj-0000wp-SM
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 16:32:17 -0400
Received: from eggs.gnu.org ([208.118.235.92]:36613)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIQgh-0000wd-9F
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:32:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIQgf-00008h-9P
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:32:14 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:56048)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIQgf-00008U-4P
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:32:13 -0400
Received: from mpv5.cwru.edu (mpv5.tis.cwru.edu [129.22.105.51])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJV47388;
	Thu, 12 Apr 2012 16:32:11 -0400
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AVX28744 (AUTH cpr);
	Thu, 12 Apr 2012 16:32:10 -0400 (EDT)
Message-ID: <4F873BCA.5070601@case.edu>
Date: Thu, 12 Apr 2012 16:32:10 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: dethrophes <dethrophes@web.de>
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>
	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>
	<4F871C05.10204@web.de> <4F873708.10207@syslang.net>
	<4F873941.2030800@web.de>
In-Reply-To: <4F873941.2030800@web.de>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 12 Apr 2012 20:32:16 -0000

On 4/12/12 4:21 PM, dethrophes wrote:

> I don't think it helps me but thanks for the try.
> I would say zhats correct behavior. the code in the functions is only
> executed when you call the functions. So the first executed readonly
> variable is preserved.
> Anyway my problem isn't with how readonly is preserved, its with how when I
> set readonly the variable seems to have a limited context even if I declare
> it explicitly global.

Simple variables or associative arrays?  If it's associative arrays
with compound assignments, look at

http://lists.gnu.org/archive/html/help-bash/2012-04/msg00000.html


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


From MAILER-DAEMON Thu Apr 12 16:38:37 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIQmq-0001lb-Vx
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 16:38:36 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52159)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SIQmo-0001lT-21
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:38:35 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SIQml-0001ow-SK
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:38:33 -0400
Received: from saturn.syslang.net ([207.172.210.41]:44950)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SIQml-0001oj-NV
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:38:31 -0400
Received: from [IPv6:::1] (localhost [127.0.0.1])
	by saturn.syslang.net (8.14.5/8.14.5) with ESMTP id q3CKcTSO029194
	for <bug-bash@gnu.org>; Thu, 12 Apr 2012 16:38:29 -0400
Message-ID: <4F873D45.5080206@syslang.net>
Date: Thu, 12 Apr 2012 16:38:29 -0400
From: "Steven W. Orr" <steveo@syslang.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
	rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>	<4F871C05.10204@web.de>
	<4F873708.10207@syslang.net> <4F873941.2030800@web.de>
In-Reply-To: <4F873941.2030800@web.de>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 207.172.210.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 12 Apr 2012 20:38:35 -0000

On 4/12/2012 4:21 PM, dethrophes wrote:
> Am 12.04.2012 22:11, schrieb Steven W. Orr:
>> On 4/12/2012 2:16 PM, dethrophes wrote:
>>> Am 12.04.2012 14:27, schrieb Chet Ramey:
>>>> On 4/11/12 4:12 PM, dethrophes wrote:
>>>>
>>>>> I've also noticed weird behavior with "declare -gr" the r sometimes seems
>>>>> to override the g, but not specific to functions It seems to be specific
>>>>> either to the source file or to the compound statement. I haven't been able
>>>>> to figure out exactly whats going on there. I haven't been able to
>>>>> reproduce it in a simple example. this is most readily noticeable with set
>>>>> -o nounset
>>>> An example would help. The above is supposed to create a global readonly
>>>> variable. I suspect that you see the `global' as being `overridden'
>>>> because it's being created in a subshell environment.
>>>>
>>>> Chet
>>
>> It took me a second to reproduce it, but here it is:
>>
>> ----------------------
>> #! /bin/bash
>>
>> A()
>> {
>> typeset v1=Hello
>>
>> B
>> echo "IN B:$v1"
>> }
>>
>> B()
>> {
>> typeset -r v1=Goodbye
>>
>> :
>> }
>> typeset -r v1=abc
>> A
>> echo "v1:$v1"
>> --------------------------
>>
>> This is 4.0.35(1).
>>
>> The v1 that's set to abc is the global one.
>> A defines a local copy that's not readonly and B defines one that is. When I
>> run it I get:
>>
>> 950 > ./foo.sh
>> ./foo.sh: line 5: typeset: v1: readonly variable
>> ./foo.sh: line 13: typeset: v1: readonly variable
>> IN B:abc
>> v1:abc
>>
>> This means that the typeset failed is both A and B and the references in the
>> routines fell back to the global instance of v1.
>>
>> Does this help?
>>
>>>>
>>>>
>>>>
>>> I only see the problem in large complex cases, I've tried to reproduce a
>>> simple example a couple of times but without success.
>>> no its not a subshell problem, I avoid subshells as much as possible.
>>> also when I expereimented with the problem a couple of times I discovered the
>>> following-
>>> declare -g works
>>> declare -gr doesn't work
>>> my current workaround is I've just stopped using the readonly attribute which
>>> works. or just stopped using declare altogether.
>>> or do something like this
>>> var=x
>>> typeset -r var
>>>
>>> I've also seen some strange behavior with
>>> declare in a conditional sourced global context. it only seems to happen when
>>> the code size is 10000s+ lines long.
>>> I think this is exasperated by the fact that i source my files inside
>>> conditional statements. the result is that I now even in a global context set
>>> the global flag.
>>>
>>> any ideas what could be causing it would help me try to figure out how to test
>>> for it.
>>>
>>> Sorry about the weak description but I've been working around it now for
>>> months waiting for it to make sense and I'm no closer to figuring out whats
>>> going on.
>>> the problem is so erratic it has to be some sort of partial lost context or
>>> something.
>>>
>>> can you give me any tips on how to debug it if I can reproduce it again? is
>>> their an easy way to track the validity of a variable?
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
> I don't think it helps me but thanks for the try.
> I would say zhats correct behavior. the code in the functions is only executed
> when you call the functions. So the first executed readonly variable is
> preserved.
> Anyway my problem isn't with how readonly is preserved, its with how when I
> set readonly the variable seems to have a limited context even if I declare it
> explicitly global.
>
>

Ok, but do I have a point? I get your problem, but it seems like having a 
global variable that is allowed to be reinstantiated in an inner (albeit 
dynamic) scope should behave the same regardless of whether the global is 
readonly. Inside A, I don't get why I can't create a new variable whose 
failure (or success) depends on whether a previous outer scope variable exists 
as readonly.

Note that if v1 at the global scope is not readonly, the one in A *is* 
readonly, and the one in B is not, then there's no problem.

To me, this begs the question of whether all mainline code should be placed 
into a containing 'main' function so as to prevent this problem from 
occurring. Even if I do this, it still leaves me vulnerable to readonly 
variables that are sourced in before main is defined.

[I hope that didn't come off as a rant. ;-)]

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


From MAILER-DAEMON Thu Apr 12 16:43:08 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIQrE-0002zq-2W
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 16:43:08 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34706)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SIQrA-0002zT-T6
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:43:06 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SIQr8-0003AF-ME
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:43:04 -0400
Received: from fmmailgate05.web.de ([217.72.192.243]:47075)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SIQr8-0003A5-Cy
	for bug-bash@gnu.org; Thu, 12 Apr 2012 16:43:02 -0400
Received: from moweb002.kundenserver.de (moweb002.kundenserver.de
	[172.19.20.108])
	by fmmailgate05.web.de (Postfix) with ESMTP id A80EB6D76FCD
	for <bug-bash@gnu.org>; Thu, 12 Apr 2012 22:43:00 +0200 (CEST)
Received: from [192.168.178.49] ([77.13.105.141]) by smtp.web.de (mrweb002)
	with ESMTPA (Nemesis) id 0LgHau-1RvPqS1bbo-00ngGz;
	Thu, 12 Apr 2012 22:43:00 +0200
Message-ID: <4F873E58.2080404@web.de>
Date: Thu, 12 Apr 2012 22:43:04 +0200
From: dethrophes <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>	<4F871C05.10204@web.de>
	<4F873708.10207@syslang.net> <4F873941.2030800@web.de>
	<4F873D45.5080206@syslang.net>
In-Reply-To: <4F873D45.5080206@syslang.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:hTd9UBoPnUguhfknaTGZAeGmqZqhU98QOEeO9fA1U45
	Y2fPKdcweGm/NzKFSW9Y7+X+ajxc1v4IpfdlGTpernoIYGNRgQ
	Qgz4bKYHu2OfwPIgiWR1FD4B/9ZDrnuCtza5dkYtuyid0eOgUK
	RNHbjILkVErH8WeYv1QI1I3I3KVlOFXniCfPI2X3vl25wpuZU+
	kzygJgVQ0dSBZxlTpo9lQ==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.243
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 12 Apr 2012 20:43:06 -0000

Am 12.04.2012 22:38, schrieb Steven W. Orr:
> On 4/12/2012 4:21 PM, dethrophes wrote:
>> Am 12.04.2012 22:11, schrieb Steven W. Orr:
>>> On 4/12/2012 2:16 PM, dethrophes wrote:
>>>> Am 12.04.2012 14:27, schrieb Chet Ramey:
>>>>> On 4/11/12 4:12 PM, dethrophes wrote:
>>>>>
>>>>>> I've also noticed weird behavior with "declare -gr" the r 
>>>>>> sometimes seems
>>>>>> to override the g, but not specific to functions It seems to be 
>>>>>> specific
>>>>>> either to the source file or to the compound statement. I haven't 
>>>>>> been able
>>>>>> to figure out exactly whats going on there. I haven't been able to
>>>>>> reproduce it in a simple example. this is most readily noticeable 
>>>>>> with set
>>>>>> -o nounset
>>>>> An example would help. The above is supposed to create a global 
>>>>> readonly
>>>>> variable. I suspect that you see the `global' as being `overridden'
>>>>> because it's being created in a subshell environment.
>>>>>
>>>>> Chet
>>>
>>> It took me a second to reproduce it, but here it is:
>>>
>>> ----------------------
>>> #! /bin/bash
>>>
>>> A()
>>> {
>>> typeset v1=Hello
>>>
>>> B
>>> echo "IN B:$v1"
>>> }
>>>
>>> B()
>>> {
>>> typeset -r v1=Goodbye
>>>
>>> :
>>> }
>>> typeset -r v1=abc
>>> A
>>> echo "v1:$v1"
>>> --------------------------
>>>
>>> This is 4.0.35(1).
>>>
>>> The v1 that's set to abc is the global one.
>>> A defines a local copy that's not readonly and B defines one that 
>>> is. When I
>>> run it I get:
>>>
>>> 950 > ./foo.sh
>>> ./foo.sh: line 5: typeset: v1: readonly variable
>>> ./foo.sh: line 13: typeset: v1: readonly variable
>>> IN B:abc
>>> v1:abc
>>>
>>> This means that the typeset failed is both A and B and the 
>>> references in the
>>> routines fell back to the global instance of v1.
>>>
>>> Does this help?
>>>
>>>>>
>>>>>
>>>>>
>>>> I only see the problem in large complex cases, I've tried to 
>>>> reproduce a
>>>> simple example a couple of times but without success.
>>>> no its not a subshell problem, I avoid subshells as much as possible.
>>>> also when I expereimented with the problem a couple of times I 
>>>> discovered the
>>>> following-
>>>> declare -g works
>>>> declare -gr doesn't work
>>>> my current workaround is I've just stopped using the readonly 
>>>> attribute which
>>>> works. or just stopped using declare altogether.
>>>> or do something like this
>>>> var=x
>>>> typeset -r var
>>>>
>>>> I've also seen some strange behavior with
>>>> declare in a conditional sourced global context. it only seems to 
>>>> happen when
>>>> the code size is 10000s+ lines long.
>>>> I think this is exasperated by the fact that i source my files inside
>>>> conditional statements. the result is that I now even in a global 
>>>> context set
>>>> the global flag.
>>>>
>>>> any ideas what could be causing it would help me try to figure out 
>>>> how to test
>>>> for it.
>>>>
>>>> Sorry about the weak description but I've been working around it 
>>>> now for
>>>> months waiting for it to make sense and I'm no closer to figuring 
>>>> out whats
>>>> going on.
>>>> the problem is so erratic it has to be some sort of partial lost 
>>>> context or
>>>> something.
>>>>
>>>> can you give me any tips on how to debug it if I can reproduce it 
>>>> again? is
>>>> their an easy way to track the validity of a variable?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>> I don't think it helps me but thanks for the try.
>> I would say zhats correct behavior. the code in the functions is only 
>> executed
>> when you call the functions. So the first executed readonly variable is
>> preserved.
>> Anyway my problem isn't with how readonly is preserved, its with how 
>> when I
>> set readonly the variable seems to have a limited context even if I 
>> declare it
>> explicitly global.
>>
>>
>
> Ok, but do I have a point? I get your problem, but it seems like 
> having a global variable that is allowed to be reinstantiated in an 
> inner (albeit dynamic) scope should behave the same regardless of 
> whether the global is readonly. Inside A, I don't get why I can't 
> create a new variable whose failure (or success) depends on whether a 
> previous outer scope variable exists as readonly.
>
> Note that if v1 at the global scope is not readonly, the one in A *is* 
> readonly, and the one in B is not, then there's no problem.
>
> To me, this begs the question of whether all mainline code should be 
> placed into a containing 'main' function so as to prevent this problem 
> from occurring. Even if I do this, it still leaves me vulnerable to 
> readonly variables that are sourced in before main is defined.
>
> [I hope that didn't come off as a rant. ;-)]
>
have you tried local?
I'm not sure if it'll make a difference.
I don't agree that typeset/declare should be able to override/redefine a 
readonly variable it would defeat the purpose in a way.
however local arguably should allow you to do it.




From MAILER-DAEMON Thu Apr 12 20:27:17 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIUM9-0004a5-Dd
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 20:27:17 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52975)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIUM6-0004Zq-Jd
	for bug-bash@gnu.org; Thu, 12 Apr 2012 20:27:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIUM4-0005sJ-16
	for bug-bash@gnu.org; Thu, 12 Apr 2012 20:27:14 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:6964)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIUM3-0005s2-SF
	for bug-bash@gnu.org; Thu, 12 Apr 2012 20:27:11 -0400
Received: from mpv7.case.edu (mpv7.tis.CWRU.Edu [129.22.104.170])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJV59439;
	Thu, 12 Apr 2012 20:27:09 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TFX46866 (AUTH cpr);
	Thu, 12 Apr 2012 20:27:09 -0400 (EDT)
Message-ID: <4F8772D5.9000300@case.edu>
Date: Thu, 12 Apr 2012 20:27:01 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Petr Sumbera <petr.sumbera@oracle.com>
Subject: Re: small fix for lib/sh/snprintf.c
References: <4F8701F3.6000002@oracle.com>
In-Reply-To: <4F8701F3.6000002@oracle.com>
X-Enigmail-Version: 1.4
Content-Type: multipart/mixed; boundary="------------000709030201020409080200"
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 13 Apr 2012 00:27:16 -0000

This is a multi-part message in MIME format.
--------------000709030201020409080200
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On 4/12/12 12:25 PM, Petr Sumbera wrote:
> Hi,
> 
> we are running Bash 3.2.38 on Solaris 10 where asprintf() isn't available.
> Thus code in snprintf.c is used.
> 
> There is a problem with following command:
> 
> bash -c 'printf "x%10.0fx\n" 123'
> x0000000123x
> 
> Where correct output should be:
> x       123x
> 
> It seems that '0' after '.' enables zero padding. Please see proposed patch
> bellow:
> 
> --- bash-3.2.48/lib/sh/snprintf.c       Tue Dec 12 12:10:18 2006
> +++ bash-3.2.48/lib/sh/snprintf.c       Thu Apr 12 08:55:44 2012
> @@ -1277,6 +1277,8 @@
>                 data->flags |= PF_ALTFORM;
>                 continue;
>               case '0':
> +               if (data->flags & PF_DOT)
> +                 continue;
>                 data->flags |= PF_ZEROPAD;
>                 data->pad = '0';
>                 continue;
> 
> The same code seems to be also in Bash 4.1 so I guess the problem is still
> there.
> 
> Any comments?

Thanks for the report.  Try this slightly improved patch; yours (and the
original code) doesn't treat a precision specifier beginning with a `0'
correctly.  (And the test has to use `printf -v' to exercise the right
code in bash-4.0 and later.)

Chet

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

--------------000709030201020409080200
Content-Type: text/x-patch;
 name="snprintf-zeropad.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="snprintf-zeropad.patch"

*** ../bash-4.2-patched/lib/sh/snprintf.c	2010-05-30 18:34:52.000000000 -0400
--- lib/sh/snprintf.c	2012-04-12 20:12:56.000000000 -0400
***************
*** 1296,1303 ****
  		data->flags |= PF_ALTFORM;
  		continue;
- 	      case '0':
- 		data->flags |= PF_ZEROPAD;
- 		data->pad = '0';
- 		continue;
  	      case '*':
  		if (data->flags & PF_DOT)
--- 1289,1292 ----
***************
*** 1330,1333 ****
--- 1319,1329 ----
  		continue;
  
+ 	      case '0':
+ 	        if ((data->flags & PF_DOT) == 0)
+ 		  {
+ 		    data->flags |= PF_ZEROPAD;
+ 		    data->pad = '0';
+ 		    continue;
+ 		  }
  	      case '1': case '2': case '3':
  	      case '4': case '5': case '6':

--------------000709030201020409080200--



From MAILER-DAEMON Thu Apr 12 21:05:58 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIUxa-0004Yo-CZ
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 21:05:58 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52477)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIUxX-0004YF-50
	for bug-bash@gnu.org; Thu, 12 Apr 2012 21:05:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIUxV-0003C7-3y
	for bug-bash@gnu.org; Thu, 12 Apr 2012 21:05:54 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:64297)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIUxU-0003By-VS
	for bug-bash@gnu.org; Thu, 12 Apr 2012 21:05:53 -0400
Received: from mpv8.tis.cwru.edu (EHLO mpv8.case.edu) ([129.22.105.116])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXQ20701 (AUTH cpr);
	Thu, 12 Apr 2012 21:05:50 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TMJ77113 (AUTH cpr);
	Thu, 12 Apr 2012 21:05:50 -0400 (EDT)
Message-ID: <4F877BEA.4000602@case.edu>
Date: Thu, 12 Apr 2012 21:05:46 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: "Steven W. Orr" <steveo@syslang.net>
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>
	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>
	<4F871C05.10204@web.de> <4F873708.10207@syslang.net>
In-Reply-To: <4F873708.10207@syslang.net>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 13 Apr 2012 01:05:56 -0000

On 4/12/12 4:11 PM, Steven W. Orr wrote:

> It took me a second to reproduce it, but here it is:
> 
> ----------------------
> #! /bin/bash
> 
> A()
> {
>     typeset v1=Hello
> 
>     B
>     echo "IN B:$v1"
> }
> 
> B()
> {
>     typeset -r v1=Goodbye
> 
>     :
> }
> typeset -r v1=abc
> A
> echo "v1:$v1"
> --------------------------
> 
> This is 4.0.35(1).
> 
> The v1 that's set to abc is the global one.
> A defines a local copy that's not readonly and B defines one that is. When
> I run it I get:
> 
> 950 > ./foo.sh
> ./foo.sh: line 5: typeset: v1: readonly variable
> ./foo.sh: line 13: typeset: v1: readonly variable
> IN B:abc
> v1:abc
> 
> This means that the typeset failed is both A and B and the references in
> the routines fell back to the global instance of v1.

This is intended.  Bash doesn't allow a local copy of a variable to
override a readonly global one.  This can be a potential security hole,
especially if the readonly variable is exported, assuming that the
person/script/agent that set the variable readonly really didn't intend
for it to be modified for a reason.

However, the code allows a local variable to override a different
function's readonly local variable with the reasoning that the security
hole is not as great.  If you don't like the global behavior, you can work
around it by having a function declare all your variables as local and
relying on dynamic scoping to treat them as essentially global.

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


From MAILER-DAEMON Thu Apr 12 21:09:03 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIV0Z-0004lF-Qh
	for mharc-bug-bash@gnu.org; Thu, 12 Apr 2012 21:09:03 -0400
Received: from eggs.gnu.org ([208.118.235.92]:36804)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIV0W-0004l5-3L
	for bug-bash@gnu.org; Thu, 12 Apr 2012 21:09:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIV0U-0003YQ-B5
	for bug-bash@gnu.org; Thu, 12 Apr 2012 21:08:59 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:64711)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SIV0U-0003WW-6e
	for bug-bash@gnu.org; Thu, 12 Apr 2012 21:08:58 -0400
Received: from mpv7.tis.cwru.edu (EHLO mpv7.case.edu) ([129.22.104.170])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXQ20830 (AUTH cpr);
	Thu, 12 Apr 2012 21:08:57 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TFX75426 (AUTH cpr);
	Thu, 12 Apr 2012 21:08:57 -0400 (EDT)
Message-ID: <4F877CA6.3070904@case.edu>
Date: Thu, 12 Apr 2012 21:08:54 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: dethrophes <dethrophes@web.de>
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>	<4F871C05.10204@web.de>
	<4F873708.10207@syslang.net> <4F873941.2030800@web.de>
	<4F873D45.5080206@syslang.net> <4F873E58.2080404@web.de>
In-Reply-To: <4F873E58.2080404@web.de>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 13 Apr 2012 01:09:01 -0000

On 4/12/12 4:43 PM, dethrophes wrote:

> have you tried local?
> I'm not sure if it'll make a difference.

It won't.

> I don't agree that typeset/declare should be able to override/redefine a
> readonly variable it would defeat the purpose in a way.

I described the (hybrid/compromise) bash behavior in the previous message.

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


From MAILER-DAEMON Fri Apr 13 09:19:27 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIgPP-0004eL-5x
	for mharc-bug-bash@gnu.org; Fri, 13 Apr 2012 09:19:27 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51877)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SIgPL-0004du-S4
	for bug-bash@gnu.org; Fri, 13 Apr 2012 09:19:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SIgPG-0001vq-TJ
	for bug-bash@gnu.org; Fri, 13 Apr 2012 09:19:23 -0400
Received: from acsinet15.oracle.com ([141.146.126.227]:50843)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SIgPG-0001vg-MD
	for bug-bash@gnu.org; Fri, 13 Apr 2012 09:19:18 -0400
Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237])
	by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with
	ESMTP id q3DDJ7VL017164
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Fri, 13 Apr 2012 13:19:07 GMT
Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158])
	by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
	q3DDJ6CI024170
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Fri, 13 Apr 2012 13:19:07 GMT
Received: from abhmt115.oracle.com (abhmt115.oracle.com [141.146.116.67])
	by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id
	q3DDJ6eI015162; Fri, 13 Apr 2012 08:19:06 -0500
Received: from [10.163.101.52] (/10.163.101.52)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Fri, 13 Apr 2012 06:19:05 -0700
Message-ID: <4F8827BE.9090109@oracle.com>
Date: Fri, 13 Apr 2012 15:18:54 +0200
From: Petr Sumbera <petr.sumbera@oracle.com>
User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US;
	rv:1.9.2.13) Gecko/20110117 Lightning/1.0b2 Thunderbird/3.1.7
MIME-Version: 1.0
To: chet.ramey@case.edu
Subject: Re: small fix for lib/sh/snprintf.c
References: <4F8701F3.6000002@oracle.com> <4F8772D5.9000300@case.edu>
In-Reply-To: <4F8772D5.9000300@case.edu>
Content-Type: multipart/mixed; boundary="------------030801040500040505070607"
X-Source-IP: acsinet21.oracle.com [141.146.126.237]
X-Auth-Type: Internal IP
X-CT-RefId: str=0001.0A090201.4F8827CC.0023,ss=1,re=0.000,fgs=0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1)
X-Received-From: 141.146.126.227
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 13 Apr 2012 13:19:26 -0000

This is a multi-part message in MIME format.
--------------030801040500040505070607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Your change is ok for my original test case. But I have realized that 
there are several other problems. Please see attached new version of the 
patch.

Problem 1:
==========

bash -c 'printf "x%-010.0fx\n" 123'
x1230000000x

where it should be:
x123       x

Fixed in chunk #6.

Problem 2:
==========

bash -c 'printf "x%+010.0fx\n" 123'
x000000+123x

where it should be:
x+000000123x

Fixed in chunk #3 (but the problem is there also for other types!).

Problem 3:
==========

bash -c 'printf "x%-+10.0fx\n" 123'
x      +123x

where it should be:
x+123      x

Fixed in chunk #5 and #1.

Problem 4:
==========

bash -c 'printf "%f\n" -123'
-inf

where it should be:
-123.000000

Fixed in chunk #2.

--

Petr

On 04/13/12 02:27 AM, Chet Ramey wrote:
> On 4/12/12 12:25 PM, Petr Sumbera wrote:
>> Hi,
>>
>> we are running Bash 3.2.38 on Solaris 10 where asprintf() isn't available.
>> Thus code in snprintf.c is used.
>>
>> There is a problem with following command:
>>
>> bash -c 'printf "x%10.0fx\n" 123'
>> x0000000123x
>>
>> Where correct output should be:
>> x       123x
>>
>> It seems that '0' after '.' enables zero padding. Please see proposed patch
>> bellow:
>>
>> --- bash-3.2.48/lib/sh/snprintf.c       Tue Dec 12 12:10:18 2006
>> +++ bash-3.2.48/lib/sh/snprintf.c       Thu Apr 12 08:55:44 2012
>> @@ -1277,6 +1277,8 @@
>>                  data->flags |= PF_ALTFORM;
>>                  continue;
>>                case '0':
>> +               if (data->flags&  PF_DOT)
>> +                 continue;
>>                  data->flags |= PF_ZEROPAD;
>>                  data->pad = '0';
>>                  continue;
>>
>> The same code seems to be also in Bash 4.1 so I guess the problem is still
>> there.
>>
>> Any comments?
>
> Thanks for the report.  Try this slightly improved patch; yours (and the
> original code) doesn't treat a precision specifier beginning with a `0'
> correctly.  (And the test has to use `printf -v' to exercise the right
> code in bash-4.0 and later.)
>
> Chet
>


--------------030801040500040505070607
Content-Type: text/plain;
 name="snprintf.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="snprintf.patch"

--- bash-3.2.48/lib/sh/snprintf.c.orig	Tue Dec 12 12:10:18 2006
+++ bash-3.2.48/lib/sh/snprintf.c	Fri Apr 13 05:30:04 2012
@@ -352,7 +352,7 @@
 	while (0)
 
 #define PUT_PLUS(d, p, zero) \
-	    if ((d) > zero && (p)->justify == RIGHT) \
+	    if (((p)->flags & PF_PLUS) && (d) > zero) \
 	      PUT_CHAR('+', p)
 
 #define PUT_SPACE(d, p, zero) \
@@ -907,7 +907,7 @@
      double d;
 {
 #ifdef DBL_MAX
-  if (d < DBL_MIN)
+  if (d < -DBL_MAX)
     return -1;
   else if (d > DBL_MAX)
     return 1;
@@ -994,8 +994,10 @@
 	    ((p->flags & PF_SPACE) ? 1:0) -
 	    strlen(tmp) - p->precision -
 	    ((p->precision != 0 || (p->flags & PF_ALTFORM)) ? 1 : 0);	/* radix char */
-  PAD_RIGHT(p);  
+  if (*tmp == '-')
+       PUT_CHAR(*tmp++, p);
   PUT_PLUS(d, p, 0.);
+  PAD_RIGHT(p);  
   PUT_SPACE(d, p, 0.);
 
   while (*tmp)
@@ -1276,10 +1278,6 @@
 	      case '#':
 		data->flags |= PF_ALTFORM;
 		continue;
-	      case '0':
-		data->flags |= PF_ZEROPAD;
-		data->pad = '0';
-		continue;
 	      case '*':
 		if (data->flags & PF_DOT)
 		  data->flags |= PF_STAR_P;
@@ -1303,7 +1301,8 @@
 		if ((data->flags & PF_DOT) == 0)
 		  {
 		    data->flags |= PF_PLUS;
-		    data->justify = RIGHT;
+		    if ((data->flags & PF_LADJUST) == 0)
+		      data->justify = RIGHT;
 		  }
 		continue;
 	      case '\'':
@@ -1310,6 +1309,13 @@
 		data->flags |= PF_THOUSANDS;
 		continue;
 
+	      case '0':
+	        if ((data->flags & (PF_DOT|PF_LADJUST)) == 0)
+		  {
+		    data->flags |= PF_ZEROPAD;
+		    data->pad = '0';
+		    continue;
+		  }
 	      case '1': case '2': case '3':
 	      case '4': case '5': case '6':
 	      case '7': case '8': case '9':

--------------030801040500040505070607--


From MAILER-DAEMON Fri Apr 13 09:58:04 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIh0m-0001Dd-0W
	for mharc-bug-bash@gnu.org; Fri, 13 Apr 2012 09:58:04 -0400
Received: from eggs.gnu.org ([208.118.235.92]:42689)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SIh0e-0001Bm-GP
	for bug-bash@gnu.org; Fri, 13 Apr 2012 09:58:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SIh0c-0005zK-OA
	for bug-bash@gnu.org; Fri, 13 Apr 2012 09:57:56 -0400
Received: from rcsinet15.oracle.com ([148.87.113.117]:39307)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SIh0c-0005zA-IK
	for bug-bash@gnu.org; Fri, 13 Apr 2012 09:57:54 -0400
Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237])
	by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with
	ESMTP id q3DDvoJn027636
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Fri, 13 Apr 2012 13:57:51 GMT
Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156])
	by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
	q3DDvnf6001154
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Fri, 13 Apr 2012 13:57:50 GMT
Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68])
	by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id
	q3DDvnqW021890; Fri, 13 Apr 2012 08:57:49 -0500
Received: from [10.163.101.52] (/10.163.101.52)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Fri, 13 Apr 2012 06:57:49 -0700
Message-ID: <4F8830DB.50908@oracle.com>
Date: Fri, 13 Apr 2012 15:57:47 +0200
From: Petr Sumbera <petr.sumbera@oracle.com>
User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US;
	rv:1.9.2.13) Gecko/20110117 Lightning/1.0b2 Thunderbird/3.1.7
MIME-Version: 1.0
To: chet.ramey@case.edu
Subject: Re: small fix for lib/sh/snprintf.c
References: <4F8701F3.6000002@oracle.com> <4F8772D5.9000300@case.edu>
	<4F8827BE.9090109@oracle.com>
In-Reply-To: <4F8827BE.9090109@oracle.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Source-IP: acsinet21.oracle.com [141.146.126.237]
X-CT-RefId: str=0001.0A090208.4F8830DF.00AE,ss=1,re=0.000,fgs=0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1)
X-Received-From: 148.87.113.117
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 13 Apr 2012 13:58:02 -0000

On 04/13/12 03:18 PM, Petr Sumbera wrote:

> Problem 2:
> ==========
>
> bash -c 'printf "x%+010.0fx\n" 123'
> x000000+123x
>
> where it should be:
> x+000000123x
>
> Fixed in chunk #3 (but the problem is there also for other types!).

My fix breaks following case:

bash -c 'printf "x%+10.0fx\n" 123'
x+      123x

where it should be
x      +123x

So this would be probably fixed in my original patch (chunk #3) with 
following code:

   if (p->pad == ' ')
     {
       PAD_RIGHT(p);
       PUT_PLUS(d, p, 0.);
     } else {
       if (*tmp == '-')
         PUT_CHAR(*tmp++, p);
       PUT_PLUS(d, p, 0.);
       PAD_RIGHT(p);
     }
     PUT_SPACE(d, p, 0.);

--

Petr


From MAILER-DAEMON Fri Apr 13 20:01:55 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIqR9-00060P-5z
	for mharc-bug-bash@gnu.org; Fri, 13 Apr 2012 20:01:55 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57102)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIqR6-0005zE-Nl
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:01:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIqR5-0008FP-1v
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:01:52 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:50318
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIqR4-0008EQ-9K
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:01:50 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3E01gio025373
	for <bug-bash@gnu.org>; Fri, 13 Apr 2012 17:01:45 -0700
Message-ID: <4F88BE66.1020401@tlinx.org>
Date: Fri, 13 Apr 2012 17:01:42 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: how are aliases exported?
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 14 Apr 2012 00:01:54 -0000





How can I export an alias so it survives across an exec?


I thought there was a way for them to be exported like vars or functions...
but neither work.

I have a prog that needs an alias defined, if it isn't, it
execs a program to define the alias which re-execs the first --
if the alias isn't defined on the 2nd execution, the program
fails (has a check to prevent looping)...it seems the alias isn't
staying defined across the exec....

shouldn't export -f work for aliases? -- as I don't think
it would work to have an alias the same name as a function
(or would it?....)  Either way.. How can you export an alias - simply!

I mean I could do it by re-instantiating them in a bash_env file, like
I have to do for arrays -- is the same required for aliases?    Both
are pretty ugly though...





From MAILER-DAEMON Fri Apr 13 20:20:27 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIqj5-0001tl-DM
	for mharc-bug-bash@gnu.org; Fri, 13 Apr 2012 20:20:27 -0400
Received: from eggs.gnu.org ([208.118.235.92]:36961)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dennistwilliamson@gmail.com>) id 1SIqj3-0001tS-3T
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:20:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dennistwilliamson@gmail.com>) id 1SIqj0-00024o-U8
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:20:24 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:56937)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dennistwilliamson@gmail.com>) id 1SIqj0-000241-Mg
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:20:22 -0400
Received: by obbup16 with SMTP id up16so4555097obb.0
	for <bug-bash@gnu.org>; Fri, 13 Apr 2012 17:20:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=cloH/XTpb437qSOHM05dZqDgRV3qbXSgPazXlamzsA8=;
	b=ZvX5uSw+FSzboA74GX3+wvUokcIoPiy3KqiAPzhsM1asOo7h+sUIRvTnfDx56Rh4eC
	M22HjgRAsPfsNUtZoO6+9R1qHDZhZoDJ1XnjUUkio5YK3Tc8ZMlSKE2SwkODjYn24T1x
	+YxHnzRSU5bADBeC3J7c6rvmC5GFEs7wSF2jlCTw9KzSeJFFdej1ckkN/imAOHNtheMq
	xnCHd+qeg5l/1KTYDWkDlr0yPW2qcFdVUnEG0xbruGFECJmeanbWMe1FVngPRgMdcjqW
	TffCtjAe6XC9uI+lzKtm/kkqYY0sAsFWwWUfd+otnhPjIt6TWCkKmHYkRof1zzTP+Bet
	en0Q==
MIME-Version: 1.0
Received: by 10.182.113.106 with SMTP id ix10mr4988717obb.26.1334362819618;
	Fri, 13 Apr 2012 17:20:19 -0700 (PDT)
Received: by 10.182.51.137 with HTTP; Fri, 13 Apr 2012 17:20:19 -0700 (PDT)
Received: by 10.182.51.137 with HTTP; Fri, 13 Apr 2012 17:20:19 -0700 (PDT)
In-Reply-To: <4F88BE66.1020401@tlinx.org>
References: <4F88BE66.1020401@tlinx.org>
Date: Fri, 13 Apr 2012 19:20:19 -0500
Message-ID: <CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>
Subject: Re: how are aliases exported?
From: Dennis Williamson <dennistwilliamson@gmail.com>
To: Linda Walsh <bash@tlinx.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 14 Apr 2012 00:20:26 -0000

Aliases are intended for command line convenience. You should use
functions, which can be exported and are the correct thing to use in
scripts (and even from the command line).

"For almost every purpose, shell functions are preferred over aliases."

But, of course, you know that already.

On Apr 13, 2012 7:01 PM, "Linda Walsh" <bash@tlinx.org> wrote:
>
>
>
>
>
> How can I export an alias so it survives across an exec?
>
>
> I thought there was a way for them to be exported like vars or
functions...
> but neither work.
>
> I have a prog that needs an alias defined, if it isn't, it
> execs a program to define the alias which re-execs the first --
> if the alias isn't defined on the 2nd execution, the program
> fails (has a check to prevent looping)...it seems the alias isn't
> staying defined across the exec....
>
> shouldn't export -f work for aliases? -- as I don't think
> it would work to have an alias the same name as a function
> (or would it?....)  Either way.. How can you export an alias - simply!
>
> I mean I could do it by re-instantiating them in a bash_env file, like
> I have to do for arrays -- is the same required for aliases?    Both
> are pretty ugly though...
>
>
>
>

From MAILER-DAEMON Fri Apr 13 20:45:04 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIr6u-0007HT-Fx
	for mharc-bug-bash@gnu.org; Fri, 13 Apr 2012 20:45:04 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56581)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIr6s-0007G6-79
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:45:03 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIr6q-0002It-DC
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:45:01 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:51018
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIr6p-0002Gn-8c
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:45:00 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3E0iinu030654; Fri, 13 Apr 2012 17:44:47 -0700
Message-ID: <4F88C87C.6030803@tlinx.org>
Date: Fri, 13 Apr 2012 17:44:44 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Dennis Williamson <dennistwilliamson@gmail.com>,
	bug-bash <bug-bash@gnu.org>
Subject: Re: how are aliases exported?
References: <4F88BE66.1020401@tlinx.org>
	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>
In-Reply-To: <CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 14 Apr 2012 00:45:03 -0000



Dennis Williamson wrote:

> Aliases are intended for command line convenience. You should use
> functions, which can be exported and are the correct thing to use in
> scripts (and even from the command line).
> 
> "For almost every purpose, shell functions are preferred over aliases."
> 
> But, of course, you know that already.

---
	Yeah... and I've already demonstrated the 'almost' part.

It's one of those:

function _include_h { return "source <liblookup>$1" ;}


alias include='eval $( _include_h "$1")'

Near as I can tell, you can't do that in a function.
If you source a file in a function, the local vars in the file
would be local to the function -- not to the prog using the alias


I thought I did suggest that line be corrected -- so people wouldn't
think functions replace aliases...
Since for some purposes, functions cannot replace aliases.

Now that I've justified another usage (similar to previous that eval'ed a 
result), -- how about how do I export aliases??






From MAILER-DAEMON Fri Apr 13 20:50:22 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIrC2-0000Ei-Lf
	for mharc-bug-bash@gnu.org; Fri, 13 Apr 2012 20:50:22 -0400
Received: from eggs.gnu.org ([208.118.235.92]:40427)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIrC0-0000E9-4h
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:50:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIrBy-0004r6-F4
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:50:19 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:51111
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SIrBx-0004qJ-UF
	for bug-bash@gnu.org; Fri, 13 Apr 2012 20:50:18 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3E0oAcm030963
	for <bug-bash@gnu.org>; Fri, 13 Apr 2012 17:50:13 -0700
Message-ID: <4F88C9C2.9080709@tlinx.org>
Date: Fri, 13 Apr 2012 17:50:10 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>	<4F871C05.10204@web.de>
	<4F873708.10207@syslang.net> <4F877BEA.4000602@case.edu>
In-Reply-To: <4F877BEA.4000602@case.edu>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 14 Apr 2012 00:50:21 -0000



Chet Ramey wrote:

> This is intended.  Bash doesn't allow a local copy of a variable to
> override a readonly global one.  This can be a potential security hole,

---
You can look at it that way, but it also hinders modular programming.

If I declare a variable to be local, I wouldn't expect it to fail and
be overridden by some global namespace pollution.

It is overridable, but not easily.

Might be nice to have some way to declare a var local to a function that
can be protected from random namespace pollution.




From MAILER-DAEMON Sat Apr 14 01:28:57 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIvXd-0000gY-LD
	for mharc-bug-bash@gnu.org; Sat, 14 Apr 2012 01:28:57 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48603)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SIvXb-0000fo-F4
	for bug-bash@gnu.org; Sat, 14 Apr 2012 01:28:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SIvXZ-0001Nh-HC
	for bug-bash@gnu.org; Sat, 14 Apr 2012 01:28:55 -0400
Received: from mail-iy0-f169.google.com ([209.85.210.169]:63607)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SIvXZ-0001JG-8n
	for bug-bash@gnu.org; Sat, 14 Apr 2012 01:28:53 -0400
Received: by iajr24 with SMTP id r24so6280961iaj.0
	for <bug-bash@gnu.org>; Fri, 13 Apr 2012 22:28:50 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type;
	bh=g28ixXoxVlKdmteiTZm2FXQuedoVyQxV+ktpcN1SZV0=;
	b=agg3tvHWLq5i4R8CFSUCck+WjF7MUlHKQRUbnIS1POb5ctri3DLql5/DRyKTfCPyiF
	Oc//Hur3YnxolF83iD5wDx55YuV21gkLp6h5stK6e7tCOF6R0B0eo2bfeBzLB2xbphpH
	siT6yTHxmO1SXcaQpAdYUR460FHSqPX6ITuUaq0ToLL8xooRGZTrpfAwtLlg5EZ60QIP
	/RSPeFPWXVKoc8UCZ1o2xVyCHWlQZG2vv/TTDYu9ZsoTdFrTdnM2AoXwcyxu5ah/hUYD
	X6rEtjBbVbfbRbmL0OOab22+bZAYqZdxo9GmNbVt8+TwPA4ooSHGkgmsHpHxFJwvvo8Y
	Fqsw==
Received: by 10.43.49.3 with SMTP id uy3mr3073549icb.2.1334381330029; Fri, 13
	Apr 2012 22:28:50 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.42.233.11 with HTTP; Fri, 13 Apr 2012 22:28:28 -0700 (PDT)
In-Reply-To: <4F88C87C.6030803@tlinx.org>
References: <4F88BE66.1020401@tlinx.org>
	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>
	<4F88C87C.6030803@tlinx.org>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Sat, 14 Apr 2012 08:28:28 +0300
Message-ID: <CAPSX3sRUvNHOtNsQ9Jp84KAsekhtPoHwv0z9w4VZgofkZoK0-w@mail.gmail.com>
Subject: Re: how are aliases exported?
To: Linda Walsh <bash@tlinx.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.210.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: Dennis Williamson <dennistwilliamson@gmail.com>,
	bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 14 Apr 2012 05:28:56 -0000

On Sat, Apr 14, 2012 at 3:44 AM, Linda Walsh <bash@tlinx.org> wrote:

>
>
> Dennis Williamson wrote:
>
>  Aliases are intended for command line convenience. You should use
>> functions, which can be exported and are the correct thing to use in
>> scripts (and even from the command line).
>>
>> "For almost every purpose, shell functions are preferred over aliases."
>>
>> But, of course, you know that already.
>>
>
> ---
>        Yeah... and I've already demonstrated the 'almost' part.
>
> It's one of those:
>
> function _include_h { return "source <liblookup>$1" ;}
>
>
> alias include='eval $( _include_h "$1")'
>
> Near as I can tell, you can't do that in a function.
> If you source a file in a function, the local vars in the file
> would be local to the function -- not to the prog using the alias
>
>
> I thought I did suggest that line be corrected -- so people wouldn't
> think functions replace aliases...
> Since for some purposes, functions cannot replace aliases.
>
> Now that I've justified another usage (similar to previous that eval'ed a
> result), -- how about how do I export aliases??
>

you can't.

From MAILER-DAEMON Sat Apr 14 01:32:20 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIvau-00019l-HT
	for mharc-bug-bash@gnu.org; Sat, 14 Apr 2012 01:32:20 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49281)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SIvar-000197-8P
	for bug-bash@gnu.org; Sat, 14 Apr 2012 01:32:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SIvap-00042t-Hu
	for bug-bash@gnu.org; Sat, 14 Apr 2012 01:32:16 -0400
Received: from mail-iy0-f169.google.com ([209.85.210.169]:36150)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SIvap-00040x-Ap
	for bug-bash@gnu.org; Sat, 14 Apr 2012 01:32:15 -0400
Received: by iajr24 with SMTP id r24so6282977iaj.0
	for <bug-bash@gnu.org>; Fri, 13 Apr 2012 22:32:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type;
	bh=0VbAHCe+4kdX0tbRC03I6QvV26qezZPe63cssoYdf5o=;
	b=sNon7Ev6ZK45noaysSLofW27UtNkrnxmDczGTJlZjk76r75KvO7+EBOj4jhTumnRXE
	Hn4G9LlVR0/FyMeHFArhI7EjleaUAzMCp6St4eHVW10+DHB5eTb1pL/blAKEhi31dS4V
	KeA7E2a3WRxcZqIgkc8Tpggm+/hKQ2bUxNxvhVidtOVhesJIh+++T6CPZJbIJ2cteCnY
	76HZucXCzylt16sabzfWTiLKgafQus3xari3g8idmCVwTBpysl14MVtE8nmPXAbQe5bV
	OdMGxeRLYOUAJ/h+mlFOP2tNEdYekCsm6RNZ9qBPfN1mTsq5Cb7URcKLdRfJuURwjwfr
	HCAg==
Received: by 10.50.186.132 with SMTP id fk4mr501018igc.23.1334381532541; Fri,
	13 Apr 2012 22:32:12 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.42.233.11 with HTTP; Fri, 13 Apr 2012 22:31:52 -0700 (PDT)
In-Reply-To: <4F88C87C.6030803@tlinx.org>
References: <4F88BE66.1020401@tlinx.org>
	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>
	<4F88C87C.6030803@tlinx.org>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Sat, 14 Apr 2012 08:31:52 +0300
Message-ID: <CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
Subject: Re: how are aliases exported?
To: Linda Walsh <bash@tlinx.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.210.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: Dennis Williamson <dennistwilliamson@gmail.com>,
	bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 14 Apr 2012 05:32:18 -0000

On Sat, Apr 14, 2012 at 3:44 AM, Linda Walsh <bash@tlinx.org> wrote:

>
>
> Dennis Williamson wrote:
>
>  Aliases are intended for command line convenience. You should use
>> functions, which can be exported and are the correct thing to use in
>> scripts (and even from the command line).
>>
>> "For almost every purpose, shell functions are preferred over aliases."
>>
>> But, of course, you know that already.
>>
>
> ---
>        Yeah... and I've already demonstrated the 'almost' part.
>
> It's one of those:
>
> function _include_h { return "source <liblookup>$1" ;}
>
>
> alias include='eval $( _include_h "$1")'
>
> Near as I can tell, you can't do that in a function.
> If you source a file in a function, the local vars in the file
> would be local to the function -- not to the prog using the alias
>
>
> local vars in the file? what is this?

From MAILER-DAEMON Sat Apr 14 02:34:09 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIwYj-0006OK-24
	for mharc-bug-bash@gnu.org; Sat, 14 Apr 2012 02:34:09 -0400
Received: from eggs.gnu.org ([208.118.235.92]:35861)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SIwYf-0006O1-QT
	for bug-bash@gnu.org; Sat, 14 Apr 2012 02:34:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SIwYd-0005TL-Fi
	for bug-bash@gnu.org; Sat, 14 Apr 2012 02:34:05 -0400
Received: from mail-iy0-f169.google.com ([209.85.210.169]:64633)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pierre.gaston@gmail.com>) id 1SIwYd-0005RO-6c
	for bug-bash@gnu.org; Sat, 14 Apr 2012 02:34:03 -0400
Received: by iajr24 with SMTP id r24so6325180iaj.0
	for <bug-bash@gnu.org>; Fri, 13 Apr 2012 23:34:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type;
	bh=2Wd4ivGovfzS5/nhyh2Xzjuq8xfDwSgSvwb/0yMko2o=;
	b=PatXw14KP2bgUhGS0RghvbbteUcwT10KS7TWZZTumH5L5I06TdNpdhQESH7JxE2PeS
	wQZutsdh0+5znnqBoXGcgEU/RIrduVZCFholx3Rf3RqDKEPsnsLmUq1ZY+sURj1LIQsv
	H7cJOejKd4CkkxQLgj9o4xD8+EbjwPeUcGGvdw53OiKsAE5+FXJkYBVR3Uu5fMoJytm6
	np+vxJUDMh30rsy6Ap0v0BFaHN1LPo4PUWsX5uSGtCL45KVHVyR49fJtHt1mlVaIWuQo
	Sti7ZTFk3slVqV3k2U69Jt9EnGwJZktgCMFyWK5jWs26PWo+2Rh/jFdHmEt9EdY6lJLX
	RS8w==
Received: by 10.42.159.202 with SMTP id m10mr2759986icx.50.1334385241399; Fri,
	13 Apr 2012 23:34:01 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.42.233.11 with HTTP; Fri, 13 Apr 2012 23:33:41 -0700 (PDT)
In-Reply-To: <CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
References: <4F88BE66.1020401@tlinx.org>
	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>
	<4F88C87C.6030803@tlinx.org>
	<CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
From: Pierre Gaston <pierre.gaston@gmail.com>
Date: Sat, 14 Apr 2012 09:33:41 +0300
Message-ID: <CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
Subject: Re: how are aliases exported?
To: Linda Walsh <bash@tlinx.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.210.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: Dennis Williamson <dennistwilliamson@gmail.com>,
	bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 14 Apr 2012 06:34:07 -0000

On Sat, Apr 14, 2012 at 8:31 AM, Pierre Gaston <pierre.gaston@gmail.com>wrote:

>
>
> On Sat, Apr 14, 2012 at 3:44 AM, Linda Walsh <bash@tlinx.org> wrote:
>
>>
>>
>> Dennis Williamson wrote:
>>
>>  Aliases are intended for command line convenience. You should use
>>> functions, which can be exported and are the correct thing to use in
>>> scripts (and even from the command line).
>>>
>>> "For almost every purpose, shell functions are preferred over aliases."
>>>
>>> But, of course, you know that already.
>>>
>>
>> ---
>>        Yeah... and I've already demonstrated the 'almost' part.
>>
>> It's one of those:
>>
>> function _include_h { return "source <liblookup>$1" ;}
>>
>>
>> alias include='eval $( _include_h "$1")'
>>
>> Near as I can tell, you can't do that in a function.
>> If you source a file in a function, the local vars in the file
>> would be local to the function -- not to the prog using the alias
>>
>>
>> local vars in the file? what is this?
>

Oh I get it, the non working code put me off (returning a string really?)

You mean if you have "declare var=foo" in a file and then source it from a
function the variable will be local to the function, newer bash versions
have a -g option to work around this.

Anyway, as to export an alias there are 2 cases:

1) interactive bash
These source .bashrc so you can put your aliases there

2) non-interactive bash
Aliases are off by default. So given that you need to run something at the
beginning of your new bash instance anyway, you could define your aliases
in a function together with the mandatory shopt, eg:

function start_aliases {
       shopt -s expand_aliases
       alias foo=ls
}
export -f start_aliases

Then you can do:
bash  <<< $'start_aliases\nfoo'

Note that the function need to be on a line before the first use of the
alias, eg bash -c 'start_aliases;foo' doesn't work.

You can even make a kinda of export alias function with a hack like:
function start_aliases {
       shopt -s expand_aliases
       eval "$my_aliases"
}
export -f start_aliases

function exportalias {
   export my_aliases+=$'\n'"$(alias "$1")"
}
alias bar=ls
exportalias bar

From MAILER-DAEMON Sat Apr 14 21:21:38 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJE9q-0003eF-PF
	for mharc-bug-bash@gnu.org; Sat, 14 Apr 2012 21:21:38 -0400
Received: from eggs.gnu.org ([208.118.235.92]:33047)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SJE9n-0003e6-8R
	for bug-bash@gnu.org; Sat, 14 Apr 2012 21:21:37 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SJE9l-0005FD-E8
	for bug-bash@gnu.org; Sat, 14 Apr 2012 21:21:34 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:32683)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SJE9l-0005F5-9N
	for bug-bash@gnu.org; Sat, 14 Apr 2012 21:21:33 -0400
Received: from mpv8.case.edu (mpv8.tis.CWRU.Edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJW69961;
	Sat, 14 Apr 2012 21:21:30 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TNE26300 (AUTH cpr);
	Sat, 14 Apr 2012 21:21:30 -0400 (EDT)
Message-ID: <4F8A2296.8020608@case.edu>
Date: Sat, 14 Apr 2012 21:21:26 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Linda Walsh <bash@tlinx.org>
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>	<4F871C05.10204@web.de>
	<4F873708.10207@syslang.net> <4F877BEA.4000602@case.edu>
	<4F88C9C2.9080709@tlinx.org>
In-Reply-To: <4F88C9C2.9080709@tlinx.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash <bug-bash@gnu.org>, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 15 Apr 2012 01:21:37 -0000

On 4/13/12 8:50 PM, Linda Walsh wrote:
> 
> 
> Chet Ramey wrote:
> 
>> This is intended.  Bash doesn't allow a local copy of a variable to
>> override a readonly global one.  This can be a potential security hole,
> 
> ---
> You can look at it that way, but it also hinders modular programming.
> 
> If I declare a variable to be local, I wouldn't expect it to fail and
> be overridden by some global namespace pollution.

If I declare a variable readonly at global scope, I wouldn't expect it
to be overridden by some local namespace pollution.

> It is overridable, but not easily.

Yes, it is.


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


From MAILER-DAEMON Sun Apr 15 04:42:56 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJL2u-0002E6-Lf
	for mharc-bug-bash@gnu.org; Sun, 15 Apr 2012 04:42:56 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34517)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJL2s-0002CY-0X
	for bug-bash@gnu.org; Sun, 15 Apr 2012 04:42:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJL2q-0002WN-9B
	for bug-bash@gnu.org; Sun, 15 Apr 2012 04:42:53 -0400
Received: from mail-we0-f169.google.com ([74.125.82.169]:37168)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJL2p-0002W9-Vx
	for bug-bash@gnu.org; Sun, 15 Apr 2012 04:42:52 -0400
Received: by werj55 with SMTP id j55so3501823wer.0
	for <bug-bash@gnu.org>; Sun, 15 Apr 2012 01:42:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:content-transfer-encoding:message-id:references:to:x-mailer;
	bh=KEx/PcsjELcmeW+Q8ArgEJDPloQnaQq2j0I0l8QZ6NI=;
	b=alhyqvVPHjSq16AZfBHHliuzVLF2ge3EcceT3nExFaH654dfqkgkMNwNKjlddVkca3
	bti4ml5ucs4UUOvDpqiznsoiFt15DtvZcL/Yj7G/jfwPH8aM8aWIThG6lam6ix0jPBsR
	VL/KJfpbqN9sLWuoaMgkW+zWrdVRv5W447vk0=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:content-transfer-encoding:message-id:references:to:x-mailer
	:x-gm-message-state;
	bh=KEx/PcsjELcmeW+Q8ArgEJDPloQnaQq2j0I0l8QZ6NI=;
	b=oW/e59+L571rEhQB75f1OLR4ILP47GIPq0Pho9AowB5Zs3OM1c2ToPqHWj+6iJbjck
	UtzAsi8q20cxBCK8Ix81dU/JQmj60iHwXkAUZaBF68g+nH0ycHrYtuJYpXLSXejhqFu1
	axOZt6CSkqXiaDNIBYR8OmgobngUuEo4w3FNRaRm6ktd8jR/EfXiVq+uXEwI28KSXic4
	H1FsiuKcjwlw+Yw7IpfqPPNcj6RD9jgNbhWqAFlmbETaiKgQ/QGD3D7RDy4hWug64GGW
	SjL2SJX0wqGxcsA0l+Xii2AzqeJlgvIokoSc+K6FbPvjzPfnd5FIZccFwPqq3y+vmRXI
	qeUA==
Received: by 10.216.136.157 with SMTP id w29mr4482512wei.23.1334479368989;
	Sun, 15 Apr 2012 01:42:48 -0700 (PDT)
Received: from [192.168.0.10] (ip-83-134-150-38.dsl.scarlet.be.
	[83.134.150.38])
	by mx.google.com with ESMTPS id gd4sm17118510wib.6.2012.04.15.01.42.47
	(version=TLSv1/SSLv3 cipher=OTHER);
	Sun, 15 Apr 2012 01:42:48 -0700 (PDT)
Subject: Re: inconsistency with "readonly" and scope
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: text/plain; charset=iso-8859-1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <4F8A2296.8020608@case.edu>
Date: Sun, 15 Apr 2012 10:42:47 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <01C7E101-8902-444A-BCFE-5FA74D181A1D@lyndir.com>
References: <20120411185014.GG22241@eeg.ccf.org>	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>	<4F871C05.10204@web.de>
	<4F873708.10207@syslang.net> <4F877BEA.4000602@case.edu>
	<4F88C9C2.9080709@tlinx.org> <4F8A2296.8020608@case.edu>
To: chet.ramey@case.edu
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQl6xwSBOBZ/yw4MzwDAxyMnUjnGJgAN5ILy/dA7Aj2nyys+bIJxWVVZkwQ72n2zKcP9rTjB
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 74.125.82.169
Cc: Linda Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 15 Apr 2012 08:42:55 -0000

On 15 Apr 2012, at 03:21, Chet Ramey wrote:
>=20
> If I declare a variable readonly at global scope, I wouldn't expect it
> to be overridden by some local namespace pollution.

I think that's fine; in the local context, your variable has a different =
meaning; it's another variable with the same name. =20

Outside of the local scope, the original readonly variable remains =
unmodified.=


From MAILER-DAEMON Sun Apr 15 04:51:58 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJLBe-0003sE-PN
	for mharc-bug-bash@gnu.org; Sun, 15 Apr 2012 04:51:58 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49042)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SJLBb-0003rQ-GQ
	for bug-bash@gnu.org; Sun, 15 Apr 2012 04:51:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SJLBZ-0005NQ-QW
	for bug-bash@gnu.org; Sun, 15 Apr 2012 04:51:55 -0400
Received: from mail-out.m-online.net ([212.18.0.9]:57219)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SJLBZ-0005NJ-K2
	for bug-bash@gnu.org; Sun, 15 Apr 2012 04:51:53 -0400
Received: from frontend1.mail.m-online.net (unknown [192.168.8.180])
	by mail-out.m-online.net (Postfix) with ESMTP id 3VVmg93SNdz4LDfG;
	Sun, 15 Apr 2012 10:51:49 +0200 (CEST)
Received: from linux.local (ppp-93-104-140-113.dynamic.mnet-online.de
	[93.104.140.113])
	by mail.mnet-online.de (Postfix) with ESMTPA id 3VVmg92DLPz4KK77;
	Sun, 15 Apr 2012 10:51:49 +0200 (CEST)
Received: by linux.local (Postfix, from userid 501)
	id CAF781E52EC; Sun, 15 Apr 2012 10:51:48 +0200 (CEST)
From: Andreas Schwab <schwab@linux-m68k.org>
To: Maarten Billemont <lhunath@lyndir.com>
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org> <4F85E59C.4020702@web.de>
	<4F86CA2B.4010400@case.edu> <4F871C05.10204@web.de>
	<4F873708.10207@syslang.net> <4F877BEA.4000602@case.edu>
	<4F88C9C2.9080709@tlinx.org> <4F8A2296.8020608@case.edu>
	<01C7E101-8902-444A-BCFE-5FA74D181A1D@lyndir.com>
X-Yow: WHOA!!  I'm having a RELIGIOUS EXPERIENCE right NOW!!
Date: Sun, 15 Apr 2012 10:51:48 +0200
In-Reply-To: <01C7E101-8902-444A-BCFE-5FA74D181A1D@lyndir.com> (Maarten
	Billemont's message of "Sun, 15 Apr 2012 10:42:47 +0200")
Message-ID: <m27gxhcr8b.fsf@linux-m68k.org>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	4)
X-Received-From: 212.18.0.9
Cc: Linda Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>,
	chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 15 Apr 2012 08:51:56 -0000

Maarten Billemont <lhunath@lyndir.com> writes:

> On 15 Apr 2012, at 03:21, Chet Ramey wrote:
>> 
>> If I declare a variable readonly at global scope, I wouldn't expect it
>> to be overridden by some local namespace pollution.
>
> I think that's fine; in the local context, your variable has a
> different meaning; it's another variable with the same name.

If the variable is exported the local variable overrides the exported
value.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


From MAILER-DAEMON Sun Apr 15 14:56:46 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJUcw-0006RD-Br
	for mharc-bug-bash@gnu.org; Sun, 15 Apr 2012 14:56:46 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55896)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <golmoon@naver.com>) id 1SJPP1-0000Ix-GI
	for bug-bash@gnu.org; Sun, 15 Apr 2012 09:22:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <golmoon@naver.com>) id 1SJPOz-0001Ri-Lh
	for bug-bash@gnu.org; Sun, 15 Apr 2012 09:22:03 -0400
Received: from tmailpost19-2.nm.naver.com ([114.111.39.71]:38116)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <golmoon@naver.com>) id 1SJPOz-0001RQ-AT
	for bug-bash@gnu.org; Sun, 15 Apr 2012 09:22:01 -0400
Received: from [114.111.32.201] ([114.111.32.201]) 
	by tmailpost19-2.nm.naver.com ([10.25.246.50]) 
	with ESMTP id 1334496141.547232.4138630032.tmailpost19-2
	for <bug-bash@gnu.org>; Sun, 15 Apr 2012 22:22:21 +0900 (KST) 
Received: from [119.149.176.57] ([119.149.176.57]) 
	by a51507.nm.naver.com ([202.131.27.107]) 
	with ESMTP id 1334496111.61472.3076508560.a51507
	for <bug-bash@gnu.org>; Sun, 15 Apr 2012 22:21:51 +0900 (KST) 
Message-ID: <4F8ACB6B.5010402@naver.com>
Date: Sun, 15 Apr 2012 22:21:47 +0900
From: =?EUC-KR?B?IsCvurS8rihCeWVvbmdzZW9rIFl1KSI=?= <golmoon@naver.com>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Input line of a terminal is messed and broken
X-TERRACE-DUMMYSUBJECT: Terrace Spam system *
X-TERRACE-DUMMYSUBJECT: Terrace Spam system *
Content-Type: text/plain; charset=EUC-KR
Content-Transfer-Encoding: 7bit
X-TERRACE-SPAMMARK: NOT spam-marked.                              
	(by Terrace)                                            
X-TERRACE-SPAMMARK: NOT spam-marked.                              
	(by Terrace)                                            
X-detected-operating-system: by eggs.gnu.org: Linux 2.6? (barebone, rare!)
X-Received-From: 114.111.39.71
X-Mailman-Approved-At: Sun, 15 Apr 2012 14:56:44 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 15 Apr 2012 13:22:04 -0000

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: darwin11.3.0
Compiler: /usr/bin/clang
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='darwin11.3.0' -DCONF_MACHTYPE='i386-apple-darwin11.3.0'
-DCONF_VENDOR='apple' -DLOCALEDIR='/opt/local/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DMACOSX -I. -I. -I./include
-I./lib -I/opt/local/include -pipe -O2 -arch x86_64
uname output: Darwin yubyeongseog-ui-MacBook-Air.local 11.3.0 Darwin
Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012;
root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
Machine Type: i386-apple-darwin11.3.0

Bash Version: 4.2
Patch Level: 24
Release Status: release

Description:
Input line is messed and broken.

Repeat-By:
1. $export PS1=\e[34;40m[\u@\h \w]\e[m
2. #cd subfolders successively until PS1 echoes go over the half portion
of input line of a terminal screen width.
3. $ls <tab> # key to show up the file candidates.
4. You will see abnormal display - something like wrapping-around to the
beginning position

Fix:
[Description of how to fix the problem. If you don't know a
fix for the problem, don't include this section.]






From MAILER-DAEMON Sun Apr 15 16:00:41 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJVcn-0001SV-JV
	for mharc-bug-bash@gnu.org; Sun, 15 Apr 2012 16:00:41 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48622)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJVcj-0001LA-EM
	for bug-bash@gnu.org; Sun, 15 Apr 2012 16:00:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJVcd-0003GG-OE
	for bug-bash@gnu.org; Sun, 15 Apr 2012 16:00:36 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:43987
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJVcd-0003Cr-06
	for bug-bash@gnu.org; Sun, 15 Apr 2012 16:00:31 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3FK0Hf6009078; Sun, 15 Apr 2012 13:00:19 -0700
Message-ID: <4F8B28D1.5050402@tlinx.org>
Date: Sun, 15 Apr 2012 13:00:17 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Andreas Schwab <schwab@linux-m68k.org>
Subject: Re: inconsistency with "readonly" and scope
References: <20120411185014.GG22241@eeg.ccf.org>
	<4F85E59C.4020702@web.de>	<4F86CA2B.4010400@case.edu>
	<4F871C05.10204@web.de>	<4F873708.10207@syslang.net>
	<4F877BEA.4000602@case.edu>	<4F88C9C2.9080709@tlinx.org>
	<4F8A2296.8020608@case.edu>	<01C7E101-8902-444A-BCFE-5FA74D181A1D@lyndir.com>
	<m27gxhcr8b.fsf@linux-m68k.org>
In-Reply-To: <m27gxhcr8b.fsf@linux-m68k.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: chet.ramey@case.edu, bug-bash <bug-bash@gnu.org>,
	Maarten Billemont <lhunath@lyndir.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 15 Apr 2012 20:00:39 -0000



Andreas Schwab wrote:

> Maarten Billemont <lhunath@lyndir.com> writes:
> 
>> On 15 Apr 2012, at 03:21, Chet Ramey wrote:
>>> If I declare a variable readonly at global scope, I wouldn't expect it
>>> to be overridden by some local namespace pollution.
>> I think that's fine; in the local context, your variable has a
>> different meaning; it's another variable with the same name.
> 
> If the variable is exported the local variable overrides the exported
> value.
> 
> Andreas.


If the local variable is exported to be 'global', then
how is that a local variable?




From MAILER-DAEMON Sun Apr 15 16:38:31 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJWDP-0000lu-SZ
	for mharc-bug-bash@gnu.org; Sun, 15 Apr 2012 16:38:31 -0400
Received: from eggs.gnu.org ([208.118.235.92]:54161)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJWDM-0000ex-Pm
	for bug-bash@gnu.org; Sun, 15 Apr 2012 16:38:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJWDK-0000to-S9
	for bug-bash@gnu.org; Sun, 15 Apr 2012 16:38:28 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:44628
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJWDK-0000tE-4Y
	for bug-bash@gnu.org; Sun, 15 Apr 2012 16:38:26 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3FKcFYs007424; Sun, 15 Apr 2012 13:38:18 -0700
Message-ID: <4F8B31B7.7090006@tlinx.org>
Date: Sun, 15 Apr 2012 13:38:15 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Pierre Gaston <pierre.gaston@gmail.com>, bug-bash <bug-bash@gnu.org>
Subject: Re: how are aliases exported?
References: <4F88BE66.1020401@tlinx.org>
	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>
	<4F88C87C.6030803@tlinx.org>
	<CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
	<CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
In-Reply-To: <CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id
	q3FKcFYs007424
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 15 Apr 2012 20:38:30 -0000



Pierre Gaston wrote:

>=20
>=20
> On Sat, Apr 14, 2012 at 8:31 AM, Pierre Gaston <pierre.gaston@gmail.com=
=20
> <mailto:pierre.gaston@gmail.com>> wrote:
>=20
>=20
>=20
>     On Sat, Apr 14, 2012 at 3:44 AM, Linda Walsh <bash@tlinx.org
>     <mailto:bash@tlinx.org>> wrote:
>=20
>=20
>=20
>         Dennis Williamson wrote:
>=20
>             Aliases are intended for command line convenience. You
>             should use
>             functions, which can be exported and are the correct thing
>             to use in
>             scripts (and even from the command line).
>=20
>             "For almost every purpose, shell functions are preferred
>             over aliases."
>=20
>             But, of course, you know that already.
>=20
>=20
>         ---
>         =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BDYeah... and I've already=
 demonstrated the 'almost' part.
>=20
>         It's one of those:
>=20
>         function _include_h { return "source <liblookup>$1" ;}
>=20
>=20
>         alias include=3D'eval $( _include_h "$1")'
>=20
>         Near as I can tell, you can't do that in a function.
>         If you source a file in a function, the local vars in the file
>         would be local to the function -- not to the prog using the ali=
as
>=20
>=20
>     local vars in the file? what is this?=20
>=20
>=20
> Oh I get it, the non working code put me off (returning a string really=
?)
>=20
> You mean if you have "declare var=3Dfoo" in a file and then source it f=
rom=20
> a function the variable will be local to the function, newer bash=20
> versions have a -g option to work around this.

---
	Yeah, but I was hoping for a more portable solution.


Problem the various versions of bash are neither forward nor backward
compatible in various areas that hit my scripts.  Who's to say -g won't g=
o
away in the next version?

Is it posix?  At least aliases and functions are in posix ..

What do you mean non working code?... the fact that I didn't expand the
internals of the function?  Sorry, I didn't think it would be
interesting to folks..


But if you want 'working' [sic] (doesn't because alias isn't easily=20
exportable...).. but putting the alias definition in an exported var that
is evale'd in bash_env, would do the trick -- I use that to make arrays
inheritable as well...


---

!/bin/bash  -x


shopt -s expand_aliases
alias dcl=3Ddeclare

dcl -x _SPATH
dcl -xa _FPATH
dcl -xA _INC

function _include_h {
# [[ ${0##*/} =3D=3D include ]] && { exec "$@" ; }
   [[ -z $1 ]] && return 1
   dcl fnc=3D$1
   [[ $PATH !=3D $_SPATH ]] && {
     unset _FPATH; dcl -xa _FPATH=3D( $( IFS=3D:;  echo $PATH ) )
     unset _SPATH; dcl -x _SPATH=3D"$PATH"
   }

   if [[ ! ${_INC[$fnc]:-""}  ]]; then
     for pw in "${_FPATH[@]}"; do
       if [[ -r $pw/$fnc ]]; then
         printf "%s" "source \"$pw/$fnc\""   && _INC[$fnc]=3D"$pw/$fnc" &=
& return 0
       fi
     done
     echo "ERROR: Missing \"$fnc\" in \$PATH" >&2
     exit 2
   fi
}

export -f _include_h
alias include=3D'eval $( _include_h "$1")'
export include

# test if initial include -- if so, restart with aliases defined...
[[ ${0##*/} =3D=3D include ]] && { exec "$@" ; }
# else include the arg
include "$@"

# vim: ts=3D2 sw=3D2


From MAILER-DAEMON Sun Apr 15 16:52:17 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJWQj-0004iZ-JF
	for mharc-bug-bash@gnu.org; Sun, 15 Apr 2012 16:52:17 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47498)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJWQg-0004iI-Bf
	for bug-bash@gnu.org; Sun, 15 Apr 2012 16:52:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJWQe-00050P-Ek
	for bug-bash@gnu.org; Sun, 15 Apr 2012 16:52:13 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:44872
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJWQd-000501-P5
	for bug-bash@gnu.org; Sun, 15 Apr 2012 16:52:12 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3FKq2UQ015335; Sun, 15 Apr 2012 13:52:05 -0700
Message-ID: <4F8B34F2.40907@tlinx.org>
Date: Sun, 15 Apr 2012 13:52:02 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: Re: how are aliases exported?
References: <4F88BE66.1020401@tlinx.org>	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>	<4F88C87C.6030803@tlinx.org>	<CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
	<CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
In-Reply-To: <CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: Pierre Gaston <pierre.gaston@gmail.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 15 Apr 2012 20:52:15 -0000



Pierre Gaston wrote:



> 2) non-interactive bash
> Aliases are off by default. So given that you need to run something at the
> beginning of your new bash instance anyway, you could define your aliases
> in a function together with the mandatory shopt, eg:
> 
> function start_aliases {
>        shopt -s expand_aliases
>        alias foo=ls
> }
> export -f start_aliases
> 
> Then you can do:
> bash  <<< $'start_aliases\nfoo'
> 
> Note that the function need to be on a line before the first use of the
> alias, eg bash -c 'start_aliases;foo' doesn't work.
> 
> You can even make a kinda of export alias function with a hack like:
> function start_aliases {
>        shopt -s expand_aliases
>        eval "$my_aliases"
> }

---
Right... that's what I was going for as a work around.


But I want the syntax

include file.shh

to just 'work', i.e. first time, it would call my include file, which defines
the function...
but then when I include stuff in file.ssh,
my include file won't know what is in it.

So I can't very well go and apply "-g" to everything --

I just need it to execute in the top context. not from within a function.

The only way I see to do that is using an alias with an eval
of the contents of the include...




Then everything is as if it was simply 'sourced'...

Except that you can include

include	Math/Simple.shh

and it will still look it up on your path.






From MAILER-DAEMON Sun Apr 15 17:13:39 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJWlP-0000Y6-TS
	for mharc-bug-bash@gnu.org; Sun, 15 Apr 2012 17:13:39 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51603)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SJWlN-0000Xg-KC
	for bug-bash@gnu.org; Sun, 15 Apr 2012 17:13:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SJWlL-0002v5-10
	for bug-bash@gnu.org; Sun, 15 Apr 2012 17:13:37 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:62434)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SJWlK-0002uU-Sh
	for bug-bash@gnu.org; Sun, 15 Apr 2012 17:13:34 -0400
Received: from mpv7.tis.cwru.edu (EHLO mpv7.case.edu) ([129.22.104.170])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXR74766 (AUTH cpr);
	Sun, 15 Apr 2012 17:13:32 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id THB18218 (AUTH cpr);
	Sun, 15 Apr 2012 17:13:32 -0400 (EDT)
Message-ID: <4F8B39E6.1030901@case.edu>
Date: Sun, 15 Apr 2012 17:13:10 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: =?UTF-8?B?IuycoOuzkeyEnShCeWVvbmdzZW9rIFl1KSI=?= <golmoon@naver.com>
Subject: Re: Input line of a terminal is messed and broken
References: <4F8ACB6B.5010402@naver.com>
In-Reply-To: <4F8ACB6B.5010402@naver.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 15 Apr 2012 21:13:39 -0000

On 4/15/12 9:21 AM, "ěś ëł‘ě„ť(Byeongseok Yu)" wrote:

> Bash Version: 4.2
> Patch Level: 24
> Release Status: release
> 
> Description:
> Input line is messed and broken.
> 
> Repeat-By:
> 1. $export PS1=\e[34;40m[\u@\h \w]\e[m
> 2. #cd subfolders successively until PS1 echoes go over the half portion
> of input line of a terminal screen width.
> 3. $ls <tab> # key to show up the file candidates.
> 4. You will see abnormal display - something like wrapping-around to the
> beginning position

You forgot to use \[ and \] to bracket sequences of non-printing
characters in the prompt.  If you don't indicate which characters don't
take up any screen space, readline miscalculates the length of the
prompt and the location of the cursor on the screen.

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


From MAILER-DAEMON Sun Apr 15 19:14:56 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJYem-0006r6-Kg
	for mharc-bug-bash@gnu.org; Sun, 15 Apr 2012 19:14:56 -0400
Received: from eggs.gnu.org ([208.118.235.92]:35481)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SJYej-0006r0-CJ
	for bug-bash@gnu.org; Sun, 15 Apr 2012 19:14:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SJYeh-00040b-Ek
	for bug-bash@gnu.org; Sun, 15 Apr 2012 19:14:52 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:21256)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SJYeh-00040I-A8
	for bug-bash@gnu.org; Sun, 15 Apr 2012 19:14:51 -0400
Received: from mpv8.tis.cwru.edu (EHLO mpv8.case.edu) ([129.22.105.116])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXR78435 (AUTH cpr);
	Sun, 15 Apr 2012 19:14:49 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TNO25402 (AUTH cpr);
	Sun, 15 Apr 2012 19:14:49 -0400 (EDT)
Message-ID: <4F8B5665.1020107@case.edu>
Date: Sun, 15 Apr 2012 19:14:45 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Petr Sumbera <petr.sumbera@oracle.com>
Subject: Re: small fix for lib/sh/snprintf.c
References: <4F8701F3.6000002@oracle.com> <4F8772D5.9000300@case.edu>
	<4F8827BE.9090109@oracle.com> <4F8830DB.50908@oracle.com>
In-Reply-To: <4F8830DB.50908@oracle.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 15 Apr 2012 23:14:54 -0000

On 4/13/12 9:57 AM, Petr Sumbera wrote:
> On 04/13/12 03:18 PM, Petr Sumbera wrote:
> 
>> Problem 2:
>> ==========
>>
>> bash -c 'printf "x%+010.0fx\n" 123'
>> x000000+123x
>>
>> where it should be:
>> x+000000123x
>>
>> Fixed in chunk #3 (but the problem is there also for other types!).
> 
> My fix breaks following case:

Thanks, the patches are very helpful.

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


From MAILER-DAEMON Mon Apr 16 03:54:48 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJgls-0002l8-5A
	for mharc-bug-bash@gnu.org; Mon, 16 Apr 2012 03:54:48 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45265)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJglo-0002kN-W7
	for bug-bash@gnu.org; Mon, 16 Apr 2012 03:54:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJgln-0005oP-2n
	for bug-bash@gnu.org; Mon, 16 Apr 2012 03:54:44 -0400
Received: from mail-wi0-f171.google.com ([209.85.212.171]:36173)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJglm-0005oK-Mo
	for bug-bash@gnu.org; Mon, 16 Apr 2012 03:54:42 -0400
Received: by wibhj13 with SMTP id hj13so6454584wib.12
	for <bug-bash@gnu.org>; Mon, 16 Apr 2012 00:54:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=Jtcnn7BWbW64MxDBUOfJFKmhYJtEb4b6AVXLjIJ+9NY=;
	b=M68wf/bVQUbrHXnfRPL1+w7u/J6w6mROHIeEsXP4ZjirTBtcDQcb6RGpaFUgGW6TXQ
	UeOt7dfzq+QVc3y4aanT3035XwwYwotnf+ec9kwVaJaArZqINzG4570ipjMMaShV56GE
	X9Q0k/bh32MOSGjLXOwqm77BjS8rQe3tNochU=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=Jtcnn7BWbW64MxDBUOfJFKmhYJtEb4b6AVXLjIJ+9NY=;
	b=nMRqxcX50rd6KuPuHxL7gTVZFbDL6yjawpBK5rHgWuxSXO/L2Mu3YExpfTLCx3FDKD
	R6hMj/5yoynATQ44izJI24UUR1RA3L+jXHc/JpRjPVeiqwmHx8CZNr3tZ7rVmdYtaPKs
	QLgB7rqCR4pJkINaJfQfy0hsQKZeqANjriGK4EsNvVtQA2/uIR4XXnIb/PoBxj+fRfiL
	s+Hg2JIqAA9ZEC503MxK8x5rjc90r0TPAqKu16KUnQP5i0CUC+YyerGdJvpDk8VEnGif
	avnUJzhUJjd8vmakBbRLud7HKv7sjL7YZ9RDGicenP17yDrkxxQXqSixqMXeRuoc569J
	qibQ==
Received: by 10.180.81.166 with SMTP id b6mr5494915wiy.0.1334562880457;
	Mon, 16 Apr 2012 00:54:40 -0700 (PDT)
Received: from [10.9.10.10] (c253.adsl.inet-telecom.org. [83.170.109.115])
	by mx.google.com with ESMTPS id 17sm18302697wis.0.2012.04.16.00.54.38
	(version=TLSv1/SSLv3 cipher=OTHER);
	Mon, 16 Apr 2012 00:54:39 -0700 (PDT)
Subject: Re: how are aliases exported?
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_AD9AD613-AD6A-4740-8E6C-E03D8B1AD15D";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <4F8B34F2.40907@tlinx.org>
Date: Mon, 16 Apr 2012 09:54:37 +0200
Message-Id: <B693D054-CA17-4C26-9962-4B750DF1D015@lyndir.com>
References: <4F88BE66.1020401@tlinx.org>	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>	<4F88C87C.6030803@tlinx.org>	<CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
	<CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
	<4F8B34F2.40907@tlinx.org>
To: Linda Walsh <bash@tlinx.org>
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQloPmHueBjPzjjhSBUNhvz+mmQ1MEfPSDG3Z5jskIxeKNyY9BdX+TkTUsgzzUbyJ9gH8osn
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.212.171
Cc: bug-bash <bug-bash@gnu.org>, Pierre Gaston <pierre.gaston@gmail.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 16 Apr 2012 07:54:46 -0000


--Apple-Mail=_AD9AD613-AD6A-4740-8E6C-E03D8B1AD15D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 15 Apr 2012, at 22:52, Linda Walsh wrote:
>=20
> But I want the syntax
>=20
> include file.shh
>=20
> to just 'work', i.e. first time, it would call my include file, which =
defines
> the function...

I'm sorry, tell me again why you don't just write "source file.sh" =
instead of having to invent your own "include file.sh"?

If you really want to create custom syntax, write and enable your own =
built-in.

As a side note, you should probably have a slash in there somewhere =
unless you intend for bash to search PATH for the file.=

--Apple-Mail=_AD9AD613-AD6A-4740-8E6C-E03D8B1AD15D
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDE2MDc1NDM4WjAjBgkqhkiG9w0BCQQx
FgQUA9OdULGphQ4TNzBRhVOzaNKlEogwgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGAEyHEVkgLVnk0gheLVEm0TYPa
lnRnOgR1R0Gp+PAcpdPUvgZoWJHdV5NGlUIfE3uAiNBAVeeofTnzjtP89gf+iv/8L5GPfQybu8Zv
6K5eGbMfvJ6iuPWBVLT7fzDtKXQs/RhDgE9VxfWYBCj2jm3TEYNWKypU2CHm7L13QOyY7WsAAAAA
AAA=

--Apple-Mail=_AD9AD613-AD6A-4740-8E6C-E03D8B1AD15D--


From MAILER-DAEMON Mon Apr 16 04:03:34 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJguM-0003kU-SC
	for mharc-bug-bash@gnu.org; Mon, 16 Apr 2012 04:03:34 -0400
Received: from eggs.gnu.org ([208.118.235.92]:42732)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJguE-0003gP-G6
	for bug-bash@gnu.org; Mon, 16 Apr 2012 04:03:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJgu9-0000su-EZ
	for bug-bash@gnu.org; Mon, 16 Apr 2012 04:03:26 -0400
Received: from mail-we0-f169.google.com ([74.125.82.169]:65078)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJgu9-0000s7-3Z
	for bug-bash@gnu.org; Mon, 16 Apr 2012 04:03:21 -0400
Received: by werj55 with SMTP id j55so4038805wer.0
	for <bug-bash@gnu.org>; Mon, 16 Apr 2012 01:03:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=JqWyB5Emd2jRukqtpiioJSrdGRFHnEKXeh6LgwOzxGA=;
	b=Fl9ey6I5SOu3Gz72NqLTCss5Vh1IxBp+ybwIuWaqIShieDXgUz3v7Gti1M2lECpYoM
	+6zlFsHjO6EF7WMwaDxHy7TG4Y17UFtCNUDFpyUh1wkLpkFN2/AC3N1j64fxVKhYxhMa
	EH+vprNLPFG6vB9MORXlY4/Rqog6w03gjXtdw=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=JqWyB5Emd2jRukqtpiioJSrdGRFHnEKXeh6LgwOzxGA=;
	b=kN4w9ALKvsHd+InMg7hRrsjF2asHfw4W5dVx0YiisSA+p+HRRXBlkncfjg9Pkt5T8U
	7jWVXcO3EQh9wjN3XXqtpEpLGub8bv7yuA3H/9yy0YR9IYHvSWi2zCu9JOzgr80NFLIe
	H7kC5dGAoi0ffJJlhmjkE+fZUf1AUZKDJ/CUtMyoxNH7GpjwEbEcdTMxs+/2GzonMH/K
	jc/Pm9B6/zSWLz/BBtZ0zMj4MLiLkBoeDlBv72gop+X44tQUKaAOZb+d+mt4wUPLpRUW
	ptlaw45AXsd4FiaAuSpXlYoxC519WkkLVM1DCEovmV7yiheSt5JSH3uoTQj5c371VLHr
	WoMg==
Received: by 10.180.101.8 with SMTP id fc8mr2508290wib.12.1334563399106;
	Mon, 16 Apr 2012 01:03:19 -0700 (PDT)
Received: from [10.9.10.10] (c253.adsl.inet-telecom.org. [83.170.109.115])
	by mx.google.com with ESMTPS id gg2sm29115497wib.7.2012.04.16.01.03.17
	(version=TLSv1/SSLv3 cipher=OTHER);
	Mon, 16 Apr 2012 01:03:18 -0700 (PDT)
Subject: Re: how are aliases exported?
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_F44C50E9-560A-4179-98C7-69C2DC82B00E";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <B693D054-CA17-4C26-9962-4B750DF1D015@lyndir.com>
Date: Mon, 16 Apr 2012 10:03:16 +0200
Message-Id: <0709CDB5-514E-4CC6-B613-11DBCFD4F7AA@lyndir.com>
References: <4F88BE66.1020401@tlinx.org>	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>	<4F88C87C.6030803@tlinx.org>	<CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
	<CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
	<4F8B34F2.40907@tlinx.org>
	<B693D054-CA17-4C26-9962-4B750DF1D015@lyndir.com>
To: Linda Walsh <bash@tlinx.org>
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQn4hu6HwfakXgGLBGv8mqB/Vgvzs2CUJ8irbRrHduIJsoq+QfmXa1erp7q0TcB0Y/CRgRpQ
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 74.125.82.169
Cc: bug-bash <bug-bash@gnu.org>, Pierre Gaston <pierre.gaston@gmail.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 16 Apr 2012 08:03:33 -0000


--Apple-Mail=_F44C50E9-560A-4179-98C7-69C2DC82B00E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 16 Apr 2012, at 09:54, Maarten Billemont wrote:
> On 15 Apr 2012, at 22:52, Linda Walsh wrote:
>>=20
>> But I want the syntax
>>=20
>> include file.shh
>>=20
>> to just 'work', i.e. first time, it would call my include file, which =
defines
>> the function...
>=20
> I'm sorry, tell me again why you don't just write "source file.sh" =
instead of having to invent your own "include file.sh"?


I just realized, you appear to be looking for a way to define a "source =
path" to search for the file.

PATH=3D/foo:/bar:/etc source file

or

PATH=3D$SOURCEPATH source file

I know it's not as "clean" as "include file", but it's certainly more =
clear as to what it does.  And clarity is more important, IMO.  Also, it =
conveniently also doesn't require insane hacks.=

--Apple-Mail=_F44C50E9-560A-4179-98C7-69C2DC82B00E
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDE2MDgwMzE2WjAjBgkqhkiG9w0BCQQx
FgQUuMAglYKWUFknSWpzI0HtQC0BPlEwgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGAlD4l3maPP3j3qwqod3m4ko2v
DdwqcBobDTdokdxBch8e43zEiDYHtl8Pk3uIBraVUKcH/Zh812AkTQroi4+eGXA377X/Qqg/oieB
FLsSnsAxIrX3roLDsHOcCIoL1lTLdK/K27FXUUE6TUhZ9kGfxdc2Q7SchLsvc29PenNDknUAAAAA
AAA=

--Apple-Mail=_F44C50E9-560A-4179-98C7-69C2DC82B00E--


From MAILER-DAEMON Mon Apr 16 04:31:08 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJhL2-0002P8-G3
	for mharc-bug-bash@gnu.org; Mon, 16 Apr 2012 04:31:08 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58503)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SJhKv-0002P0-Fo
	for bug-bash@gnu.org; Mon, 16 Apr 2012 04:31:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SJhKp-00039M-6t
	for bug-bash@gnu.org; Mon, 16 Apr 2012 04:31:01 -0400
Received: from rcsinet15.oracle.com ([148.87.113.117]:48285)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <petr.sumbera@oracle.com>) id 1SJhKp-00038s-0T
	for bug-bash@gnu.org; Mon, 16 Apr 2012 04:30:55 -0400
Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93])
	by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with
	ESMTP id q3G8UmXD026260
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Mon, 16 Apr 2012 08:30:49 GMT
Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158])
	by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
	q3G8UlWF026206
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Mon, 16 Apr 2012 08:30:48 GMT
Received: from abhmt108.oracle.com (abhmt108.oracle.com [141.146.116.60])
	by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id
	q3G8UlZQ025700; Mon, 16 Apr 2012 03:30:47 -0500
Received: from [10.163.101.52] (/10.163.101.52)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Mon, 16 Apr 2012 01:30:47 -0700
Message-ID: <4F8BD8B5.6090903@oracle.com>
Date: Mon, 16 Apr 2012 10:30:45 +0200
From: Petr Sumbera <petr.sumbera@oracle.com>
User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US;
	rv:1.9.2.13) Gecko/20110117 Lightning/1.0b2 Thunderbird/3.1.7
MIME-Version: 1.0
To: chet.ramey@case.edu
Subject: Re: small fix for lib/sh/snprintf.c
References: <4F8701F3.6000002@oracle.com> <4F8772D5.9000300@case.edu>
	<4F8827BE.9090109@oracle.com> <4F8830DB.50908@oracle.com>
	<4F8B5665.1020107@case.edu>
In-Reply-To: <4F8B5665.1020107@case.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Source-IP: ucsinet21.oracle.com [156.151.31.93]
X-CT-RefId: str=0001.0A090208.4F8BD8B9.00E8,ss=1,re=0.000,fgs=0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1)
X-Received-From: 148.87.113.117
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 16 Apr 2012 08:31:07 -0000

I have found one more problem:

I'm getting following:
bash -c 'printf "x%+fx\n" -0'
x+0.000000x

where it should be:
x-0.000000x

This is cause by:

/* round off to the precision */
#define ROUND(d, p) \
             (d < 0.) ? \
              d - pow_10(-(p)->precision) * 0.5 : \
              d + pow_10(-(p)->precision) * 0.5

where (-0 < 0.) isn't true.

And there is probably no easy solution for this:

http://en.wikipedia.org/wiki/Signed_zero

Thanks,

Petr

On 04/16/12 01:14 AM, Chet Ramey wrote:
> On 4/13/12 9:57 AM, Petr Sumbera wrote:
>> On 04/13/12 03:18 PM, Petr Sumbera wrote:
>>
>>> Problem 2:
>>> ==========
>>>
>>> bash -c 'printf "x%+010.0fx\n" 123'
>>> x000000+123x
>>>
>>> where it should be:
>>> x+000000123x
>>>
>>> Fixed in chunk #3 (but the problem is there also for other types!).
>>
>> My fix breaks following case:
>
> Thanks, the patches are very helpful.
>
> Chet



From MAILER-DAEMON Mon Apr 16 05:43:42 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJiTG-000664-A3
	for mharc-bug-bash@gnu.org; Mon, 16 Apr 2012 05:43:42 -0400
Received: from eggs.gnu.org ([208.118.235.92]:60476)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJiTD-00065a-OM
	for bug-bash@gnu.org; Mon, 16 Apr 2012 05:43:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJiT4-0002G1-Oi
	for bug-bash@gnu.org; Mon, 16 Apr 2012 05:43:39 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:60599
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJiT3-0002Dp-UL
	for bug-bash@gnu.org; Mon, 16 Apr 2012 05:43:30 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3G9hNqV003248; Mon, 16 Apr 2012 02:43:25 -0700
Message-ID: <4F8BE9BB.30407@tlinx.org>
Date: Mon, 16 Apr 2012 02:43:23 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Maarten Billemont <lhunath@lyndir.com>, bug-bash <bug-bash@gnu.org>
Subject: Re: how are aliases exported?
References: <4F88BE66.1020401@tlinx.org>	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>	<4F88C87C.6030803@tlinx.org>	<CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
	<CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
	<4F8B34F2.40907@tlinx.org>
	<B693D054-CA17-4C26-9962-4B750DF1D015@lyndir.com>
	<0709CDB5-514E-4CC6-B613-11DBCFD4F7AA@lyndir.com>
In-Reply-To: <0709CDB5-514E-4CC6-B613-11DBCFD4F7AA@lyndir.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 16 Apr 2012 09:43:41 -0000



Maarten Billemont wrote:

> On 16 Apr 2012, at 09:54, Maarten Billemont wrote:
>> On 15 Apr 2012, at 22:52, Linda Walsh wrote:
>>> But I want the syntax
>>>
>>> include file.shh
>>>
>>> to just 'work', i.e. first time, it would call my include file, which defines
>>> the function...
>> I'm sorry, tell me again why you don't just write "source file.sh" instead of having to invent your own "include file.sh"?
> 
> 
> I just realized, you appear to be looking for a way to define a "source path" to search for the file.
> 
> PATH=/foo:/bar:/etc source file
> 
> or
> 
> PATH=$SOURCEPATH source file
> 
> I know it's not as "clean" as "include file", but it's certainly more clear as to what it does. 


 And clarity is more important, IMO.  Also, it conveniently also doesn't require insane hacks.


But it won't work for files below the top level of the library directory.

if I have include system/errno.shh,   Source is crippled to not look in PATH.




From MAILER-DAEMON Mon Apr 16 09:24:42 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJlv8-00073O-SB
	for mharc-bug-bash@gnu.org; Mon, 16 Apr 2012 09:24:42 -0400
Received: from eggs.gnu.org ([208.118.235.92]:42603)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJlv1-00071t-82
	for bug-bash@gnu.org; Mon, 16 Apr 2012 09:24:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJluz-0007lB-DX
	for bug-bash@gnu.org; Mon, 16 Apr 2012 09:24:34 -0400
Received: from mail-wi0-f171.google.com ([209.85.212.171]:54990)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SJluz-0007kb-1I
	for bug-bash@gnu.org; Mon, 16 Apr 2012 09:24:33 -0400
Received: by wibhj13 with SMTP id hj13so6655262wib.12
	for <bug-bash@gnu.org>; Mon, 16 Apr 2012 06:24:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=+EutA+f8HiGOCGGjsWxtN48rcoXdaCZ5Mp2JWios6nc=;
	b=hy6F7VZxd0i34ReY8El0fvLPU67yoPTsd/YmarGEyyhXnIqEirDQCnYbBoBjsWM4vS
	RP1ecg4zzSEFZ9Qfz//8dtBN4HgiFhoZK+hXkZB2LSsI0rWfxbgMFDRlSTZBhK31mlzs
	AZv2BMui8xKPHOzjG4UTgBvijoIbGMpvv0w2k=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=+EutA+f8HiGOCGGjsWxtN48rcoXdaCZ5Mp2JWios6nc=;
	b=GEEefwBYhZjAQdiNEJsmSZKDGpQmRjh+HVwKSzaugLvxO8LQIueJz9A1IuswXrb95i
	nzpNhfv8czdj67vX9dz3v3nK/naHlVuyrYZ7bsr7MDTnSGsNIKqj2pRDOygjKC3PaJLh
	qiAdJFNqAd5wpWoSsxGacDJQveoEAPTyyeBpVShrf5Vw0vTEdxYo2kqW/Fs0OqH/n3Mn
	fIPTXhMJRTRKPzoOFvrjVEF8M7t1aQAgN46rpA95u2ADuGiS25JcUyi0ChXy1UETynXy
	/+z6blWRTpIQnSvBMgqkEB7XS9kTTk6Oe9zxe6VLFvrGiLFAnRkiHf6y2/C0ymARx0X1
	L9Nw==
Received: by 10.180.107.132 with SMTP id hc4mr18646773wib.21.1334582668907;
	Mon, 16 Apr 2012 06:24:28 -0700 (PDT)
Received: from [10.9.10.26] (c253.adsl.inet-telecom.org. [83.170.109.115])
	by mx.google.com with ESMTPS id j3sm31714195wiw.1.2012.04.16.06.24.26
	(version=TLSv1/SSLv3 cipher=OTHER);
	Mon, 16 Apr 2012 06:24:27 -0700 (PDT)
Subject: Re: how are aliases exported?
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_88E104ED-2795-4B3A-ABF1-FC669A5F10CD";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <4F8BE9BB.30407@tlinx.org>
Date: Mon, 16 Apr 2012 15:24:23 +0200
Message-Id: <5187013E-F57F-49F6-A376-137EA7FA1859@lyndir.com>
References: <4F88BE66.1020401@tlinx.org>	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>	<4F88C87C.6030803@tlinx.org>	<CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
	<CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
	<4F8B34F2.40907@tlinx.org>
	<B693D054-CA17-4C26-9962-4B750DF1D015@lyndir.com>
	<0709CDB5-514E-4CC6-B613-11DBCFD4F7AA@lyndir.com>
	<4F8BE9BB.30407@tlinx.org>
To: Linda Walsh <bash@tlinx.org>
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQmg/RkLj4b3AJ4JRXY9oxSxHwIyNxydENBA6UNHOZPUVlo57aOXRpGsSm5OqgUFJxh8bTYx
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.212.171
Cc: bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 16 Apr 2012 13:24:41 -0000


--Apple-Mail=_88E104ED-2795-4B3A-ABF1-FC669A5F10CD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 16 Apr 2012, at 11:43, Linda Walsh wrote:
>=20
>=20
> But it won't work for files below the top level of the library =
directory.
>=20
> if I have include system/errno.shh,   Source is crippled to not look =
in PATH.

When there's a slash in the file, it stops searching PATH.

So the reason you're not doing source /lib/system/errno.sh is because =
you want it to search multiple possible lib dirs for a system subdir?=

--Apple-Mail=_88E104ED-2795-4B3A-ABF1-FC669A5F10CD
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDE2MTMyNDI1WjAjBgkqhkiG9w0BCQQx
FgQUC9LNYgneKBn0CV4+xKTk/xrFBSQwgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGAaW1Ra28QD50sTOrphUNZXrdR
EdWrkSscqJwkJO0AYx+bxT3ClRRBzdnnJJ50D87JP9yOeAJ4P4e6H0aA9Cu7qDF7sQuXygxghqbR
NDuYQW3BXnYkRK2NFx6a1ZWVQsy0+hAuQ9J3rdHJFmbX6xdR+BPWHczcU8QPdHMPT71pu1AAAAAA
AAA=

--Apple-Mail=_88E104ED-2795-4B3A-ABF1-FC669A5F10CD--


From MAILER-DAEMON Mon Apr 16 19:03:23 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SJux9-0005gP-KK
	for mharc-bug-bash@gnu.org; Mon, 16 Apr 2012 19:03:23 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59739)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJux7-0005fr-06
	for bug-bash@gnu.org; Mon, 16 Apr 2012 19:03:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJux5-0001gG-BL
	for bug-bash@gnu.org; Mon, 16 Apr 2012 19:03:20 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:46887
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SJux3-0001ci-TH
	for bug-bash@gnu.org; Mon, 16 Apr 2012 19:03:19 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3GN36dq022245; Mon, 16 Apr 2012 16:03:10 -0700
Message-ID: <4F8CA52A.4090903@tlinx.org>
Date: Mon, 16 Apr 2012 16:03:06 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Maarten Billemont <lhunath@lyndir.com>
Subject: Re: how are aliases exported?
References: <4F88BE66.1020401@tlinx.org>	<CANaoh6L3JX3r8O=Znb8qRixRQakEauq5dAhouhtOGhSHEB-MSQ@mail.gmail.com>	<4F88C87C.6030803@tlinx.org>	<CAPSX3sS1q9F5=kcV=pfpBd4YYDA9sa5qz-em_b_sC-kOhNgGBQ@mail.gmail.com>
	<CAPSX3sRNZmkBFiWrKDBT2Ad=CodsyjMk=FKerOEtW8C02KfapA@mail.gmail.com>
	<4F8B34F2.40907@tlinx.org>
	<B693D054-CA17-4C26-9962-4B750DF1D015@lyndir.com>
	<0709CDB5-514E-4CC6-B613-11DBCFD4F7AA@lyndir.com>
	<4F8BE9BB.30407@tlinx.org>
	<5187013E-F57F-49F6-A376-137EA7FA1859@lyndir.com>
In-Reply-To: <5187013E-F57F-49F6-A376-137EA7FA1859@lyndir.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 16 Apr 2012 23:03:22 -0000



Maarten Billemont wrote:

> On 16 Apr 2012, at 11:43, Linda Walsh wrote:
>>
>> But it won't work for files below the top level of the library directory.
>>
>> if I have include system/errno.shh,   Source is crippled to not look in PATH.
> 
> When there's a slash in the file, it stops searching PATH.
> 
> So the reason you're not doing source /lib/system/errno.sh is because you want it to search

 multiple possible lib dirs for a system subdir?

----

It's searching for system/errno.shh in ~/bin/lib.  In addition to the searching 
the <bin> starting dir, it also looks <bin>/lib for any library tree.

It also keeps track of files included, with the idea that they not be
re-included.

I want a segmented path that is searched for include files -- just like in C, 
Perl and most other languages.  I.e. -- dir hierarchies that are 'somepath' 
relative.  (be it LIB, INCLUDE, PERLLIB, PATH or SHLIB)... None of them use
absolute pathnames -- if you change the INCLUDE/LIB paths, you can use
a different base.

So multi-level hierarchical sourcing (include) -- and since BASH uses PATH
for sourcing files with the sourcepath option, I decided sticking to PATH
was a consistent choice.









From MAILER-DAEMON Wed Apr 18 09:20:11 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKUnr-0006VM-AV
	for mharc-bug-bash@gnu.org; Wed, 18 Apr 2012 09:20:11 -0400
Path: usenet.stanford.edu!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From: Victor Engmark <victor.engmark@gmail.com>
Newsgroups: gnu.bash.bug
Subject: Why are parameters to Bash's builtin optional?
Date: Wed, 18 Apr 2012 06:18:57 -0700 (PDT)
Organization: http://groups.google.com
Lines: 11
Message-ID: <698142.359.1334755137092.JavaMail.geo-discussion-forums@vbab2>
NNTP-Posting-Host: 84.73.54.61
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1334755137 12783 127.0.0.1 (18 Apr 2012 13:18:57
	GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 18 Apr 2012 13:18:57 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.73.54.61;
	posting-account=VuCHegoAAAA3_Mjkr_9uJw-UCDTaRb1R
User-Agent: G2/1.0
Xref: usenet.stanford.edu gnu.bash.bug:24485
To: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 18 Apr 2012 13:20:10 -0000

(Re-posted from Stack Overflow <http://unix.stackexchange.com/questions/367=
51/why-are-parameters-to-bashs-builtin-optional>)

Running simply `builtin` prints nothing and returns exit code 0. This is in=
 accordance with `help builtin`, which shows all parameters as optional. Bu=
t why isn't this no-op an error? Is there a use case for this? A more usefu=
l result would be an error code or, even better, listing the currently avai=
lable builtins.

Cheers,
V

From MAILER-DAEMON Wed Apr 18 09:30:09 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKUxV-0000eD-4U
	for mharc-bug-bash@gnu.org; Wed, 18 Apr 2012 09:30:09 -0400
Path: usenet.stanford.edu!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From: Victor Engmark <victor.engmark@gmail.com>
Newsgroups: gnu.bash.bug
Subject: Shouldn't "type" and "command" complain if there are no parameters?
Date: Wed, 18 Apr 2012 06:26:15 -0700 (PDT)
Organization: http://groups.google.com
Lines: 21
Message-ID: <5596614.529.1334755575982.JavaMail.geo-discussion-forums@ynbr30>
NNTP-Posting-Host: 84.73.54.61
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1334755659 17946 127.0.0.1 (18 Apr 2012 13:27:39
	GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 18 Apr 2012 13:27:39 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.73.54.61;
	posting-account=VuCHegoAAAA3_Mjkr_9uJw-UCDTaRb1R
User-Agent: G2/1.0
Xref: usenet.stanford.edu gnu.bash.bug:24486
To: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 18 Apr 2012 13:30:08 -0000

Re-post from <http://unix.stackexchange.com/questions/36752/why-are-parameters-to-bashs-command-and-type-optional>:

[T]hese commands print nothing and return exit code 0 if no parameters are provided. But [...] `help command` and `help type` both state that at least one parameter is mandatory. Is this a bug, a feature, or did I misunderstand something?

    $ bash --version
    GNU bash, version 4.2.10(1)-release (x86_64-pc-linux-gnu)
    $ type -a command
    command is a shell builtin
    $ type -a type
    type is a shell builtin
    $ help -s command
    command: command [-pVv] command [arg ...]
    victor@victor:/home/victor/taclom/rails (master *$)
    $ help -s type
    type: type [-afptP] name [name ...]
    $ command
    $ echo $?
    0
    $ type
    $ echo $?
    0

From MAILER-DAEMON Wed Apr 18 10:36:50 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKW02-00036g-Ql
	for mharc-bug-bash@gnu.org; Wed, 18 Apr 2012 10:36:50 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41373)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SKVzx-00034r-7Z
	for bug-bash@gnu.org; Wed, 18 Apr 2012 10:36:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SKVzs-000249-4f
	for bug-bash@gnu.org; Wed, 18 Apr 2012 10:36:44 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:50684)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SKVzr-00023j-W8
	for bug-bash@gnu.org; Wed, 18 Apr 2012 10:36:40 -0400
Received: from mpv5.tis.CWRU.Edu (EHLO mpv5.cwru.edu) ([129.22.105.51])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXU16945; Wed, 18 Apr 2012 10:36:37 -0400 (EDT)
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWE38036 (AUTH cpr);
	Wed, 18 Apr 2012 10:36:36 -0400 (EDT)
Message-ID: <4F8ED174.4020800@case.edu>
Date: Wed, 18 Apr 2012 10:36:36 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Victor Engmark <victor.engmark@gmail.com>
Subject: Re: Why are parameters to Bash's builtin optional?
References: <698142.359.1334755137092.JavaMail.geo-discussion-forums@vbab2>
In-Reply-To: <698142.359.1334755137092.JavaMail.geo-discussion-forums@vbab2>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 18 Apr 2012 14:36:49 -0000

On 4/18/12 9:18 AM, Victor Engmark wrote:
> (Re-posted from Stack Overflow <http://unix.stackexchange.com/questions/36751/why-are-parameters-to-bashs-builtin-optional>)
> 
> Running simply `builtin` prints nothing and returns exit code 0. This is in accordance with `help builtin`, which shows all parameters as optional. But why isn't this no-op an error? Is there a use case for this? A more useful result would be an error code or, even better, listing the currently available builtins.

What's the use case for having it be an error?  I can see printing a list
of builtins, though `enable' already does that.

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


From MAILER-DAEMON Wed Apr 18 11:30:08 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKWpc-0005NT-8n
	for mharc-bug-bash@gnu.org; Wed, 18 Apr 2012 11:30:08 -0400
Path: usenet.stanford.edu!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From: Victor Engmark <victor.engmark@gmail.com>
Newsgroups: gnu.bash.bug
Subject: Re: Why are parameters to Bash's builtin optional?
Date: Wed, 18 Apr 2012 08:27:01 -0700 (PDT)
Organization: http://groups.google.com
Lines: 29
Message-ID: <25668998.1425.1334762821795.JavaMail.geo-discussion-forums@vbbdy9>
References: <698142.359.1334755137092.JavaMail.geo-discussion-forums@vbab2>
	<mailman.150.1334759810.751.bug-bash@gnu.org>
NNTP-Posting-Host: 84.73.54.61
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1334762822 28758 127.0.0.1 (18 Apr 2012 15:27:02
	GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 18 Apr 2012 15:27:02 +0000 (UTC)
In-Reply-To: <mailman.150.1334759810.751.bug-bash@gnu.org>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.73.54.61;
	posting-account=VuCHegoAAAA3_Mjkr_9uJw-UCDTaRb1R
User-Agent: G2/1.0
Xref: usenet.stanford.edu gnu.bash.bug:24488
To: bug-bash@gnu.org
Cc: chet.ramey@case.edu, bug-bash@gnu.org,
	Victor Engmark <victor.engmark@gmail.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 18 Apr 2012 15:30:07 -0000

On Wednesday, April 18, 2012 4:36:36 PM UTC+2, Chet Ramey wrote:
> On 4/18/12 9:18 AM, Victor Engmark wrote:
> > (Re-posted from Stack Overflow <http://unix.stackexchange.com/questions=
/36751/why-are-parameters-to-bashs-builtin-optional>)
> >=20
> > Running simply `builtin` prints nothing and returns exit code 0. This i=
s in accordance with `help builtin`, which shows all parameters as optional=
. But why isn't this no-op an error? Is there a use case for this? A more u=
seful result would be an error code or, even better, listing the currently =
available builtins.
>=20
> What's the use case for having it be an error?

Since it's a nonsensical command, and since developers who haven't learned =
proper quoting shouldn't be shot too hard in the foot when they run `builti=
n $empty`. Or maybe they should be - Quoting is such a different matter fro=
m mainstream languages (and *much* more complex) that maybe `builtin` shoul=
d print simply "Use More Quotes!" Seriously though, Bash is difficult enoug=
h as it is, and a spoonful of language fussiness is worth a ton of guard co=
de.

>  I can see printing a list of builtins, though `enable' already does that=
.

I guess the difference would be that `builtin` prints *all* builtins, and *=
never* modifies their state.

Cheers,
V

From MAILER-DAEMON Wed Apr 18 13:03:56 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKYIO-00012R-Jw
	for mharc-bug-bash@gnu.org; Wed, 18 Apr 2012 13:03:56 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53879)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <victor.engmark@gmail.com>) id 1SKWmi-0004QN-Qv
	for bug-bash@gnu.org; Wed, 18 Apr 2012 11:27:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <victor.engmark@gmail.com>) id 1SKWme-0002G0-Ca
	for bug-bash@gnu.org; Wed, 18 Apr 2012 11:27:08 -0400
Received: from mail-vb0-f61.google.com ([209.85.212.61]:43905)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <victor.engmark@gmail.com>) id 1SKWme-0002Fi-8P
	for bug-bash@gnu.org; Wed, 18 Apr 2012 11:27:04 -0400
Received: by vbbfd1 with SMTP id fd1so23758395vbb.6
	for <bug-bash@gnu.org>; Wed, 18 Apr 2012 08:27:02 -0700 (PDT)
Received: by 10.52.67.79 with SMTP id l15mr227761vdt.0.1334762821991; Wed, 18
	Apr 2012 08:27:01 -0700 (PDT)
Path: glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: gnu.bash.bug
Date: Wed, 18 Apr 2012 08:27:01 -0700 (PDT)
In-Reply-To: <mailman.150.1334759810.751.bug-bash@gnu.org>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.73.54.61;
	posting-account=VuCHegoAAAA3_Mjkr_9uJw-UCDTaRb1R
NNTP-Posting-Host: 84.73.54.61
References: <698142.359.1334755137092.JavaMail.geo-discussion-forums@vbab2>
	<mailman.150.1334759810.751.bug-bash@gnu.org>
User-Agent: G2/1.0
X-Google-Web-Client: true
MIME-Version: 1.0
Message-ID: <25668998.1425.1334762821795.JavaMail.geo-discussion-forums@vbbdy9>
Subject: Re: Why are parameters to Bash's builtin optional?
From: Victor Engmark <victor.engmark@gmail.com>
To: gnu.bash.bug@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.212.61
X-Mailman-Approved-At: Wed, 18 Apr 2012 13:03:55 -0400
Cc: chet.ramey@case.edu, bug-bash@gnu.org,
	Victor Engmark <victor.engmark@gmail.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 18 Apr 2012 15:27:18 -0000

On Wednesday, April 18, 2012 4:36:36 PM UTC+2, Chet Ramey wrote:
> On 4/18/12 9:18 AM, Victor Engmark wrote:
> > (Re-posted from Stack Overflow <http://unix.stackexchange.com/questions=
/36751/why-are-parameters-to-bashs-builtin-optional>)
> >=20
> > Running simply `builtin` prints nothing and returns exit code 0. This i=
s in accordance with `help builtin`, which shows all parameters as optional=
. But why isn't this no-op an error? Is there a use case for this? A more u=
seful result would be an error code or, even better, listing the currently =
available builtins.
>=20
> What's the use case for having it be an error?

Since it's a nonsensical command, and since developers who haven't learned =
proper quoting shouldn't be shot too hard in the foot when they run `builti=
n $empty`. Or maybe they should be - Quoting is such a different matter fro=
m mainstream languages (and *much* more complex) that maybe `builtin` shoul=
d print simply "Use More Quotes!" Seriously though, Bash is difficult enoug=
h as it is, and a spoonful of language fussiness is worth a ton of guard co=
de.

>  I can see printing a list of builtins, though `enable' already does that=
.

I guess the difference would be that `builtin` prints *all* builtins, and *=
never* modifies their state.

Cheers,
V


From MAILER-DAEMON Thu Apr 19 06:25:32 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKoYO-0004VV-RJ
	for mharc-bug-bash@gnu.org; Thu, 19 Apr 2012 06:25:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47545)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKoYH-0004VK-Kk
	for bug-bash@gnu.org; Thu, 19 Apr 2012 06:25:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKoYB-0002Ec-CC
	for bug-bash@gnu.org; Thu, 19 Apr 2012 06:25:25 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:48998)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKoYB-0002E6-4N
	for bug-bash@gnu.org; Thu, 19 Apr 2012 06:25:19 -0400
Received: by obbeh20 with SMTP id eh20so6996538obb.0
	for <bug-bash@gnu.org>; Thu, 19 Apr 2012 03:25:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=FX69lmXcj9MTePjoWYrWQ3LBHb9ma/X0ruj0UsZD4kQ=;
	b=Bst6cPIBDLD1WukMsEpviW+hgR73jSBGtBfPvkejS/w8t6J0PIsyWMTV9sdopWZrhT
	v1QVBz9m9ikqDh8Uq2QzWOOwLr1x4S9G8GimYE7keJrGjAJtXy0yo4M7fdn0/AmBJE9e
	r8Qg5ctkzKdQbIPrdQhPm8o1QXNjU5KgWzLMXhNx3rpk168I88k4wkzBSqwbTIrYIKq5
	szzjzl7b0JWF/DfC8SexLFK50lPbfCCK/JleZaVa1QVdgQQw6FneNlMlOx/X0aTAGMGD
	hpw+s2CYodrp77BufZCWpOC1jeahjLxG/jREfiPpsWELXZj2VRLEqWz9gNUISqYgu1hK
	8+Zg==
MIME-Version: 1.0
Received: by 10.60.22.10 with SMTP id z10mr2089694oee.16.1334831117440; Thu,
	19 Apr 2012 03:25:17 -0700 (PDT)
Received: by 10.182.105.34 with HTTP; Thu, 19 Apr 2012 03:25:17 -0700 (PDT)
Date: Thu, 19 Apr 2012 12:25:17 +0200
Message-ID: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
Subject: Directory completion problems
From: Artur Rataj <arturrataj@gmail.com>
To: bug-bash@gnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 19 Apr 2012 10:25:31 -0000

hello, could you explain the following?

~/projects/art/dev/lib$ cd ../
.bzr/ lib/
~/projects/art/dev/lib$ cd ../src
~/projects/art/dev/src$

Artur

From MAILER-DAEMON Thu Apr 19 06:28:38 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKobO-0004jF-6r
	for mharc-bug-bash@gnu.org; Thu, 19 Apr 2012 06:28:38 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56669)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKobG-0004ht-Nt
	for bug-bash@gnu.org; Thu, 19 Apr 2012 06:28:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKobA-0002x3-Jr
	for bug-bash@gnu.org; Thu, 19 Apr 2012 06:28:30 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:42076)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKobA-0002wr-Bw
	for bug-bash@gnu.org; Thu, 19 Apr 2012 06:28:24 -0400
Received: by obbeh20 with SMTP id eh20so7001335obb.0
	for <bug-bash@gnu.org>; Thu, 19 Apr 2012 03:28:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:content-type; bh=aF9GJI1SU3H87Hq3hn1RBOCWEvxBoDgLT85HYR+fK7Q=;
	b=lLeuVH7RnT1MfLIopNOfvmZbK2rb45b7APQXbCjmgXjA6g34YVXWfRyHrLrSmlB9Z+
	rx/AsQPFZ0xjTxDIq/rwIYuNXNqGT6LJSOXPjyzeJQ0p716w9MRZ4wYypN7h8DP9H6De
	mADzdtClp8xIp9nQhX16pEHTvC49hpmxN1Wc7YHxDewYgBhzoFQlxEaA32Q1haQpoeMS
	ct4+WYyPuMXXj8r9YGFvetuhN/tR5uPgQyYe2xmC2fByVvIi4ITXQz+izhA+YqqjpVZR
	CKApNqS+pXN66VTwczpeZeY/5F5yYm33ra3KS6OoRp/q/bcFLFL7zQ08JRf8oqk+3u2I
	8owQ==
MIME-Version: 1.0
Received: by 10.60.169.146 with SMTP id ae18mr2047338oec.36.1334831302516;
	Thu, 19 Apr 2012 03:28:22 -0700 (PDT)
Received: by 10.182.105.34 with HTTP; Thu, 19 Apr 2012 03:28:22 -0700 (PDT)
In-Reply-To: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
Date: Thu, 19 Apr 2012 12:28:22 +0200
Message-ID: <CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
Subject: Re: Directory completion problems
From: Artur Rataj <arturrataj@gmail.com>
To: bug-bash@gnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 19 Apr 2012 10:28:36 -0000

~/projects/art/dev/lib$ cd ../
.bzr/ lib/
~/projects/art/dev/lib$ cd ../src
~/projects/art/dev/src$ cd ../
.bzr/ lib/ src/
~/projects/art/dev/src$ cd ../lib
~/projects/art/dev/lib$ cd ../
.bzr/ lib/

From MAILER-DAEMON Thu Apr 19 07:27:47 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKpWd-0005Zh-Bl
	for mharc-bug-bash@gnu.org; Thu, 19 Apr 2012 07:27:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51933)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrakus@redhat.com>) id 1SKpWa-0005ZR-MB
	for bug-bash@gnu.org; Thu, 19 Apr 2012 07:27:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrakus@redhat.com>) id 1SKpWT-0007ok-Sd
	for bug-bash@gnu.org; Thu, 19 Apr 2012 07:27:44 -0400
Received: from mx1.redhat.com ([209.132.183.28]:17376)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrakus@redhat.com>) id 1SKpWT-0007jk-Kv
	for bug-bash@gnu.org; Thu, 19 Apr 2012 07:27:37 -0400
Received: from int-mx01.intmail.prod.int.phx2.redhat.com
	(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3JBRYB1030647
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Thu, 19 Apr 2012 07:27:34 -0400
Received: from dhcp-25-98.brq.redhat.com (dhcp-25-98.brq.redhat.com
	[10.34.25.98])
	by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
	id q3JBRXCj007671
	for <bug-bash@gnu.org>; Thu, 19 Apr 2012 07:27:34 -0400
Message-ID: <4F8FF6A5.1060301@redhat.com>
Date: Thu, 19 Apr 2012 13:27:33 +0200
From: Roman Rakus <rrakus@redhat.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:11.0) Gecko/20120329 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: Directory completion problems
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
In-Reply-To: <CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.132.183.28
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 19 Apr 2012 11:27:45 -0000

On 04/19/2012 12:28 PM, Artur Rataj wrote:
> ~/projects/art/dev/lib$ cd ../
> .bzr/ lib/
> ~/projects/art/dev/lib$ cd ../src
> ~/projects/art/dev/src$ cd ../
> .bzr/ lib/ src/
> ~/projects/art/dev/src$ cd ../lib
> ~/projects/art/dev/lib$ cd ../
> .bzr/ lib/
Are there any symlinks?

RR


From MAILER-DAEMON Thu Apr 19 07:39:02 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKphW-0000vg-G0
	for mharc-bug-bash@gnu.org; Thu, 19 Apr 2012 07:39:02 -0400
Received: from eggs.gnu.org ([208.118.235.92]:54119)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKphR-0000vT-K8
	for bug-bash@gnu.org; Thu, 19 Apr 2012 07:39:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKphN-00036e-11
	for bug-bash@gnu.org; Thu, 19 Apr 2012 07:38:57 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:58188)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKphM-00036N-Ph
	for bug-bash@gnu.org; Thu, 19 Apr 2012 07:38:52 -0400
Received: by obbeh20 with SMTP id eh20so7100456obb.0
	for <bug-bash@gnu.org>; Thu, 19 Apr 2012 04:38:50 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=zqRq0dgJEeFbKUzHUgEp+r5T3uap7bM5qJ0gW8+RtoY=;
	b=NhC8rT6T8uosOXySiT4r8924tYCyWTy7O84M+3ddwHjuDZYAfTDLdxCuCiDUdISo72
	/mVB89hzW/2jtenXjIAGehk7KZbbX/57chLXE99YD5ed0pJmZzJ0NytXOBxSlaEq4OUi
	QendbUhOP6j0pgnkCuv6/DbsRkxHPZssdD4EpGEP52U1F+08OuUpTgX3tsFwOXdfB7LJ
	hu8dQrwkL2lHeX6ItRwSuDvEnm1eI1ErxIor+oVJWGf6uRiBW+EzUEN6V+IlTRrMGyfo
	fepeO42ZR5C/bOHNwIO1aVNAX2H7QNRyvpAOQvrYhqGCu0+q1BGgSQw0EwOHsiOyHsQF
	4rBg==
MIME-Version: 1.0
Received: by 10.182.190.6 with SMTP id gm6mr2441005obc.6.1334835530862; Thu,
	19 Apr 2012 04:38:50 -0700 (PDT)
Received: by 10.182.105.34 with HTTP; Thu, 19 Apr 2012 04:38:50 -0700 (PDT)
In-Reply-To: <4F8FF6A5.1060301@redhat.com>
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
	<4F8FF6A5.1060301@redhat.com>
Date: Thu, 19 Apr 2012 13:38:50 +0200
Message-ID: <CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
Subject: Re: Directory completion problems
From: Artur Rataj <arturrataj@gmail.com>
To: Roman Rakus <rrakus@redhat.com>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 19 Apr 2012 11:39:01 -0000

Yes, it appears that "lib" is indeed a symlink. Is it possible to treat it
as if it were "just here" with the tab completion?

From MAILER-DAEMON Thu Apr 19 08:32:54 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKqXe-0001dT-U7
	for mharc-bug-bash@gnu.org; Thu, 19 Apr 2012 08:32:54 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41493)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SKqXT-0001We-UT
	for bug-bash@gnu.org; Thu, 19 Apr 2012 08:32:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SKqXM-0005wp-7M
	for bug-bash@gnu.org; Thu, 19 Apr 2012 08:32:43 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:31594)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SKqXM-0005uj-1O
	for bug-bash@gnu.org; Thu, 19 Apr 2012 08:32:36 -0400
Received: from mpv5.cwru.edu (mpv5.tis.CWRU.Edu [129.22.105.51])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BJZ96062;
	Thu, 19 Apr 2012 08:32:33 -0400
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWF54117 (AUTH cpr);
	Thu, 19 Apr 2012 08:32:33 -0400 (EDT)
Message-ID: <4F9005E0.2090006@case.edu>
Date: Thu, 19 Apr 2012 08:32:32 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Artur Rataj <arturrataj@gmail.com>
Subject: Re: Directory completion problems
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
	<4F8FF6A5.1060301@redhat.com>
	<CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
In-Reply-To: <CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: Roman Rakus <rrakus@redhat.com>, bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 19 Apr 2012 12:32:53 -0000

On 4/19/12 7:38 AM, Artur Rataj wrote:
> Yes, it appears that "lib" is indeed a symlink. Is it possible to treat it
> as if it were "just here" with the tab completion?

By default, bash uses a logical view of the file system, in which $PWD
and pwd report the current directory using the path used to get there,
and `..' in arguments to `cd' retreats one path element in pathname.   Bash
tries to be consistent in its treatment of `..', so there are occasional
discrepancies between what bash completes to and the physical directory
tree.

If you don't want bash to do that by default, use `set -o physical'.

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


From MAILER-DAEMON Thu Apr 19 09:03:40 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKr1Q-0004W5-1k
	for mharc-bug-bash@gnu.org; Thu, 19 Apr 2012 09:03:40 -0400
Received: from eggs.gnu.org ([208.118.235.92]:46096)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKr1F-0004S9-5R
	for bug-bash@gnu.org; Thu, 19 Apr 2012 09:03:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKr18-0004jl-1h
	for bug-bash@gnu.org; Thu, 19 Apr 2012 09:03:28 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:60565)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SKr17-0004jL-Qm
	for bug-bash@gnu.org; Thu, 19 Apr 2012 09:03:21 -0400
Received: by obbeh20 with SMTP id eh20so7216925obb.0
	for <bug-bash@gnu.org>; Thu, 19 Apr 2012 06:03:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=HJlnmDCnpD9OHhYvEuG94eYuImkSo0xjFoWQuy929PU=;
	b=g5y/920qrCq1E1zv75PapG/0JKtBilgJ7PuU76KvbpE4IZOVzIwxDZdwt0CqdSt7X0
	G3YHIttUjO2jm3wM1XW2ctr5mRXJz176O0V07wSRVl1X7uPKCJrPhSqP6z01ZvA6xOpE
	mYywCNyjVkqhHKp1PzUwHhXEDBEMLiiHa8qkx5BXUynTRvYtO7I/q3GFSKz6z17kTRKN
	yALHtHZWsXWE2n5GROIL17AytwLf6HDJgYnQQpFRPkDvkqhhOLnD1lrTkItNeHPtCGX2
	lfd2e6dImbRzwrCnZzXLT1xxvqlAu/I5iIttgDxAvg5+RiViAPD7V7bmkhj9/TiJteCV
	WF7Q==
MIME-Version: 1.0
Received: by 10.182.13.8 with SMTP id d8mr2844730obc.36.1334840599865; Thu, 19
	Apr 2012 06:03:19 -0700 (PDT)
Received: by 10.182.105.34 with HTTP; Thu, 19 Apr 2012 06:03:19 -0700 (PDT)
In-Reply-To: <4F9005E0.2090006@case.edu>
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
	<4F8FF6A5.1060301@redhat.com>
	<CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
	<4F9005E0.2090006@case.edu>
Date: Thu, 19 Apr 2012 15:03:19 +0200
Message-ID: <CACO3_sA2s6ou+wfht+ssL6zNR_tPhKC-zEEVS9xm_M_1iVPWww@mail.gmail.com>
Subject: Re: Directory completion problems
From: Artur Rataj <arturrataj@gmail.com>
To: chet.ramey@case.edu
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: Roman Rakus <rrakus@redhat.com>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 19 Apr 2012 13:03:38 -0000

I want the logical view, and I think there is one by now. But there is a
file missing in the logical directory, when cd ../ is completed from a
symlink.

~/projects/art/dev$ ls -la
drwxr-xr-x  6 art art 4096 2012-02-24 16:21 .bzr
lrwxrwxrwx  1 art art   18 2012-04-16 14:48 lib -> ../../hth/dev/lib/
drwxr-xr-x  2 art art 4096 2012-02-24 16:21 src
~/projects/art/dev$ cd lib/../
.bzr/ lib/

I have made a test directory, to analyse the problem:

~/a$ ls -la
drwxr-xr-x  5 art art 4096 2012-04-19 14:50 .
drwxr-xr-x 80 art art 4096 2012-04-19 14:48 ..
drwxr-xr-x  2 art art 4096 2012-04-19 14:48 .hidden
drwxr-xr-x  2 art art 4096 2012-04-19 14:50 .java
lrwxrwxrwx  1 art art    7 2012-04-19 14:48 symlink -> ../test
~/a$ cd symlink/../

hitting Tab gives:

~/a$ cd symlink/../.java/

It seems that .hidden and .java are treated differently, just because .java
indeed exists in ../test/.., i.e. .., as opposed to .hidden.
If *either* a/.java or ../.java were removed, the completion would not
work. So, it looks as if the completion was allowed only to a logical AND
between files in the physical and in the logical directory.

I use the version 4.2.8(1)-release (x86_64-pc-linux-gnu).

From MAILER-DAEMON Thu Apr 19 12:00:20 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKtmN-0005Ri-Vz
	for mharc-bug-bash@gnu.org; Thu, 19 Apr 2012 12:00:20 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47973)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <peter.maloney@brockmann-consult.de>)
	id 1SKqRP-0000Lo-4S
	for bug-bash@gnu.org; Thu, 19 Apr 2012 08:26:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <peter.maloney@brockmann-consult.de>)
	id 1SKqRI-0003rk-LU
	for bug-bash@gnu.org; Thu, 19 Apr 2012 08:26:26 -0400
Received: from moutng.kundenserver.de ([212.227.17.10]:62053)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <peter.maloney@brockmann-consult.de>)
	id 1SKqRI-0003rP-BX
	for bug-bash@gnu.org; Thu, 19 Apr 2012 08:26:20 -0400
Received: from [10.3.0.26] ([141.4.215.32])
	by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis)
	id 0MdqQ5-1Sbi4K3Ont-00QFqs; Thu, 19 Apr 2012 14:26:18 +0200
Message-ID: <4F900469.1070605@brockmann-consult.de>
Date: Thu, 19 Apr 2012 14:26:17 +0200
From: Peter Maloney <peter.maloney@brockmann-consult.de>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:11.0) Gecko/20120312 Thunderbird/11.0
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: crash bug report, plus complaint about bashbug
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:v9NN8cTZGpi9P9MtL7GOrMChn6yzfw46SHJEwDcNSyU
	iXCNPcf4DhKoX/pTtMVAoNZaJFkD1vuhCHHM00ieGCCnZMTDVO
	B9qjslEx6WzfdfyHoBLwDoCrHFX7ae7fv/4iG4Y3dqiwLE+51y
	EljVWseIrszu/H7SLtmfdhv8ynz4RPT254L/liHcbZrf4wdutD
	ZJX1TaZoHzH9kKe2Gely3NpvK4VoXWu0JcrliIWy3+YFphkD2l
	chehXQFcRZerMn1qbCxPygYCIIlgLKl9yROlTM9NFtTZd6bTqK
	jZ8tqE0tcShfOUsysp1CqVFTDaCV5dQlQlVlYanOg9BYz7hl0P
	3iNSFygc5fpAmw8Tu+adtd6JJJbsidkPqJ4BH2AM1
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 212.227.17.10
X-Mailman-Approved-At: Thu, 19 Apr 2012 12:00:18 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 19 Apr 2012 12:26:33 -0000

Dear bash guys,

Bashbug interface was COMPLETELY useless. The emacs quit key didn't 
work. There were no instructions. It didn't even tell me it was emacs so 
I could go look it up. I had to find that out elsewhere. Eventually it 
wouldn't even let me edit, saying the buffer is read only. What the hell 
were you thinking? Why not use the EDITOR variable? That's what it's 
for! Not everyone knows how to use every editor.

So here is an email instead, with copy & paste from what I wrote in that 
thing before getting annoyed and using "kill -9".



From: peter
To: bug-bash@gnu.org
Subject: [50 character or so descriptive subject here (for reference)]

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.2 
-L/home/abuild/rpmbuild/BUILD/bash-4.2/../readline-6.2
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' -DPACKA\
GE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   
-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector 
-funwind-tables -fasynchronous-unwind-tables -g  -D_GNU\
_SOURCE -DRECYCLES_PIDS -Wall -g -std=gnu89 -Wuninitialized -Wextra 
-Wno-unprototyped-calls -Wno-switch-enum -Wno-unused-variable 
-Wno-unused-parameter -ftree-loop-linear -pipe -fprofile-us\
e
uname output: Linux peter 3.1.9-1.4-desktop #1 SMP PREEMPT Fri Jan 27 
08:55:10 UTC 2012 (efb5ff4) x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux-gnu

Bash Version: 4.2
Patch Level: 10
Release Status: release

Description:
         Running the following script crashes bash with exit code 141. The
         problem occurs on this openSuSE machine, and on FreeBSD with bash
         4.1.10, and on Ubuntu with bash 4.1.5.

Repeat-By: (2 line script, this email thing split it in 3)
         foo() { while IFS='' read -r line; do echo "$(date) $line" >>
         file.txt; done; };

         exec 2> >(foo)



From MAILER-DAEMON Thu Apr 19 15:08:53 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SKwir-0000JN-Cq
	for mharc-bug-bash@gnu.org; Thu, 19 Apr 2012 15:08:53 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55825)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SKwik-0000JH-7b
	for bug-bash@gnu.org; Thu, 19 Apr 2012 15:08:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SKwii-00062X-8d
	for bug-bash@gnu.org; Thu, 19 Apr 2012 15:08:45 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:40916)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SKwii-00062H-4M
	for bug-bash@gnu.org; Thu, 19 Apr 2012 15:08:44 -0400
Received: from mpv5.cwru.edu (mpv5.tis.CWRU.Edu [129.22.105.51])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKA37490;
	Thu, 19 Apr 2012 15:08:41 -0400
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv5.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWG21071 (AUTH cpr);
	Thu, 19 Apr 2012 15:08:41 -0400 (EDT)
Message-ID: <4F9062B9.7070209@case.edu>
Date: Thu, 19 Apr 2012 15:08:41 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Peter Maloney <peter.maloney@brockmann-consult.de>
Subject: Re: crash bug report, plus complaint about bashbug
References: <4F900469.1070605@brockmann-consult.de>
In-Reply-To: <4F900469.1070605@brockmann-consult.de>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 19 Apr 2012 19:08:52 -0000

On 4/19/12 8:26 AM, Peter Maloney wrote:
> Dear bash guys,
> 
> Bashbug interface was COMPLETELY useless. The emacs quit key didn't work.
> There were no instructions. It didn't even tell me it was emacs so I could
> go look it up. I had to find that out elsewhere. Eventually it wouldn't
> even let me edit, saying the buffer is read only. What the hell were you
> thinking? Why not use the EDITOR variable? That's what it's for! Not
> everyone knows how to use every editor.

If you were to look at the bashbug script, you would see that it does
use $EDITOR to edit the temporary file.  If that variable's not set,
it looks for $DEFEDITOR and tries to choose an intelligent default if
it doesn't find either.

> Bash Version: 4.2
> Patch Level: 10
> Release Status: release
> 
> Description:
>         Running the following script crashes bash with exit code 141. The
>         problem occurs on this openSuSE machine, and on FreeBSD with bash
>         4.1.10, and on Ubuntu with bash 4.1.5.
> 
> Repeat-By: (2 line script, this email thing split it in 3)
>         foo() { while IFS='' read -r line; do echo "$(date) $line" >>
>         file.txt; done; };
> 
>         exec 2> >(foo)

I can't reproduce the crash with bash-4.2, bash-4.1, or bash-4.0 (with
all the official patches applied to each version) on Mac OS X, RHEL 5,
Ubuntu 10, Solaris 8, or Solaris 10.  How about a stack traceback from
the crash on one of your systems?

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


From MAILER-DAEMON Fri Apr 20 04:42:04 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SL9Po-0002m0-4H
	for mharc-bug-bash@gnu.org; Fri, 20 Apr 2012 04:42:04 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45245)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SL9Ph-0002lN-2f
	for bug-bash@gnu.org; Fri, 20 Apr 2012 04:42:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SL9Pb-0005IZ-3L
	for bug-bash@gnu.org; Fri, 20 Apr 2012 04:41:56 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:54141)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SL9Pa-0005IG-ST
	for bug-bash@gnu.org; Fri, 20 Apr 2012 04:41:51 -0400
Received: by obbeh20 with SMTP id eh20so8638775obb.0
	for <bug-bash@gnu.org>; Fri, 20 Apr 2012 01:41:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:content-type; bh=hj8DjElWBFDmrHF0RjwQxBH4hb0dT+3/ydSXwrQMTmA=;
	b=UfoewiCigLmzuoZOGybtCRkm4vdLUJlysgRm5xvA7NOw1+zeWI69rSxbNUQnlU8Zo6
	PTg5XV0zjaDsvtlDX7TyNDHc8uZ+m9V1S8T4j76aTaCKPx9h6CCfFYw8YFpEMnle8MWk
	KqM/JS8Hr9H+VPJoe9EW9MXL13yyrjNJXpeAxydHgtRFt7SEtHxUhJhacPJlqgSlqssx
	3eJ6CW4R2aA0F80ibZcVIb87wtPnc73g3yhMJ9USBHVUBH4WAK7rkJ9k6KgwUjhRylfj
	sNxzYHwTOn4QNb4NELhjW+1uh15lJj5L6Wp8TkqJpC8kdccaBWwesGRh+1mfzS9aR7Hx
	AqDA==
MIME-Version: 1.0
Received: by 10.182.232.38 with SMTP id tl6mr7617728obc.16.1334911309067; Fri,
	20 Apr 2012 01:41:49 -0700 (PDT)
Received: by 10.182.105.34 with HTTP; Fri, 20 Apr 2012 01:41:49 -0700 (PDT)
In-Reply-To: <CACO3_sA2s6ou+wfht+ssL6zNR_tPhKC-zEEVS9xm_M_1iVPWww@mail.gmail.com>
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
	<4F8FF6A5.1060301@redhat.com>
	<CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
	<4F9005E0.2090006@case.edu>
	<CACO3_sA2s6ou+wfht+ssL6zNR_tPhKC-zEEVS9xm_M_1iVPWww@mail.gmail.com>
Date: Fri, 20 Apr 2012 10:41:49 +0200
Message-ID: <CACO3_sAeOHdY2XDUqJ=6Cz0n8eWCZP8W8WVPgMFx++hkeKjETg@mail.gmail.com>
Subject: Re: Directory completion problems
From: Artur Rataj <arturrataj@gmail.com>
To: bug-bash@gnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 20 Apr 2012 08:42:02 -0000

~/a$ mkdir .java
~/a$ cd symlink
~/a/symlink$ cd ../.java/
~/a/.java$
~/a/.java$ cd ../
~/a$ rm -r .java && touch .java
~/a$ cd symlink
~/a/symlink$ cd ../.java/
~/.java$

Should it really be like that?

From MAILER-DAEMON Fri Apr 20 04:49:52 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SL9XM-0004Wj-4a
	for mharc-bug-bash@gnu.org; Fri, 20 Apr 2012 04:49:52 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57651)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SL9XI-0004W4-S2
	for bug-bash@gnu.org; Fri, 20 Apr 2012 04:49:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SL9XC-0007go-OJ
	for bug-bash@gnu.org; Fri, 20 Apr 2012 04:49:48 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:49159)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SL9XC-0007bM-Do
	for bug-bash@gnu.org; Fri, 20 Apr 2012 04:49:42 -0400
Received: by obbeh20 with SMTP id eh20so8649223obb.0
	for <bug-bash@gnu.org>; Fri, 20 Apr 2012 01:49:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:content-type; bh=RqW47oUj+ZItMm5snq9288A3jwCXug2/wZlJj3P2d18=;
	b=L9LLJZtd431sOOF7iDBzrwaiy7Tf9vAiX2APDMJQ9MB0mRkymI+BBkPEjFzCcVoer5
	RUA+q0GC/ayl8RlObEHFS0K3ZMGjnx6nFgmhqth6/uIPahAGTIsIz78ki6EfgMoAZ7LK
	qMwFVKqMfa/abpDaTWmwg79Q9v+p54lLwh+KbXUEBszIXEy4q/rPmfCkMoZuxbfdogjn
	xhN925fbxt+PeEDyf2c0YTABh8Kc0Zdv9RK0SETxECq/GXAv0RuYhffogNyBxOv19vNf
	uyNsXIxTtg9uRuuVW2F9xYqBmu/+OBtOqJb/sqpUNwR8Uju8rYaF8qq1KIgH8Bvsi5T6
	pEKA==
MIME-Version: 1.0
Received: by 10.182.190.6 with SMTP id gm6mr7542000obc.6.1334911780612; Fri,
	20 Apr 2012 01:49:40 -0700 (PDT)
Received: by 10.182.105.34 with HTTP; Fri, 20 Apr 2012 01:49:40 -0700 (PDT)
In-Reply-To: <CACO3_sAeOHdY2XDUqJ=6Cz0n8eWCZP8W8WVPgMFx++hkeKjETg@mail.gmail.com>
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
	<4F8FF6A5.1060301@redhat.com>
	<CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
	<4F9005E0.2090006@case.edu>
	<CACO3_sA2s6ou+wfht+ssL6zNR_tPhKC-zEEVS9xm_M_1iVPWww@mail.gmail.com>
	<CACO3_sAeOHdY2XDUqJ=6Cz0n8eWCZP8W8WVPgMFx++hkeKjETg@mail.gmail.com>
Date: Fri, 20 Apr 2012 10:49:40 +0200
Message-ID: <CACO3_sCfYyqMVu4kOaEWD32JYyRiKiv7Y2mJii1ME0xQjLNt7g@mail.gmail.com>
Subject: Re: Directory completion problems
From: Artur Rataj <arturrataj@gmail.com>
To: bug-bash@gnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 20 Apr 2012 08:49:50 -0000

...continuation:

~/.java$ cd ../a
~/a$ rm -r .java
~/a$ cd symlink
~/a/symlink$ cd ../ [now completion does not work]
~/a/symlink$ cd ../.java/
~/.java$

So, cd looks into the logical directory, and if the lookup fails, then it
looks into the physical directory. The cd completion from a symlink,
though, needs a file of a given name in both directories, and it does not
matter if the one in the logical directory is even a directory.

From MAILER-DAEMON Fri Apr 20 10:38:43 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLEyx-0004HK-Ss
	for mharc-bug-bash@gnu.org; Fri, 20 Apr 2012 10:38:43 -0400
Received: from eggs.gnu.org ([208.118.235.92]:36411)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SLEyu-00049d-7p
	for bug-bash@gnu.org; Fri, 20 Apr 2012 10:38:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SLEyj-000219-F0
	for bug-bash@gnu.org; Fri, 20 Apr 2012 10:38:39 -0400
Received: from saturn.syslang.net ([207.172.210.41]:34270)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <steveo@syslang.net>) id 1SLEyj-0001zz-7D
	for bug-bash@gnu.org; Fri, 20 Apr 2012 10:38:29 -0400
Received: from [IPv6:::1] (localhost [127.0.0.1])
	by saturn.syslang.net (8.14.5/8.14.5) with ESMTP id q3KEcPEm008301
	for <bug-bash@gnu.org>; Fri, 20 Apr 2012 10:38:25 -0400
Message-ID: <4F9174E0.3020201@syslang.net>
Date: Fri, 20 Apr 2012 10:38:24 -0400
From: "Steven W. Orr" <steveo@syslang.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
	rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: I have a bash style question.  Feedback request.
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 207.172.210.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 20 Apr 2012 14:38:41 -0000

I manage a hefty collection of bash scripts. Sometimes, I make heavy use of 
pushd and popd. When problems come up, the directory stack can make debugging 
more complicated than I'd like. One thing I did to get better control over 
things was to write a dstack module that provides pushd and popd functions.

The dstack module gives me simple flags that I can set through an environment 
variable that allow me to dump the stack either before or after a pushd or a 
popd, and to control their stdout and stderr. The default is that they both 
redirect to /dev/null and that all calls are checked when they return. e.g.
push somewhere || die 'Failed to pushd to somewhere'

(I hope people are still reading...)

Recently I discovered context managers in python and I had already implemented 
a directory stack module there. I added a context manager so that instead of 
saying

ds.pushd(foo)
do_a_bunch_of_stuff
ds.popd()

I can now say

with ds(foo):
     do_a_bunch_of_stuff
# The popd is now automatic.

Back to bash, I see that things like code readability are impacted by the 
frequent use of pushd / popd. There could be lots (more than a screen full) 
between the pair, and forgetting to put the popd in or losing track of where 
you are can make things more complicateder. So, I thought: How can I get the 
benefit of a context manager in bash? It came to mind that simple curly braces 
might help.

So now I'm thinking of two possible scenarios.

Here's S1:

pushd somewhere
{
     do_a_bunch_of_stuff
}
popd

And S2 would be:

{
     pushd somewhere
     do_a_bunch_of_stuff
     popd
}

I'd like to get feedback. Some choices for reasonable feedback might be:
a. It doesn't matter and I'm clearly overthinking this. Just pick one.
b. I like S[12] and anyone who disagrees will be met with a jihad.
c. Here's a better solution that I didn't think of.

If you got this far, have feedback and are in the Boston area, there's a beer 
with your name on it.

TIA :-)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


From MAILER-DAEMON Fri Apr 20 11:10:16 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLFTU-0005ZP-4N
	for mharc-bug-bash@gnu.org; Fri, 20 Apr 2012 11:10:16 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52299)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SLFT7-0005Kb-7A
	for bug-bash@gnu.org; Fri, 20 Apr 2012 11:10:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SLFSj-0005eE-53
	for bug-bash@gnu.org; Fri, 20 Apr 2012 11:09:52 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:42384
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SLFSi-0005EH-WD
	for bug-bash@gnu.org; Fri, 20 Apr 2012 11:09:29 -0400
Received: (qmail 32485 invoked from network); 20 Apr 2012 15:08:57 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Fri, 20 Apr 2012 11:08:57 -0400
Received: (qmail 24822 invoked by uid 563); 20 Apr 2012 15:08:54 -0000
Date: Fri, 20 Apr 2012 11:08:54 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: "Steven W. Orr" <steveo@syslang.net>
Subject: Re: I have a bash style question.  Feedback request.
Message-ID: <20120420150854.GV22241@eeg.ccf.org>
References: <4F9174E0.3020201@syslang.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F9174E0.3020201@syslang.net>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 20 Apr 2012 15:10:14 -0000

On Fri, Apr 20, 2012 at 10:38:24AM -0400, Steven W. Orr wrote:
> (I hope people are still reading...)

You'd get a better response on the help-bash mailing list, since you
are not reporting a bug.


From MAILER-DAEMON Fri Apr 20 11:13:44 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLFWq-0006gA-RD
	for mharc-bug-bash@gnu.org; Fri, 20 Apr 2012 11:13:44 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59091)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SLFWn-0006fW-Ok
	for bug-bash@gnu.org; Fri, 20 Apr 2012 11:13:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SLFWk-0007iX-9m
	for bug-bash@gnu.org; Fri, 20 Apr 2012 11:13:41 -0400
Received: from fmmailgate04.web.de ([217.72.192.242]:47697)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SLFWk-0007i9-0o
	for bug-bash@gnu.org; Fri, 20 Apr 2012 11:13:38 -0400
Received: from moweb001.kundenserver.de (moweb001.kundenserver.de
	[172.19.20.114])
	by fmmailgate04.web.de (Postfix) with ESMTP id E5A8D76641CA
	for <bug-bash@gnu.org>; Fri, 20 Apr 2012 17:13:35 +0200 (CEST)
Received: from [192.168.178.49] ([77.13.121.216]) by smtp.web.de (mrweb002)
	with ESMTPA (Nemesis) id 0MLgCx-1SLWdo06OR-000r6K;
	Fri, 20 Apr 2012 17:13:35 +0200
Message-ID: <4F917D1A.6070107@web.de>
Date: Fri, 20 Apr 2012 17:13:30 +0200
From: dethrophes <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: "Steven W. Orr" <steveo@syslang.net>
Subject: Re: I have a bash style question.  Feedback request.
References: <4F9174E0.3020201@syslang.net>
In-Reply-To: <4F9174E0.3020201@syslang.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:EfE2KyGIESgqrWIqtAYRbQ6CnCCUejuqC81VxATNJoY
	7+t9vLYKhKaOosuEOc304TVDoCO8GpPK6pzd8W7EgWYWYgdblw
	fdJrhRI2WZ0fIxn645IOYbfCyVNX2+tKvkNaV5VBTwORjAjRb8
	4CYD2W3lORhiFkGjK/gCl5NNxpyZ/2QF2urekzgBI7FQR7SEmj
	himaqX5d/LRJzhAMGRS2g==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.242
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 20 Apr 2012 15:13:43 -0000

Am 20.04.2012 16:38, schrieb Steven W. Orr:
> I manage a hefty collection of bash scripts. Sometimes, I make heavy 
> use of pushd and popd. When problems come up, the directory stack can 
> make debugging more complicated than I'd like. One thing I did to get 
> better control over things was to write a dstack module that provides 
> pushd and popd functions.
>
> The dstack module gives me simple flags that I can set through an 
> environment variable that allow me to dump the stack either before or 
> after a pushd or a popd, and to control their stdout and stderr. The 
> default is that they both redirect to /dev/null and that all calls are 
> checked when they return. e.g.
> push somewhere || die 'Failed to pushd to somewhere'
>
> (I hope people are still reading...)
>
> Recently I discovered context managers in python and I had already 
> implemented a directory stack module there. I added a context manager 
> so that instead of saying
>
> ds.pushd(foo)
> do_a_bunch_of_stuff
> ds.popd()
>
> I can now say
>
> with ds(foo):
>     do_a_bunch_of_stuff
> # The popd is now automatic.
>
> Back to bash, I see that things like code readability are impacted by 
> the frequent use of pushd / popd. There could be lots (more than a 
> screen full) between the pair, and forgetting to put the popd in or 
> losing track of where you are can make things more complicateder. So, 
> I thought: How can I get the benefit of a context manager in bash? It 
> came to mind that simple curly braces might help.
>
> So now I'm thinking of two possible scenarios.
>
> Here's S1:
>
> pushd somewhere
> {
>     do_a_bunch_of_stuff
> }
> popd
>
> And S2 would be:
>
> {
>     pushd somewhere
>     do_a_bunch_of_stuff
>     popd
> }
>
> I'd like to get feedback. Some choices for reasonable feedback might be:
> a. It doesn't matter and I'm clearly overthinking this. Just pick one.
> b. I like S[12] and anyone who disagrees will be met with a jihad.
> c. Here's a better solution that I didn't think of.
>
> If you got this far, have feedback and are in the Boston area, there's 
> a beer with your name on it.
>
> TIA :-)
>
Tried something like this?


function RunCmdDir {
     pushd "${1}" || return $?
     "${@:2}"
     popd
}
RunCmdDir "Work/Dir" do_a_bunch_of_stuff

ok so you'd have to put the in between code in a function(if you want 
more than 1 instruction) but that would probably help code readability 
anyway.


you could use a sub shell, if do_a_bunch_of_stuff doesn't need to modify 
the global context.
(
     cd "Path"
     do_a_bunch_of_stuff
)






From MAILER-DAEMON Fri Apr 20 11:34:11 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLFqd-0002tj-Kk
	for mharc-bug-bash@gnu.org; Fri, 20 Apr 2012 11:34:11 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51436)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jfredett@gmail.com>) id 1SLFqa-0002n1-Ns
	for bug-bash@gnu.org; Fri, 20 Apr 2012 11:34:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jfredett@gmail.com>) id 1SLFqV-00072z-Fd
	for bug-bash@gnu.org; Fri, 20 Apr 2012 11:34:08 -0400
Received: from mail-iy0-f169.google.com ([209.85.210.169]:32913)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jfredett@gmail.com>) id 1SLFqV-00072h-6f
	for bug-bash@gnu.org; Fri, 20 Apr 2012 11:34:03 -0400
Received: by iajr24 with SMTP id r24so16953553iaj.0
	for <bug-bash@gnu.org>; Fri, 20 Apr 2012 08:34:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:cc
	:content-type; bh=SeXn4Gh1MHyQp/mYND/cssnsL2UTyGuGJmk5rNEmi3s=;
	b=J0UrU/IrPBQzCHa3OkEfCMX2tyxllCryDOx+Gzw6LWyBYIuBa3qiSanfFw8VF5Ymjz
	C6VH7DL8SDTxxpyQivuVJAIQWQna8M+meDxu7OOOsEsoWT8viYSaLcBqPQMT719c3dmG
	KgWjtVDGDft6Q+5/wC9kzyXIfdaFXYsnwFYBYKID48qTYE9VdvEzMCue8x3r7gwSZkkE
	CHG4/UEe1ZYgrZetmkJzQUhNcTp1qsKKJwtLN9Xsr4Hs+MG6qXHhMzaK2fNh823CE1kc
	8qJyT9zYEtakA/NNA4jWi4F2pP+ZHagBBA29vlUuuQZbOdga7nyX0LcturYiSzHJkSu7
	ZkzA==
MIME-Version: 1.0
Received: by 10.50.15.227 with SMTP id a3mt8653029igd.15.1334936040391; Fri,
	20 Apr 2012 08:34:00 -0700 (PDT)
Received: by 10.64.147.74 with HTTP; Fri, 20 Apr 2012 08:34:00 -0700 (PDT)
In-Reply-To: <4F917D1A.6070107@web.de>
References: <4F9174E0.3020201@syslang.net>
	<4F917D1A.6070107@web.de>
Date: Fri, 20 Apr 2012 11:34:00 -0400
Message-ID: <CAMZJe54N7zPvMFkWmDQuzKD7BeQsckYP0Uyb_vwEAzmcW5gXEA@mail.gmail.com>
Subject: Re: I have a bash style question. Feedback request.
From: Joseph Fredette <jfredett@gmail.com>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.210.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: "Steven W. Orr" <steveo@syslang.net>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 20 Apr 2012 15:34:10 -0000

You may be interested in my
version<https://github.com/jfredett/scripts/blob/master/utilities/dirstack.sh>[1]
of a directory stack module. It alters the API a bit from pushd and popd (I
think for the better). And makes use of the subshell techique mentioned by
dethrophes.



[1]https://github.com/jfredett/scripts/blob/master/utilities/dirstack.sh

On Fri, Apr 20, 2012 at 11:13 AM, dethrophes <dethrophes@web.de> wrote:

> Am 20.04.2012 16:38, schrieb Steven W. Orr:
>
>  I manage a hefty collection of bash scripts. Sometimes, I make heavy use
>> of pushd and popd. When problems come up, the directory stack can make
>> debugging more complicated than I'd like. One thing I did to get better
>> control over things was to write a dstack module that provides pushd and
>> popd functions.
>>
>> The dstack module gives me simple flags that I can set through an
>> environment variable that allow me to dump the stack either before or after
>> a pushd or a popd, and to control their stdout and stderr. The default is
>> that they both redirect to /dev/null and that all calls are checked when
>> they return. e.g.
>> push somewhere || die 'Failed to pushd to somewhere'
>>
>> (I hope people are still reading...)
>>
>> Recently I discovered context managers in python and I had already
>> implemented a directory stack module there. I added a context manager so
>> that instead of saying
>>
>> ds.pushd(foo)
>> do_a_bunch_of_stuff
>> ds.popd()
>>
>> I can now say
>>
>> with ds(foo):
>>    do_a_bunch_of_stuff
>> # The popd is now automatic.
>>
>> Back to bash, I see that things like code readability are impacted by the
>> frequent use of pushd / popd. There could be lots (more than a screen full)
>> between the pair, and forgetting to put the popd in or losing track of
>> where you are can make things more complicateder. So, I thought: How can I
>> get the benefit of a context manager in bash? It came to mind that simple
>> curly braces might help.
>>
>> So now I'm thinking of two possible scenarios.
>>
>> Here's S1:
>>
>> pushd somewhere
>> {
>>    do_a_bunch_of_stuff
>> }
>> popd
>>
>> And S2 would be:
>>
>> {
>>    pushd somewhere
>>    do_a_bunch_of_stuff
>>    popd
>> }
>>
>> I'd like to get feedback. Some choices for reasonable feedback might be:
>> a. It doesn't matter and I'm clearly overthinking this. Just pick one.
>> b. I like S[12] and anyone who disagrees will be met with a jihad.
>> c. Here's a better solution that I didn't think of.
>>
>> If you got this far, have feedback and are in the Boston area, there's a
>> beer with your name on it.
>>
>> TIA :-)
>>
>>  Tried something like this?
>
>
> function RunCmdDir {
>    pushd "${1}" || return $?
>    "${@:2}"
>    popd
> }
> RunCmdDir "Work/Dir" do_a_bunch_of_stuff
>
> ok so you'd have to put the in between code in a function(if you want more
> than 1 instruction) but that would probably help code readability anyway.
>
>
> you could use a sub shell, if do_a_bunch_of_stuff doesn't need to modify
> the global context.
> (
>    cd "Path"
>    do_a_bunch_of_stuff
> )
>
>
>
>
>
>

From MAILER-DAEMON Fri Apr 20 15:18:56 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLJM8-0007uV-Ac
	for mharc-bug-bash@gnu.org; Fri, 20 Apr 2012 15:18:56 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39994)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SLJM5-0007tY-Vj
	for bug-bash@gnu.org; Fri, 20 Apr 2012 15:18:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SLJM3-0006MU-Px
	for bug-bash@gnu.org; Fri, 20 Apr 2012 15:18:53 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:32376)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SLJM3-0006MF-LZ
	for bug-bash@gnu.org; Fri, 20 Apr 2012 15:18:51 -0400
Received: from mpv6.cwru.edu (mpv6.tis.CWRU.Edu [129.22.104.221])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKB22312;
	Fri, 20 Apr 2012 15:18:49 -0400
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AVX47845 (AUTH cpr);
	Fri, 20 Apr 2012 15:18:49 -0400 (EDT)
Message-ID: <4F91B698.6030805@case.edu>
Date: Fri, 20 Apr 2012 15:18:48 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Victor Engmark <victor.engmark@gmail.com>
Subject: Re: Why are parameters to Bash's builtin optional?
References: <698142.359.1334755137092.JavaMail.geo-discussion-forums@vbab2>
	<mailman.150.1334759810.751.bug-bash@gnu.org>
	<25668998.1425.1334762821795.JavaMail.geo-discussion-forums@vbbdy9>
In-Reply-To: <25668998.1425.1334762821795.JavaMail.geo-discussion-forums@vbbdy9>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: gnu.bash.bug@googlegroups.com, bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 20 Apr 2012 19:18:55 -0000

On 4/18/12 11:27 AM, Victor Engmark wrote:

>>  I can see printing a list of builtins, though `enable' already does that.
> 
> I guess the difference would be that `builtin` prints *all* builtins, and *never* modifies their state.

What difference does that make?  enable -a prints all builtins, and does
not modify their state unless told to do so.

Why not try out something like the following and see what you
think:

builtin()
{
	case $# in
	0)	enable -a ; return 0 ;;
	*)	command builtin "$@" ;;
	esac
}

That might be enough to make it work for you.

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


From MAILER-DAEMON Sat Apr 21 05:56:40 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLX3Y-0000ku-RS
	for mharc-bug-bash@gnu.org; Sat, 21 Apr 2012 05:56:40 -0400
Received: from eggs.gnu.org ([208.118.235.92]:46221)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <victor.engmark@gmail.com>) id 1SLX3T-0000kR-U4
	for bug-bash@gnu.org; Sat, 21 Apr 2012 05:56:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <victor.engmark@gmail.com>) id 1SLX3P-0003ft-LQ
	for bug-bash@gnu.org; Sat, 21 Apr 2012 05:56:35 -0400
Received: from mail-ee0-f41.google.com ([74.125.83.41]:33098)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <victor.engmark@gmail.com>) id 1SLX3P-0003fn-D2
	for bug-bash@gnu.org; Sat, 21 Apr 2012 05:56:31 -0400
Received: by eeke53 with SMTP id e53so2828059eek.0
	for <bug-bash@gnu.org>; Sat, 21 Apr 2012 02:56:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	bh=zuZ19zu7ow/yi70gH3M5nOxmKT2AqQb4wAjR4TVc7wM=;
	b=ryKKG6hngptROhr4xvQrDSrJPqjIBu0Wra81amh43UKTPlNV9J6AJPSx6Js+WooTyK
	BmAuW84cGAMo4z8QwetjzFRRtAfQf6MD6e4IRpZidTMveY2T14BmDias2A7Ttr4BaaS/
	GjzWMmMghDMLJDuoXEk05RB+JOUIcQqK0RmBDcksWtGf2NENyg8hQ2ED/AlB3pSWFy14
	SK4cKUE3VccWgJ7Y0cu/oJ/iwd3PffZCoFMk8vnuw9kYSzo7FjxO4DUJ4XX9mXq4k6lR
	Esd8jF+AT9IBUmLWMzFsr+HcVNiep6V85uhU63bN17O2WXLRTLvLVgyrduIsNyxO+zep
	6tTg==
MIME-Version: 1.0
Received: by 10.213.3.153 with SMTP id 25mr790871ebn.86.1335002188515; Sat, 21
	Apr 2012 02:56:28 -0700 (PDT)
Received: by 10.213.3.136 with HTTP; Sat, 21 Apr 2012 02:56:28 -0700 (PDT)
In-Reply-To: <4F91B698.6030805@case.edu>
References: <698142.359.1334755137092.JavaMail.geo-discussion-forums@vbab2>
	<mailman.150.1334759810.751.bug-bash@gnu.org>
	<25668998.1425.1334762821795.JavaMail.geo-discussion-forums@vbbdy9>
	<4F91B698.6030805@case.edu>
Date: Sat, 21 Apr 2012 11:56:28 +0200
Message-ID: <CAA5Ydx_eXOD2OE9x2E9pZncr96g97OHvfhHXmZGFSRUBikOQXg@mail.gmail.com>
Subject: Re: Why are parameters to Bash's builtin optional?
From: Victor Engmark <victor.engmark@gmail.com>
To: chet.ramey@case.edu
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: 74.125.83.41
Cc: gnu.bash.bug@googlegroups.com, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 21 Apr 2012 09:56:39 -0000

On Fri, Apr 20, 2012 at 9:18 PM, Chet Ramey <chet.ramey@case.edu> wrote:
> On 4/18/12 11:27 AM, Victor Engmark wrote:
>>> =C2=A0I can see printing a list of builtins, though `enable' already do=
es that.
>>
>> I guess the difference would be that `builtin` prints *all* builtins, an=
d *never* modifies their state.
>
> What difference does that make? =C2=A0enable -a prints all builtins, and =
does
> not modify their state unless told to do so.

Isn't that rather weird semantics? I'd expect `enable -a` to enable
all builtins and print nothing, and `enable -l` to list all builtins,
like the semantics of most *nix tools.

Also, I suppose `builtin`, if it printed builtins, would print *just*
the names of the builtins (unlike enable), so you wouldn't have to
parse the output even a little bit.

> Why not try out something like the following and see what you
> think:
>
> builtin()
> {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0case $# in
> =C2=A0 =C2=A0 =C2=A0 =C2=A00) =C2=A0 =C2=A0 =C2=A0enable -a ; return 0 ;;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0*) =C2=A0 =C2=A0 =C2=A0command builtin "$@" ;;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0esac
> }
>
> That might be enough to make it work for you.

Oh, this wasn't about any non-working script code, but rather to point
out that the behavior of `builtin` is not as expected, and `help
builtin` doesn't mention what it does when no parameters are provided.
I simply propose that the `shell-builtin` argument should be
mandatory, to avoid confusion.

Cheers,
V


From MAILER-DAEMON Sat Apr 21 12:42:33 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLdOL-0001W8-Po
	for mharc-bug-bash@gnu.org; Sat, 21 Apr 2012 12:42:33 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57108)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SLdOF-0001W1-TF
	for bug-bash@gnu.org; Sat, 21 Apr 2012 12:42:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SLdOB-0002MG-Bt
	for bug-bash@gnu.org; Sat, 21 Apr 2012 12:42:27 -0400
Received: from smtp.gentoo.org ([140.211.166.183]:58823)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SLdOB-0002M8-60
	for bug-bash@gnu.org; Sat, 21 Apr 2012 12:42:23 -0400
Received: from vapier.localnet (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id 478B81B408B
	for <bug-bash@gnu.org>; Sat, 21 Apr 2012 16:42:19 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: bug-bash@gnu.org
Subject: string replace with multibyte chars and extglob fails with bash-4.2
Date: Sat, 21 Apr 2012 12:43:29 -0400
User-Agent: KMail/1.13.7 (Linux/3.4.0-rc1; KDE/4.6.5; x86_64; ; )
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart4687859.0Reps9nyPm";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
Message-Id: <201204211243.30163.vapier@gentoo.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 140.211.166.183
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 21 Apr 2012 16:42:32 -0000

--nextPart4687859.0Reps9nyPm
Content-Type: Text/Plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

first set your locale to something unicode based:
export LC_ALL=3Den_US.UTF-8

then try the simple script (from Ulrich M=FCller):
$ cat test.sh
shopt -s extglob
text=3D"aaa=E4=F6=FC"
echo "${text} ${text//?aa} ${text//\aaa}"

with bash-4.1_p2, i get:
aaa=E4=F6=FC =E4=F6=FC =E4=F6=FC

but with bash-4.2_p8 ... 4.2_p24 (just what i have locally):
aaa=E4=F6=FC aaa=E4=F6=FC aaa=E4=F6=FC

seems like a bug to me
=2Dmike

--nextPart4687859.0Reps9nyPm
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJPkuOyAAoJEEFjO5/oN/WBN0YP/jA7OTP1H7ayt4U2zzkWcDpW
oMZ1+pUBOv3wQzveIlkF3JatIw6zxgXpS0Nf8fSos3r/TJbXRTv1iTL/otG4zlNy
3QFNPi7QhJk25hH5YJRTka/Bs0b/Tn4v0lJwL2Q8XHUindvPv9+Z2yL+myj/T0wP
6Sv4/av7pxPOc0cFDqGrWO1pCPZlGyr7Tulw5KfgffEtX40rnE6vl1XeV5FFqaO1
yqNPZYQwgpEOf+CCXh1WUaWzTb2KW+WQzQMLoY5bZaWnYlB59DNnoltBVK53r6WP
wn2cIXqkmSmKMpRZ28EzyQP8XT86obsBRVaa2AA/xK76LzGw392Ad69TLDAi5jfE
nqpCtXoolJiKhj2TG3LYx3dVlzodbsCHpwaLOKuJhPutxvodc7Do+Ogf6utIvknB
nFJzBJNICSM5vvf2ui+Mgvg6uTuhTJcx0PYZgjQpW//4Y7W8F0qAdpZ3VJ73Xqn0
v2T2MCVJtclNglP1D9qCAk3sipARLVqXn9aU2PCO3+V+6Xc5OepJvSKeLu7gIERK
/UBm3QRKPac1EEjguskJoP4dOVHid+Uc0Y352vunGrIBWKaVj5BLg6JkZT4rzVDt
b1MNJvtsmBw2t0ZLGpRXVnWYmg1egT5HKslO8fM0/gGZkGjikk6zb/8smLQz58YX
o0IPej/KsgNqVyPmBa7X
=+l70
-----END PGP SIGNATURE-----

--nextPart4687859.0Reps9nyPm--


From MAILER-DAEMON Sat Apr 21 14:15:03 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLepr-0002sP-5B
	for mharc-bug-bash@gnu.org; Sat, 21 Apr 2012 14:15:03 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58493)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SLepl-0002s7-KM
	for bug-bash@gnu.org; Sat, 21 Apr 2012 14:15:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SLepg-0005t4-60
	for bug-bash@gnu.org; Sat, 21 Apr 2012 14:14:57 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:2453)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SLepf-0005qz-Qi
	for bug-bash@gnu.org; Sat, 21 Apr 2012 14:14:52 -0400
Received: from mpv8.case.edu (mpv8.tis.CWRU.Edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKB61417;
	Sat, 21 Apr 2012 14:14:50 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TQI92530 (AUTH cpr);
	Sat, 21 Apr 2012 14:14:50 -0400 (EDT)
Message-ID: <4F92F918.5080801@case.edu>
Date: Sat, 21 Apr 2012 14:14:48 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Mike Frysinger <vapier@gentoo.org>
Subject: Re: string replace with multibyte chars and extglob fails with
	bash-4.2
References: <201204211243.30163.vapier@gentoo.org>
In-Reply-To: <201204211243.30163.vapier@gentoo.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 21 Apr 2012 18:15:02 -0000

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

On 4/21/12 12:43 PM, Mike Frysinger wrote:
> first set your locale to something unicode based:
> export LC_ALL=en_US.UTF-8
> 
> then try the simple script (from Ulrich Müller):
> $ cat test.sh
> shopt -s extglob
> text="aaaäöü"
> echo "${text} ${text//?aa} ${text//\aaa}"
> 
> with bash-4.1_p2, i get:
> aaaäöü äöü äöü
> 
> but with bash-4.2_p8 ... 4.2_p24 (just what i have locally):
> aaaäöü aaaäöü aaaäöü
> 
> seems like a bug to me

Thanks for the report.  It definitely looks like the extglob triggers the
bad behavior.  I will take a look at it.

Chet


- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+S+RAACgkQu1hp8GTqdKv7FQCeLUnNQx5C45rXfIi561B6JBZp
iLAAn3RpMtoii0i5Q8SinYYFeQ0GS48q
=wUJI
-----END PGP SIGNATURE-----


From MAILER-DAEMON Sat Apr 21 15:28:11 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLfyd-0007p3-JU
	for mharc-bug-bash@gnu.org; Sat, 21 Apr 2012 15:28:11 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39134)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SLfyX-0007nm-Un
	for bug-bash@gnu.org; Sat, 21 Apr 2012 15:28:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SLfyQ-0003xG-Hy
	for bug-bash@gnu.org; Sat, 21 Apr 2012 15:28:05 -0400
Received: from mail-out.m-online.net ([212.18.0.9]:47112)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SLfyQ-0003x3-B6
	for bug-bash@gnu.org; Sat, 21 Apr 2012 15:27:58 -0400
Received: from frontend1.mail.m-online.net (unknown [192.168.8.180])
	by mail-out.m-online.net (Postfix) with ESMTP id 3VZkVN2zCKz4LDdW;
	Sat, 21 Apr 2012 21:27:56 +0200 (CEST)
Received: from igel.home (ppp-88-217-127-121.dynamic.mnet-online.de
	[88.217.127.121])
	by mail.mnet-online.de (Postfix) with ESMTPA id 3VZkVN0vHhz4KK49;
	Sat, 21 Apr 2012 21:27:56 +0200 (CEST)
Received: by igel.home (Postfix, from userid 501)
	id CB5E8CA29F; Sat, 21 Apr 2012 21:27:55 +0200 (CEST)
From: Andreas Schwab <schwab@linux-m68k.org>
To: Mike Frysinger <vapier@gentoo.org>
Subject: Re: string replace with multibyte chars and extglob fails with
	bash-4.2
References: <201204211243.30163.vapier@gentoo.org>
X-Yow: They collapsed....  like nuns in the street... they had no teen appeal!
Date: Sat, 21 Apr 2012 21:27:55 +0200
In-Reply-To: <201204211243.30163.vapier@gentoo.org> (Mike Frysinger's message
	of "Sat, 21 Apr 2012 12:43:29 -0400")
Message-ID: <m2zka4evgk.fsf@igel.home>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	4)
X-Received-From: 212.18.0.9
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 21 Apr 2012 19:28:10 -0000

Mike Frysinger <vapier@gentoo.org> writes:

> first set your locale to something unicode based:
> export LC_ALL=en_US.UTF-8
>
> then try the simple script (from Ulrich MĂĽller):
> $ cat test.sh
> shopt -s extglob
> text="aaaĂ¤Ă¶ĂĽ"
> echo "${text} ${text//?aa} ${text//\aaa}"
>
> with bash-4.1_p2, i get:
> aaaĂ¤Ă¶ĂĽ Ă¤Ă¶ĂĽ Ă¤Ă¶ĂĽ
>
> but with bash-4.2_p8 ... 4.2_p24 (just what i have locally):
> aaaĂ¤Ă¶ĂĽ aaaĂ¤Ă¶ĂĽ aaaĂ¤Ă¶ĂĽ

diff --git a/subst.c b/subst.c
index 9feaa9c..ebd5138 100644
--- a/subst.c
+++ b/subst.c
@@ -4161,7 +4161,7 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
   simple = (wpat[0] != L'\\' && wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'[');
 #if defined (EXTENDED_GLOB)
   if (extended_glob)
-    simple |= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
+    simple &= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
 #endif
 
   /* If the pattern doesn't match anywhere in the string, go ahead and

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


From MAILER-DAEMON Sun Apr 22 11:48:02 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLz18-00005p-Bl
	for mharc-bug-bash@gnu.org; Sun, 22 Apr 2012 11:48:02 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44539)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jcarreras@krenel.org>) id 1SLz16-00005G-2o
	for bug-bash@gnu.org; Sun, 22 Apr 2012 11:48:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jcarreras@krenel.org>) id 1SLz13-0007Qp-Vl
	for bug-bash@gnu.org; Sun, 22 Apr 2012 11:47:59 -0400
Received: from mail-ee0-f41.google.com ([74.125.83.41]:37325)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jcarreras@krenel.org>) id 1SLz13-0007Pl-PX
	for bug-bash@gnu.org; Sun, 22 Apr 2012 11:47:57 -0400
Received: by eeke53 with SMTP id e53so2982642eek.0
	for <bug-bash@gnu.org>; Sun, 22 Apr 2012 08:47:55 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=mime-version:x-originating-ip:in-reply-to:references:date
	:message-id:subject:from:to:content-type:content-transfer-encoding
	:x-gm-message-state;
	bh=3NiVa5kaCXZFJENwD3VvEX9w5VEvurwS3fMkeKQLJwE=;
	b=JmTufwbF4TNvEe+fxb5SpVNxZMdvoj4sm78YeHbRh3oZpFWQ2nUT/HswzZ3qYXssr1
	KJn9Dq5vFCy4WOtnoVHvlFcaBaoMYA3Lfidk0aE32jlDG0E6JiGLqg0fZjjphW4j+gy6
	WCplZAwzdNDB21xrEVHSb/SL4GEpByg2SUDHFP5De0lu2uB4dbdQHmxBjh1BtgRVYm+z
	OBkkk3kny4ozlwhfUbStS29JIBUWY9l7FYkGxQQp1KIkFrnyOnZjjOxhO49Ay7R0C/t8
	RviRbztsPaI5eadaKE3SfRxr/hs0XfzVyJanKUwzPDsAYU3ZNqIiakMYW8CPFxvIVi2B
	VLCA==
MIME-Version: 1.0
Received: by 10.213.9.15 with SMTP id j15mr1064011ebj.17.1335109675034; Sun,
	22 Apr 2012 08:47:55 -0700 (PDT)
Received: by 10.213.22.70 with HTTP; Sun, 22 Apr 2012 08:47:54 -0700 (PDT)
X-Originating-IP: [77.227.37.129]
In-Reply-To: <CAKNFPOa-JB0g4z82t+xuuMqSVciosVZzgUZhvNV_PEY8RzjRwQ@mail.gmail.com>
References: <CAKNFPOa-JB0g4z82t+xuuMqSVciosVZzgUZhvNV_PEY8RzjRwQ@mail.gmail.com>
Date: Sun, 22 Apr 2012 17:47:54 +0200
Message-ID: <CAKNFPOa6h4gCCJ5_3qnqYJLUqaicBVbJaA6OCG9SgUKeDG7caw@mail.gmail.com>
Subject: Error in bash manual?
From: Jan Carreras Prat <jcarreras@krenel.org>
To: bug-bash@gnu.org
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Gm-Message-State: ALoCoQlrVRbOLMJCikSxOcARD56T4YdNySebZ3kBNGcmwdlXXbwypadW2f3OLghlBeMdGDTGVzVT
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 74.125.83.41
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 22 Apr 2012 15:48:01 -0000

>From my point of view in the section REDIRECTION of the man manual there
is something technically incorrect:

/dev/tcp/host/port
=A0=A0=A0 If host is a valid hostname or Internet address, and port
=A0=A0=A0 is=A0 an integer port number or service name, bash attempts
=A0=A0=A0 to open a TCP connection to the corresponding socket
/dev/udp/host/port
=A0=A0=A0 If host is a valid hostname or Internet address, and port
=A0=A0=A0 is=A0 an integer port number or service name, bash attempts
=A0=A0=A0 to open a UDP connection to the corresponding socket.


The sentence I disagree with is:
=A0=A0=A0 "bash attempts to open a UDP connection"

The term 'UDP connection' is incorrect since in UDP there aren't any connec=
tions
The definition of UDP (man udp) is:
=A0=A0=A0 This=A0 is=A0 an=A0 implementation=A0 of=A0 the User Datagram Pro=
tocol described
=A0=A0=A0 in RFC 768. It implements a *connectionless*, unreliable datagram=
 packet
=A0=A0=A0 service.=A0 Packets may be reordered or duplicated before they ar=
rive.

"Conectionless" is the key.=A0 If we search the term "connection" in RFC768=
 any
results will appear.=A0 Thus, "UDP connection" seems wrong to me, at least =
in
this context.

Moreover, "attempts to open" seems incorrect to me, because bash does not a=
ttemp
to open anything.=A0 Maybe bash "tries to send" or "attempts to send" a UDP
datagram, but does not try to open anything, nor a connection.

To me, it looks like someone has done copy-paste from the block of TCP
(block that is correct, because TCP is connection-oriented) and just change=
d TCP
word for UDP.=A0 However, UDP is not the same as TCP and one of the differe=
nces is
that UDP *does not establish any type of connections*.

So, I propose to change the sentence:
=A0=A0=A0 "bash attemps to open a UDP connection to the corresponding socke=
t"
to:
=A0=A0=A0 "bash attemps to send a UDP datagram to the corresponding socket"

It's seems to me reasonably accurate

Please, feel free to make any suggestions, variations or whatever. Thanks.

Jan Carreras

Note: I sent this mail to chet.ramey@case.edu twelve days ago and I
don't have a response yet. I guess that the next logic step is sending
the mail to bug-bash@gnu.org. If I'm wrong please point me to the
right place. Thanks.


From MAILER-DAEMON Sun Apr 22 16:30:19 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SM3QJ-0004WM-Rq
	for mharc-bug-bash@gnu.org; Sun, 22 Apr 2012 16:30:19 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51931)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SM3QG-0004MC-47
	for bug-bash@gnu.org; Sun, 22 Apr 2012 16:30:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SM3QD-0006aW-4E
	for bug-bash@gnu.org; Sun, 22 Apr 2012 16:30:15 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:11653)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SM3QC-0006XS-WC
	for bug-bash@gnu.org; Sun, 22 Apr 2012 16:30:13 -0400
Received: from mpv7.case.edu (mpv7.tis.CWRU.Edu [129.22.104.170])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKB99326;
	Sun, 22 Apr 2012 16:30:10 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TKL55889 (AUTH cpr);
	Sun, 22 Apr 2012 16:30:04 -0400 (EDT)
Message-ID: <4F946A43.80902@case.edu>
Date: Sun, 22 Apr 2012 16:29:55 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Andreas Schwab <schwab@linux-m68k.org>
Subject: Re: string replace with multibyte chars and extglob fails with
	bash-4.2
References: <201204211243.30163.vapier@gentoo.org> <m2zka4evgk.fsf@igel.home>
In-Reply-To: <m2zka4evgk.fsf@igel.home>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 22 Apr 2012 20:30:17 -0000

On 4/21/12 3:27 PM, Andreas Schwab wrote:
> Mike Frysinger <vapier@gentoo.org> writes:
> 
>> first set your locale to something unicode based:
>> export LC_ALL=en_US.UTF-8
>>
>> then try the simple script (from Ulrich Müller):
>> $ cat test.sh
>> shopt -s extglob
>> text="aaaäöü"
>> echo "${text} ${text//?aa} ${text//\aaa}"
>>
>> with bash-4.1_p2, i get:
>> aaaäöü äöü äöü
>>
>> but with bash-4.2_p8 ... 4.2_p24 (just what i have locally):
>> aaaäöü aaaäöü aaaäöü
> 
> diff --git a/subst.c b/subst.c
> index 9feaa9c..ebd5138 100644
> --- a/subst.c
> +++ b/subst.c
> @@ -4161,7 +4161,7 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
>    simple = (wpat[0] != L'\\' && wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'[');
>  #if defined (EXTENDED_GLOB)
>    if (extended_glob)
> -    simple |= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
> +    simple &= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
>  #endif

Thanks; this is the right fix.

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


From MAILER-DAEMON Sun Apr 22 16:47:27 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SM3gt-00085F-BH
	for mharc-bug-bash@gnu.org; Sun, 22 Apr 2012 16:47:27 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34101)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SM3go-00084h-BF
	for bug-bash@gnu.org; Sun, 22 Apr 2012 16:47:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SM3gm-0005Aw-LH
	for bug-bash@gnu.org; Sun, 22 Apr 2012 16:47:21 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:31961)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SM3gm-0005Ac-GY
	for bug-bash@gnu.org; Sun, 22 Apr 2012 16:47:20 -0400
Received: from mpv8.case.edu (mpv8.tis.CWRU.Edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKC00349;
	Sun, 22 Apr 2012 16:47:17 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TQX67822 (AUTH cpr);
	Sun, 22 Apr 2012 16:47:17 -0400 (EDT)
Message-ID: <4F946E52.2010307@case.edu>
Date: Sun, 22 Apr 2012 16:47:14 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Artur Rataj <arturrataj@gmail.com>
Subject: Re: Directory completion problems
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
	<4F8FF6A5.1060301@redhat.com>
	<CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
	<4F9005E0.2090006@case.edu>
	<CACO3_sA2s6ou+wfht+ssL6zNR_tPhKC-zEEVS9xm_M_1iVPWww@mail.gmail.com>
In-Reply-To: <CACO3_sA2s6ou+wfht+ssL6zNR_tPhKC-zEEVS9xm_M_1iVPWww@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: Roman Rakus <rrakus@redhat.com>, bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 22 Apr 2012 20:47:26 -0000

On 4/19/12 9:03 AM, Artur Rataj wrote:
> I want the logical view, and I think there is one by now. But there is a
> file missing in the logical directory, when cd ../ is completed from a symlink.
> 
> ~/projects/art/dev$ ls -la
> drwxr-xr-x  6 art art 4096 2012-02-24 16:21 .bzr
> lrwxrwxrwx  1 art art   18 2012-04-16 14:48 lib -> ../../hth/dev/lib/
> drwxr-xr-x  2 art art 4096 2012-02-24 16:21 src
> ~/projects/art/dev$ cd lib/../
> .bzr/ lib/ 
> 
> I have made a test directory, to analyse the problem:
> 
> ~/a$ ls -la
> drwxr-xr-x  5 art art 4096 2012-04-19 14:50 .
> drwxr-xr-x 80 art art 4096 2012-04-19 14:48 ..
> drwxr-xr-x  2 art art 4096 2012-04-19 14:48 .hidden
> drwxr-xr-x  2 art art 4096 2012-04-19 14:50 .java
> lrwxrwxrwx  1 art art    7 2012-04-19 14:48 symlink -> ../test
> ~/a$ cd symlink/../
> 
> hitting Tab gives:
> 
> ~/a$ cd symlink/../.java/

I'm wondering if you're using a completion for cd.  Using both bash-4.2.24
and the current development source, I get a completion of "symlink " (with
a space instead of a slash appended, since readline needs some more work
to do the same kind of logical directory traversal that bash does).

Chet

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


From MAILER-DAEMON Sun Apr 22 16:53:20 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SM3ma-0000cD-3L
	for mharc-bug-bash@gnu.org; Sun, 22 Apr 2012 16:53:20 -0400
Received: from eggs.gnu.org ([208.118.235.92]:33615)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SM3mW-0000aa-Kc
	for bug-bash@gnu.org; Sun, 22 Apr 2012 16:53:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SM3mU-0007Xj-GR
	for bug-bash@gnu.org; Sun, 22 Apr 2012 16:53:16 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:15589)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SM3mU-0007XU-BT
	for bug-bash@gnu.org; Sun, 22 Apr 2012 16:53:14 -0400
Received: from mpv8.tis.cwru.edu (EHLO mpv8.case.edu) ([129.22.105.116])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXX21759 (AUTH cpr);
	Sun, 22 Apr 2012 16:53:12 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TQX72012 (AUTH cpr);
	Sun, 22 Apr 2012 16:53:12 -0400 (EDT)
Message-ID: <4F946FB7.50807@case.edu>
Date: Sun, 22 Apr 2012 16:53:11 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Artur Rataj <arturrataj@gmail.com>
Subject: Re: Directory completion problems
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
	<4F8FF6A5.1060301@redhat.com>
	<CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
	<4F9005E0.2090006@case.edu>
	<CACO3_sA2s6ou+wfht+ssL6zNR_tPhKC-zEEVS9xm_M_1iVPWww@mail.gmail.com>
	<CACO3_sAeOHdY2XDUqJ=6Cz0n8eWCZP8W8WVPgMFx++hkeKjETg@mail.gmail.com>
In-Reply-To: <CACO3_sAeOHdY2XDUqJ=6Cz0n8eWCZP8W8WVPgMFx++hkeKjETg@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 22 Apr 2012 20:53:18 -0000

On 4/20/12 4:41 AM, Artur Rataj wrote:
> ~/a$ mkdir .java
> ~/a$ cd symlink
> ~/a/symlink$ cd ../.java/
> ~/a/.java$
> ~/a/.java$ cd ../
> ~/a$ rm -r .java && touch .java
> ~/a$ cd symlink
> ~/a/symlink$ cd ../.java/
> ~/.java$
> 
> Should it really be like that?

I can't reproduce it.  Is the following an accurate reproduction of what
you did?

z4.local(2)$ cd test
z4.local(2)$ ls -al
total 4
drwxrwxr-x   5 chet  admin   170 Apr 22 16:36 ./
drwxrwxr-x  88 chet  admin  2992 Apr 22 16:34 ../
drwxrwxr-x   2 chet  admin    68 Apr 22 16:36 .hidden/
drwxrwxr-x   2 chet  admin    68 Apr 22 16:36 .java/
lrwxrwxr-x   1 chet  admin     7 Apr 22 16:36 symlink@ -> ../test
z4.local(2)$ echo $PWD
/usr/local/build/bash/bash-20120420/test
z4.local(2)$ cd symlink
z4.local(2)$ echo $PWD
/usr/local/build/bash/bash-20120420/test/symlink
z4.local(2)$ cd ../.java
z4.local(2)$ echo $PWD
/usr/local/build/bash/bash-20120420/test/.java
z4.local(2)$ cd ..
z4.local(2)$ echo $PWD
/usr/local/build/bash/bash-20120420/test
z4.local(2)$ rm -r .java && touch .java
z4.local(2)$ ls -al
total 4
drwxrwxr-x   5 chet  admin   170 Apr 22 16:50 ./
drwxrwxr-x  88 chet  admin  2992 Apr 22 16:34 ../
drwxrwxr-x   2 chet  admin    68 Apr 22 16:36 .hidden/
-rw-rw-r--   1 chet  admin     0 Apr 22 16:50 .java
lrwxrwxr-x   1 chet  admin     7 Apr 22 16:36 symlink@ -> ../test
z4.local(2)$ cd symlink
z4.local(2)$ echo $PWD
/usr/local/build/bash/bash-20120420/test/symlink
z4.local(2)$ cd ../.java
bash: cd: ../.java: No such file or directory
z4.local(2)$ echo $PWD
/usr/local/build/bash/bash-20120420/test/symlink

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


From MAILER-DAEMON Mon Apr 23 00:21:09 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMAlx-0006eG-1t
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 00:21:09 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50188)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMAlu-0006e9-0Z
	for bug-bash@gnu.org; Mon, 23 Apr 2012 00:21:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMAls-0007OX-Bj
	for bug-bash@gnu.org; Mon, 23 Apr 2012 00:21:05 -0400
Received: from smtp.gentoo.org ([140.211.166.183]:38366)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMAls-0007N6-5g
	for bug-bash@gnu.org; Mon, 23 Apr 2012 00:21:04 -0400
Received: from vapier.localnet (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id 74FD71B410D
	for <bug-bash@gnu.org>; Mon, 23 Apr 2012 04:21:01 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: bug-bash@gnu.org
Subject: [patch] fix building when readline is disabled
Date: Mon, 23 Apr 2012 00:22:22 -0400
User-Agent: KMail/1.13.7 (Linux/3.4.0-rc1; KDE/4.6.5; x86_64; ; )
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart1387920.XLVqGGOqBU";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
Message-Id: <201204230022.23283.vapier@gentoo.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 140.211.166.183
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 23 Apr 2012 04:21:07 -0000

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

if you disable readline, the complete.def code fails to build.  simple patc=
h=20
below (not sure if it's correct, but at least gets the conversation going).
=2Dmike

=2D-- a/builtins/complete.def
+++ b/builtins/complete.def
@@ -49,6 +49,8 @@ $END
=20
 #include <config.h>
=20
+#ifdef READLINE
+
 #include <stdio.h>
=20
 #include "../bashtypes.h"
@@ -867,3 +869,5 @@ compopt_builtin (list)
=20
   return (ret);
 }
+
+#endif

--nextPart1387920.XLVqGGOqBU
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJPlNj/AAoJEEFjO5/oN/WBtWEQAN+3bdmLYGsyW9I1jUoZ+2o4
yCWgKYnPxoDYAv4xSHeY64tpPgfU1teI2tr0+5/NjCcCCLfRltVgDafA6AKKQt9u
qWYDVpI516bgT4Pn70+4N6yFlHczUJ4yRQPvkhOH24RiVSuXkeycC1PmVYOTbtfq
ngz41AX1VxUmHHNnPY17oZp9ISh1FKGm1kMgjsAOaHTKaefARcvMBdQ0lxogBR2H
D4y+/SB922TxmOFs1vrki0ZSfbV3neN/lJ9scVdwjUdo3ULrymyViG1+D17ED+rb
2tb8ImmLK9KBAaovcdk4ToHkSfCVE/Pu1mzKMzQwcPiezyOZjv65NDYLQVu00r7M
lVSPml0+wLqUik+JtCeqmFuzDF7+0Sh6aID+apwdzHWkNR5vg6lTDHrWNC3hxwb6
XhQqCqTxCIDbSkoxiCe4xmoo2VUQEShBKvMFJq7pNUMTQ/+oTXwWm/VslwS20z2d
T2hoqaAbsJR9gnJ7z/5Wv3foyRkOvInGN0XRJO0bxDJXQ5X5bS9ypsNxG7er08Qt
435Ntn/u03ZYYJFVGApy/hUsUaTsEslrbTZGWXCoJS2yJUkKEvr7hldd5JYoK2XP
PlzII138/Pu8AInTv8fIMSv/GxomM2XVlP2pIuAHfsjiAzXckEfnrP6vlzpsU2TH
WD2Cs1z0uhokP+/THK0t
=JTF4
-----END PGP SIGNATURE-----

--nextPart1387920.XLVqGGOqBU--


From MAILER-DAEMON Mon Apr 23 03:57:24 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SME9E-0007b0-Ej
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 03:57:24 -0400
Received: from eggs.gnu.org ([208.118.235.92]:54575)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SME98-0007Zc-Hi
	for bug-bash@gnu.org; Mon, 23 Apr 2012 03:57:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SME92-0003Hp-AT
	for bug-bash@gnu.org; Mon, 23 Apr 2012 03:57:18 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:43688)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <arturrataj@gmail.com>) id 1SME92-0003HF-32
	for bug-bash@gnu.org; Mon, 23 Apr 2012 03:57:12 -0400
Received: by obbeh20 with SMTP id eh20so12271211obb.0
	for <bug-bash@gnu.org>; Mon, 23 Apr 2012 00:57:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:content-type; bh=vFnycX2sd6pl8Ed6L/TkrLG6+ZhPPjKMHrTM6S5r0r4=;
	b=X70Yal0M4iVs4a614cI/KQzlZ1hUoB8pnNe1WmslQLEixyHlNnfqswpAJlT7EvCqPi
	2eeDkCl2yXzYTUl3RNHtbLAYSlmk7KllJRALIgM6zN7EDF1B7FgqSBd0CJWh0Ay88oZh
	RVA14Fpm4DO2hVpa1YeidPV4e3jomr3+Oh1cun+oEVJYw9lVuQjBwaAQc+GAsZNSGw0o
	cMIYdzKMarROcBXUa14WHzQpUcID5eZeYhw2RSwOedhren0r3KGc8neKGlfjXz/nTFmu
	au3n5OiwxEdoCoCUFz5Yo3ost9lyoMo81elX82X36Pgx7xcZkqyfUVWxfzacHMxdc6ts
	crdw==
MIME-Version: 1.0
Received: by 10.182.232.38 with SMTP id tl6mr6165720obc.16.1335167829227; Mon,
	23 Apr 2012 00:57:09 -0700 (PDT)
Received: by 10.182.105.34 with HTTP; Mon, 23 Apr 2012 00:57:09 -0700 (PDT)
In-Reply-To: <4F946FB7.50807@case.edu>
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
	<4F8FF6A5.1060301@redhat.com>
	<CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
	<4F9005E0.2090006@case.edu>
	<CACO3_sA2s6ou+wfht+ssL6zNR_tPhKC-zEEVS9xm_M_1iVPWww@mail.gmail.com>
	<CACO3_sAeOHdY2XDUqJ=6Cz0n8eWCZP8W8WVPgMFx++hkeKjETg@mail.gmail.com>
	<4F946FB7.50807@case.edu>
Date: Mon, 23 Apr 2012 09:57:09 +0200
Message-ID: <CACO3_sDbj7LV_00Q7HkZykbhg++DC0memQw1rjRW+4R91J9KNg@mail.gmail.com>
Subject: Re: Directory completion problems
From: Artur Rataj <arturrataj@gmail.com>
To: bug-bash@gnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 23 Apr 2012 07:57:23 -0000

To be exact, symlink is in the directory ~/a, and it points to ~/test and
there is also a directory ~/.java. So, after cd ~/a/symlink, there are two
../.java files -- one in the physical parent, and one in the logical
parent. The former is a directory, the latter is a plain file.

~/a/symlink$ cd ../

produces one alternative: .java, but only if the plain file .java exists.
So, it seems that filenames of all ~/ directories seem to be matched
against filenames of all ~/a/ files of any kind, and the AND result is used
by the completion.

But, if there is some directory in the logical directory, that does not
have its namesake in the physical directory, it is ignored:

ls -la ~/a
total 16
drwxr-xr-x  4 art art 4096 Apr 23 09:51 .
drwxr-xr-x 83 art art 4096 Apr 23 09:51 ..
drwxr-xr-x  2 art art 4096 Apr 19 14:48 .hidden
drwxr-xr-x  2 art art 4096 Apr 23 09:51 i
-rw-r--r--  1 art art    0 Apr 23 09:40 .java
lrwxrwxrwx  1 art art    7 Apr 19 14:48 symlink -> ../test
~/a/symlink$ cd ../i [completion shows only .java, but cd works for i as
well]
~/a/i$

To sum that up, files in the logical directory sometimes affect the cd
completion even that they are not directories at all, and sometimes they
are ignored even that they are directories indeed.

From MAILER-DAEMON Mon Apr 23 04:56:49 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMF4j-0005le-B1
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 04:56:49 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48792)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SMF4d-0005kf-7V
	for bug-bash@gnu.org; Mon, 23 Apr 2012 04:56:47 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SMF4Y-0000RW-3Y
	for bug-bash@gnu.org; Mon, 23 Apr 2012 04:56:42 -0400
Received: from rcsinet15.oracle.com ([148.87.113.117]:38889)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SMF4X-0000Qq-Hg
	for bug-bash@gnu.org; Mon, 23 Apr 2012 04:56:37 -0400
Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93])
	by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with
	ESMTP id q3N8uWcx027179
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Mon, 23 Apr 2012 08:56:33 GMT
Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158])
	by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
	q3N8uVmI028422
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <bug-bash@gnu.org>; Mon, 23 Apr 2012 08:56:32 GMT
Received: from abhmt113.oracle.com (abhmt113.oracle.com [141.146.116.65])
	by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id
	q3N8uVNR007433
	for <bug-bash@gnu.org>; Mon, 23 Apr 2012 03:56:31 -0500
Received: from mail-ob0-f169.google.com (/209.85.214.169)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Mon, 23 Apr 2012 01:56:31 -0700
Received: by obbeh20 with SMTP id eh20so12350221obb.0
	for <bug-bash@gnu.org>; Mon, 23 Apr 2012 01:56:30 -0700 (PDT)
Received: by 10.60.169.146 with SMTP id ae18mr17239144oec.36.1335171390916;
	Mon, 23 Apr 2012 01:56:30 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.182.75.37 with HTTP; Mon, 23 Apr 2012 01:56:09 -0700 (PDT)
In-Reply-To: <20100504175709.GA3757@blondy.prov>
References: <20100501081803.GA4615@rebase.prov>
	<n2kaca4c5091005010226p1e98d791h71e0fd5af8f325c3@mail.gmail.com>
	<r2pc440c9801005010240o2388c72fjb8ce0aa6b123d19c@mail.gmail.com>
	<20100501112118.GB4615@rebase.prov>
	<o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov> <20100504175709.GA3757@blondy.prov>
From: Clark Wang <clark.wang@oracle.com>
Date: Mon, 23 Apr 2012 16:56:09 +0800
Message-ID: <CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
Subject: Re: Passing variables by reference conflicts with local
To: bug-bash@gnu.org
X-Source-IP: ucsinet21.oracle.com [156.151.31.93]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1)
X-Received-From: 148.87.113.117
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 23 Apr 2012 08:56:47 -0000

On Wed, May 5, 2010 at 01:57, Freddy Vulto <fvulto@gmail.com> wrote:

> It appears that `unset' is capable of traversing down the call-stack and
> unsetting variables repeatedly:
>
>    a=0 b=0 c=0 d=0 e=0
>    _unset() { unset -v b c c d d d e; }
>    t1() {
>        local a=1 b=1 c=1 d=1
>        t2
>    }
>    t2() {
>        local a=2 b=2 c=2 d=2 e=2
>        _unset
>        echo a:$a b:$b c:$c d:$d e:$e
>    }
>    t1  # Outputs: a:2 b:1 c:0 d: e:0
>        #            ^   ^   ^   ^  ^-- unset once (skipped t1)
>        #            |   |   |   +----- unset thrice to global
>        #            |   |   +--------- unset twice till global
>        #            |   +------------- unset once till t1
>        #            +----------------- unset not
>
> It seems to work on bash-3.0, 3.2, 4.0 and 4.1.
> Is this a bug or a feature?
>

When I revisit this 2 years old thread I don't understand why following
foo() function does not output the global var:

$ cat foo.sh
var=global
foo()
{
    local var=foo
    unset var
    echo foo: $var
}
bar_unset()
{
    unset var
}
bar()
{
    local var=bar
    bar_unset
    echo bar: $var
}
foo
bar
$ bash foo.sh
foo:
bar: global
$

In foo() it unsets its local var so why doesn't the subsequent $var refer
to the global var?

>
> Freddy Vulto
> http://fvue.nl/wiki/Bash:_passing_variables_by_reference
>
>
>

From MAILER-DAEMON Mon Apr 23 11:26:33 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SML9t-0006Pb-II
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 11:26:33 -0400
Received: from eggs.gnu.org ([208.118.235.92]:36497)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jstcdr@gmail.com>) id 1SMGfa-0007zw-Uh
	for bug-bash@gnu.org; Mon, 23 Apr 2012 06:39:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jstcdr@gmail.com>) id 1SMGfS-0001xD-EF
	for bug-bash@gnu.org; Mon, 23 Apr 2012 06:38:58 -0400
Received: from mail-pb0-f41.google.com ([209.85.160.41]:60505)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jstcdr@gmail.com>) id 1SMGfS-0001wo-2f
	for bug-bash@gnu.org; Mon, 23 Apr 2012 06:38:50 -0400
Received: by pbcup15 with SMTP id up15so3712674pbc.0
	for <bug-bash@gnu.org>; Mon, 23 Apr 2012 03:38:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=oGBsuFgsvatiRjedRnnGao9HkXl2upfRwuG1XOzUjIQ=;
	b=Tunr/WxIS3FbR2xlmDPjHJGIpOarpk5ypILrsRM+/RTv9so8BqWUOdT5zhVEVBEyos
	+6d76P+GsPetWvFlWGQL1yn4bfe6NQ0JYPUi93qHJMbLPFysYo6STUWXRl8MFofFuzXD
	gmqp9U2VKGIOdetjdWPpAQuHY0HMWUw+Tcr2lbF+RcFRCSFkpSiC/mMxvxVq2tPf6qql
	Uc8erxR4ZPZNLsM42djJ5OwNa6SQhTBY75goa3p6/rFh1z3lDQCxjLjIYELk+MCpnwop
	AuKvRYxab3W5BOIWpyPQZIW7ZkdqX0ijFiRfgj3bgokkQd2cSnJVPoFK3cuxfC3xOCBI
	jDnQ==
MIME-Version: 1.0
Received: by 10.68.218.72 with SMTP id pe8mr29964500pbc.45.1335177527062; Mon,
	23 Apr 2012 03:38:47 -0700 (PDT)
Received: by 10.68.74.7 with HTTP; Mon, 23 Apr 2012 03:38:47 -0700 (PDT)
Date: Mon, 23 Apr 2012 14:38:47 +0400
Message-ID: <CAEZVQT5PJ1Mb_Zh8LT5qz8sv+-9Q6hGfQ5DU9ZxdJ+gV7xBUaQ@mail.gmail.com>
Subject: Internal 'echo' command doesn't handle I/O errors on close file
From: Andrey Zaitsev <jstcdr@gmail.com>
To: bug-bash@gnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.160.41
X-Mailman-Approved-At: Mon, 23 Apr 2012 11:26:30 -0400
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 23 Apr 2012 10:39:05 -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-unknown-linux-gnu'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -D_GNU_SOURCE
-DRECYCLES_PIDS  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fwrapv
uname output: Linux dhcp-10-30-20-255.sw.ru 2.6.32-042stab054.1 #1 SMP Fri
Mar 30 01:41:10 MSD 2012 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.1
Patch Level: 2
Release Status: release

Description:
Internal 'echo' command doesn't handle I/O errors on close file when I try
redirect
standart output to mounted filesystem without free space.

Try redirect stdout of echo command to mounted filesystem without free space
[user@host ~]# echo "bla-bla-bla" > /mnt/fs/out.txt
[user@host ~]# echo $?
0
i.e. it means that all ok, but operation was failed.

Try the same action for /bin/echo
[user@host ~]# /bin/echo "bla-bla-bla" > /mnt/fs/out.txt
/bin/echo: write error: No space left on device
[user@host ~]# echo $?
1
valid behaviour

Strace show that errors from /bin/bash were ignored:

[user@host ~]# strace echo "bla-bla-bla" > /mnt/fs/out.txt
execve("/bin/echo", ["echo", "bla-bla-bla"], [/* 22 vars */]) = 0
brk(0)                                  = 0x2467000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d362000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=36827, ...}) = 0
mmap(NULL, 36827, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f766d359000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3,
"\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355!b2\0\0\0"..., 832)
= 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1979000, ...}) = 0
mmap(0x3262200000, 3803304, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0x3262200000
mprotect(0x3262397000, 2097152, PROT_NONE) = 0
mmap(0x3262597000, 20480, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x197000) = 0x3262597000
mmap(0x326259c000, 18600, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x326259c000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d358000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d357000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d356000
arch_prctl(ARCH_SET_FS, 0x7f766d357700) = 0
mprotect(0x3262597000, 16384, PROT_READ) = 0
mprotect(0x326201f000, 4096, PROT_READ) = 0
munmap(0x7f766d359000, 36827)           = 0
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=99158704, ...}) = 0
mmap(NULL, 99158704, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f76674c5000
close(3)                                = 0
brk(0)                                  = 0x2467000
brk(0x2488000)                          = 0x2488000
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2512, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d361000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2512
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f766d361000, 4096)            = 0
open("/usr/lib/locale/posix/LC_IDENTIFICATION", O_RDONLY) = -1 ENOENT (No
such file or directory)
fstat(1, {st_mode=S_IFREG|0700, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d361000
write(1, "bla-bla-bla\n", 12)           = 12
close(1)                                = -1 ENOSPC (No space left on
device)
munmap(0x7f766d361000, 4096)            = 0
write(2, "echo: ", 6echo: )                   = 6
write(2, "write error", 11write error)             = 11
write(2, ": No space left on device", 25: No space left on device) = 25
write(2, "\n", 1
)                       = 1
exit_group(1)                           = ?

From MAILER-DAEMON Mon Apr 23 11:38:10 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMLL8-00048C-9i
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 11:38:10 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57094)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SMLKy-00044d-Or
	for bug-bash@gnu.org; Mon, 23 Apr 2012 11:38:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SMLKx-0004AA-1Z
	for bug-bash@gnu.org; Mon, 23 Apr 2012 11:38:00 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:43838
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SMLKw-00048d-Qw
	for bug-bash@gnu.org; Mon, 23 Apr 2012 11:37:58 -0400
Received: (qmail 21485 invoked from network); 23 Apr 2012 15:37:55 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Mon, 23 Apr 2012 11:37:55 -0400
Received: (qmail 28772 invoked by uid 563); 23 Apr 2012 15:37:54 -0000
Date: Mon, 23 Apr 2012 11:37:54 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Andrey Zaitsev <jstcdr@gmail.com>
Subject: Re: Internal 'echo' command doesn't handle I/O errors on close file
Message-ID: <20120423153754.GD22241@eeg.ccf.org>
References: <CAEZVQT5PJ1Mb_Zh8LT5qz8sv+-9Q6hGfQ5DU9ZxdJ+gV7xBUaQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAEZVQT5PJ1Mb_Zh8LT5qz8sv+-9Q6hGfQ5DU9ZxdJ+gV7xBUaQ@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 23 Apr 2012 15:38:08 -0000

On Mon, Apr 23, 2012 at 02:38:47PM +0400, Andrey Zaitsev wrote:
> Strace show that errors from /bin/bash were ignored:
> 
> [user@host ~]# strace echo "bla-bla-bla" > /mnt/fs/out.txt
> execve("/bin/echo", ["echo", "bla-bla-bla"], [/* 22 vars */]) = 0

If you want an strace of the internal echo, you have to do it this
way:

# strace bash -c 'echo "bla-bla-bla" > /mnt/fs/out.txt'

In fact it's the redirection whose failure you really care about.


From MAILER-DAEMON Mon Apr 23 12:50:47 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMMTP-0003Ew-QN
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 12:50:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50865)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SMMTN-0003EN-CI
	for bug-bash@gnu.org; Mon, 23 Apr 2012 12:50:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SMMTK-00066F-Th
	for bug-bash@gnu.org; Mon, 23 Apr 2012 12:50:44 -0400
Received: from mail-out.m-online.net ([212.18.0.9]:47639)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <whitebox@nefkom.net>) id 1SMMTK-00062z-Ma
	for bug-bash@gnu.org; Mon, 23 Apr 2012 12:50:42 -0400
Received: from frontend1.mail.m-online.net (unknown [192.168.8.180])
	by mail-out.m-online.net (Postfix) with ESMTP id 3Vbtvs60fzz4LDfW;
	Mon, 23 Apr 2012 18:50:33 +0200 (CEST)
Received: from igel.home (ppp-93-104-156-10.dynamic.mnet-online.de
	[93.104.156.10])
	by mail.mnet-online.de (Postfix) with ESMTPA id 3Vbtvs1m9sz4KK60;
	Mon, 23 Apr 2012 18:50:33 +0200 (CEST)
Received: by igel.home (Postfix, from userid 501)
	id 7EA2DCA2AA; Mon, 23 Apr 2012 18:50:32 +0200 (CEST)
From: Andreas Schwab <schwab@linux-m68k.org>
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: Internal 'echo' command doesn't handle I/O errors on close file
References: <CAEZVQT5PJ1Mb_Zh8LT5qz8sv+-9Q6hGfQ5DU9ZxdJ+gV7xBUaQ@mail.gmail.com>
	<20120423153754.GD22241@eeg.ccf.org>
X-Yow: I'm shaving!!  I'M SHAVING!!
Date: Mon, 23 Apr 2012 18:50:31 +0200
In-Reply-To: <20120423153754.GD22241@eeg.ccf.org> (Greg Wooledge's message of
	"Mon, 23 Apr 2012 11:37:54 -0400")
Message-ID: <m2fwbuxui0.fsf@igel.home>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	4)
X-Received-From: 212.18.0.9
Cc: Andrey Zaitsev <jstcdr@gmail.com>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 23 Apr 2012 16:50:46 -0000

Greg Wooledge <wooledg@eeg.ccf.org> writes:

> On Mon, Apr 23, 2012 at 02:38:47PM +0400, Andrey Zaitsev wrote:
>> Strace show that errors from /bin/bash were ignored:
>> 
>> [user@host ~]# strace echo "bla-bla-bla" > /mnt/fs/out.txt
>> execve("/bin/echo", ["echo", "bla-bla-bla"], [/* 22 vars */]) = 0
>
> If you want an strace of the internal echo, you have to do it this
> way:
>
> # strace bash -c 'echo "bla-bla-bla" > /mnt/fs/out.txt'
>
> In fact it's the redirection whose failure you really care about.

The redirection itself won't fail, unless the device is out of inodes.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


From MAILER-DAEMON Mon Apr 23 13:13:57 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMMpp-00018p-0g
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 13:13:57 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57428)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SMMpm-000180-N0
	for bug-bash@gnu.org; Mon, 23 Apr 2012 13:13:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SMMpg-0004hf-L0
	for bug-bash@gnu.org; Mon, 23 Apr 2012 13:13:54 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:43895
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SMMpg-0004hU-Ej
	for bug-bash@gnu.org; Mon, 23 Apr 2012 13:13:48 -0400
Received: (qmail 22467 invoked from network); 23 Apr 2012 17:13:43 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Mon, 23 Apr 2012 13:13:43 -0400
Received: (qmail 28982 invoked by uid 563); 23 Apr 2012 17:13:42 -0000
Date: Mon, 23 Apr 2012 13:13:42 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: bug-bash@gnu.org
Subject: Re: Internal 'echo' command doesn't handle I/O errors on close file
Message-ID: <20120423171342.GG22241@eeg.ccf.org>
References: <CAEZVQT5PJ1Mb_Zh8LT5qz8sv+-9Q6hGfQ5DU9ZxdJ+gV7xBUaQ@mail.gmail.com>
	<20120423153754.GD22241@eeg.ccf.org> <m2fwbuxui0.fsf@igel.home>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <m2fwbuxui0.fsf@igel.home>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 23 Apr 2012 17:13:56 -0000

On Mon, Apr 23, 2012 at 06:50:31PM +0200, Andreas Schwab wrote:
> The redirection itself won't fail, unless the device is out of inodes.

Ah... OK, I can see how that might be the case.  Or depending on the
file system implementation, it might fail if an additional block of
disk space would need to be allocated to the directory to hold the
new filename.  Which should be somewhat rare in practice.


From MAILER-DAEMON Mon Apr 23 18:57:14 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMSC2-0004iM-1y
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 18:57:14 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59582)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMSBz-0004hd-1X
	for bug-bash@gnu.org; Mon, 23 Apr 2012 18:57:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMSBx-0003EC-6k
	for bug-bash@gnu.org; Mon, 23 Apr 2012 18:57:10 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:32082)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMSBx-0003Dt-1w
	for bug-bash@gnu.org; Mon, 23 Apr 2012 18:57:09 -0400
Received: from mpv7.case.edu (mpv7.tis.CWRU.Edu [129.22.104.170])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKC87223;
	Mon, 23 Apr 2012 18:57:06 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TKX24059 (AUTH cpr);
	Mon, 23 Apr 2012 18:57:06 -0400 (EDT)
Message-ID: <4F95DE41.5060109@case.edu>
Date: Mon, 23 Apr 2012 18:57:05 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Mike Frysinger <vapier@gentoo.org>
Subject: Re: [patch] fix building when readline is disabled
References: <201204230022.23283.vapier@gentoo.org>
In-Reply-To: <201204230022.23283.vapier@gentoo.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 23 Apr 2012 22:57:12 -0000

On 4/23/12 12:22 AM, Mike Frysinger wrote:
> if you disable readline, the complete.def code fails to build.  simple patch 
> below (not sure if it's correct, but at least gets the conversation going).

How did you disable readline?  Running configure --disable-readline and
building as usual works for me.  You might want to run `make clean' before
rebuilding.

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


From MAILER-DAEMON Mon Apr 23 19:40:01 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMSrR-0001KW-RB
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 19:40:01 -0400
Received: from eggs.gnu.org ([208.118.235.92]:40983)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMSrP-0001K6-7X
	for bug-bash@gnu.org; Mon, 23 Apr 2012 19:40:00 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMSqv-0004Fo-0M
	for bug-bash@gnu.org; Mon, 23 Apr 2012 19:39:58 -0400
Received: from smtp.gentoo.org ([140.211.166.183]:47086)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMSqu-0004Cy-Q5
	for bug-bash@gnu.org; Mon, 23 Apr 2012 19:39:28 -0400
Received: from vapier.localnet (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id B12991B4001;
	Mon, 23 Apr 2012 23:39:26 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: chet.ramey@case.edu
Subject: Re: [patch] fix building when readline is disabled
Date: Mon, 23 Apr 2012 19:40:53 -0400
User-Agent: KMail/1.13.7 (Linux/3.4.0-rc1; KDE/4.6.5; x86_64; ; )
References: <201204230022.23283.vapier@gentoo.org> <4F95DE41.5060109@case.edu>
In-Reply-To: <4F95DE41.5060109@case.edu>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart1372744.BMpmd5o5AV";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
Message-Id: <201204231940.54468.vapier@gentoo.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 140.211.166.183
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 23 Apr 2012 23:40:00 -0000

--nextPart1372744.BMpmd5o5AV
Content-Type: Text/Plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

On Monday 23 April 2012 18:57:05 Chet Ramey wrote:
> On 4/23/12 12:22 AM, Mike Frysinger wrote:
> > if you disable readline, the complete.def code fails to build.  simple
> > patch below (not sure if it's correct, but at least gets the
> > conversation going).
>=20
> How did you disable readline?  Running configure --disable-readline and
> building as usual works for me.  You might want to run `make clean' before
> rebuilding.

i suspect you have readline files still being included and it appears to wo=
rk.

let's look at vanilla bash-4.2:
$ tar xf bash-4.2.tar.gz
$ cd bash-4.2
$ ./configure --disable-readline
$ make
=2E..
rm -f complete.o
=2E/mkbuiltins -D . complete.def
gcc -c  -DHAVE_CONFIG_H -DSHELL  -I. -I..  -I.. -I../include -I../lib -I.  =
  -g -O2 complete.c || ( rm -f complete.c ; exit 1 )
rm -f complete.c
=2E..

so, let's go into that dir and run it by hand:
$ cd builtins
$ ./mkbuiltins -D . complete.def
$ strace -f -eopen gcc -c  -DHAVE_CONFIG_H -DSHELL  -I. -I..  -I.. -I../inc=
lude -I../lib -I.    -g -O2 complete.c |& grep readline.h
=2E..
[pid 12453] open("../lib/readline/readline.h", O_RDONLY|O_NOCTTY) =3D 4
=2E..

if you were to clean out your readline code first, you'd see the build error
i'm seeing instead of the local readline code getting implicitly used even
though it was explicitly disabled.
=2Dmike

--nextPart1372744.BMpmd5o5AV
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJPleiGAAoJEEFjO5/oN/WBS/cQAOBJ4QjCCUO6tSChrvOU+IFy
VqnRSvfiM7By88REQE7bWGvRryAW2vH0UxnZ8LYjyjP7/PhKKnhan7Qm+dK21h3T
V4Yj9ZN/T4cioP1GoRRLhOrix5H+Q979kyT1g0OJ99I46jHIijj6nTdnvwPGpC3Z
PruQw7mgC6ArsfTt4YLYBWzYFsMOOFQMlDA3OyhX5TQozWTrzejK4Cn8CGUGcnbb
fJSrTuxfbWfZBbTHHqs02nm6p24y1PQpJd1BXdoE2eyeH4auHw1g8jEpTua8NskJ
BuhIuQykPk4C2CEpfABwWGBcK+2covEF1US/C2YcTpngiEVdspSlTGlyP2ouVX7f
1CL7ljl1UvDelYP9IaHscSyMZyxzp33TzN2616Jbggt11xeJ8e0sgMY1MGJdzwIp
K4uYGxw5TAKmGCglSKeMSu5vrhVFAKLN4KUxRdPk0tEw/6pXzBtGG9F8s7Qw0wYd
X8Uu9rdRlIiQKpQ8Gf0zHDTWy6+/gS8PkA00BMcMzk1zBfWJJUrsNJK64PWZiBUy
d17Ipw/K/QkjpPFOAhO/10KVXH3Ym2GD9g657d0hsyM8CIKvAQg01+3UuJfloxb1
o8BKnhmJl2w99xTMwz5rGJWoQeR8FeXBe42D+miFzXvD8sMMbIW82G55S8lENDM1
RnrR5xHlHQl99pHRs9wU
=nEMn
-----END PGP SIGNATURE-----

--nextPart1372744.BMpmd5o5AV--


From MAILER-DAEMON Mon Apr 23 20:08:34 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMTJ4-00030L-CB
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 20:08:34 -0400
Received: from eggs.gnu.org ([208.118.235.92]:35814)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMTJ1-00030B-S1
	for bug-bash@gnu.org; Mon, 23 Apr 2012 20:08:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMTIz-0007bo-Lo
	for bug-bash@gnu.org; Mon, 23 Apr 2012 20:08:31 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:2828)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMTIz-0007bP-Gw
	for bug-bash@gnu.org; Mon, 23 Apr 2012 20:08:29 -0400
Received: from mpv7.tis.cwru.edu (EHLO mpv7.case.edu) ([129.22.104.170])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXY21531 (AUTH cpr);
	Mon, 23 Apr 2012 20:08:27 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TKX45218 (AUTH cpr);
	Mon, 23 Apr 2012 20:08:26 -0400 (EDT)
Message-ID: <4F95EEFA.8020906@case.edu>
Date: Mon, 23 Apr 2012 20:08:26 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Mike Frysinger <vapier@gentoo.org>
Subject: Re: [patch] fix building when readline is disabled
References: <201204230022.23283.vapier@gentoo.org> <4F95DE41.5060109@case.edu>
	<201204231940.54468.vapier@gentoo.org>
In-Reply-To: <201204231940.54468.vapier@gentoo.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 24 Apr 2012 00:08:33 -0000

On 4/23/12 7:40 PM, Mike Frysinger wrote:
> On Monday 23 April 2012 18:57:05 Chet Ramey wrote:
>> On 4/23/12 12:22 AM, Mike Frysinger wrote:
>>> if you disable readline, the complete.def code fails to build.  simple
>>> patch below (not sure if it's correct, but at least gets the
>>> conversation going).
>>
>> How did you disable readline?  Running configure --disable-readline and
>> building as usual works for me.  You might want to run `make clean' before
>> rebuilding.
> 
> i suspect you have readline files still being included and it appears to work.

OK, so you've stripped the local readline copy out of the source tree?
Then configured it to build with a system readline library installation
that you remove?

> let's look at vanilla bash-4.2:
> $ tar xf bash-4.2.tar.gz
> $ cd bash-4.2
> $ ./configure --disable-readline
> $ make
> ...
> rm -f complete.o
> ./mkbuiltins -D . complete.def
> gcc -c  -DHAVE_CONFIG_H -DSHELL  -I. -I..  -I.. -I../include -I../lib -I.    -g -O2 complete.c || ( rm -f complete.c ; exit 1 )
> rm -f complete.c
> ...
> 
> so, let's go into that dir and run it by hand:
> $ cd builtins
> $ ./mkbuiltins -D . complete.def
> $ strace -f -eopen gcc -c  -DHAVE_CONFIG_H -DSHELL  -I. -I..  -I.. -I../include -I../lib -I.    -g -O2 complete.c |& grep readline.h
> ...
> [pid 12453] open("../lib/readline/readline.h", O_RDONLY|O_NOCTTY) = 4
> ...
> 
> if you were to clean out your readline code first, you'd see the build error
> i'm seeing instead of the local readline code getting implicitly used even
> though it was explicitly disabled.

What does "clean out your readline code" mean?  Disabled means that it
doesn't end up in the resulting binary, and the bash binary is not linked
against readline.  There aren't any link errors because the builtins are
in a library, and no other bash code calls any function in complete.c, so
complete.o is not linked out of libbuiltins.a.  What kind of "build error"
are you seeing?

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


From MAILER-DAEMON Mon Apr 23 23:58:53 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMWtx-0004hq-JU
	for mharc-bug-bash@gnu.org; Mon, 23 Apr 2012 23:58:53 -0400
Received: from eggs.gnu.org ([208.118.235.92]:42609)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMWtu-0004gv-Cu
	for bug-bash@gnu.org; Mon, 23 Apr 2012 23:58:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMWts-0004C7-GM
	for bug-bash@gnu.org; Mon, 23 Apr 2012 23:58:49 -0400
Received: from smtp.gentoo.org ([140.211.166.183]:32806)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMWts-0004Bi-7k
	for bug-bash@gnu.org; Mon, 23 Apr 2012 23:58:48 -0400
Received: from vapier.localnet (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id A72CF1B401B;
	Tue, 24 Apr 2012 03:58:45 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: chet.ramey@case.edu
Subject: Re: [patch] fix building when readline is disabled
Date: Tue, 24 Apr 2012 00:00:13 -0400
User-Agent: KMail/1.13.7 (Linux/3.4.0-rc1; KDE/4.6.5; x86_64; ; )
References: <201204230022.23283.vapier@gentoo.org>
	<201204231940.54468.vapier@gentoo.org> <4F95EEFA.8020906@case.edu>
In-Reply-To: <4F95EEFA.8020906@case.edu>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart5514748.IJprMVcx25";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
Message-Id: <201204240000.14821.vapier@gentoo.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 140.211.166.183
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 24 Apr 2012 03:58:51 -0000

--nextPart5514748.IJprMVcx25
Content-Type: Text/Plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

On Monday 23 April 2012 20:08:26 Chet Ramey wrote:
> On 4/23/12 7:40 PM, Mike Frysinger wrote:
> > On Monday 23 April 2012 18:57:05 Chet Ramey wrote:
> >> On 4/23/12 12:22 AM, Mike Frysinger wrote:
> >>> if you disable readline, the complete.def code fails to build.  simple
> >>> patch below (not sure if it's correct, but at least gets the
> >>> conversation going).
> >>=20
> >> How did you disable readline?  Running configure --disable-readline and
> >> building as usual works for me.  You might want to run `make clean'
> >> before rebuilding.
> >=20
> > i suspect you have readline files still being included and it appears to
> > work.
>=20
> OK, so you've stripped the local readline copy out of the source tree?

yes

> Then configured it to build with a system readline library installation
> that you remove?

the system doesn't have readline at all

> > let's look at vanilla bash-4.2:
> > $ tar xf bash-4.2.tar.gz
> > $ cd bash-4.2
> > $ ./configure --disable-readline
> > $ make
> > ...
> > rm -f complete.o
> > ./mkbuiltins -D . complete.def
> > gcc -c  -DHAVE_CONFIG_H -DSHELL  -I. -I..  -I.. -I../include -I../lib -=
I.
> >    -g -O2 complete.c || ( rm -f complete.c ; exit 1 ) rm -f complete.c
> > ...
> >=20
> > so, let's go into that dir and run it by hand:
> > $ cd builtins
> > $ ./mkbuiltins -D . complete.def
> > $ strace -f -eopen gcc -c  -DHAVE_CONFIG_H -DSHELL  -I. -I..  -I..
> > -I../include -I../lib -I.    -g -O2 complete.c |& grep readline.h ...
> > [pid 12453] open("../lib/readline/readline.h", O_RDONLY|O_NOCTTY) =3D 4
> > ...
> >=20
> > if you were to clean out your readline code first, you'd see the build
> > error i'm seeing instead of the local readline code getting implicitly
> > used even though it was explicitly disabled.
>=20
> What does "clean out your readline code" mean?  Disabled means that it
> doesn't end up in the resulting binary, and the bash binary is not linked
> against readline.  There aren't any link errors because the builtins are
> in a library, and no other bash code calls any function in complete.c, so
> complete.o is not linked out of libbuiltins.a.  What kind of "build error"
> are you seeing?

without a readline.h header available (system or local copy), the build fai=
ls. =20
there's plenty of READLINE and HISTORY ifdefs in the other files, so this l=
ooks=20
like one place that got missed.  imo, there should be no attempts to includ=
e a=20
readline header if support is disabled.
=2Dmike

--nextPart5514748.IJprMVcx25
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJPliVOAAoJEEFjO5/oN/WBpSEP/105vn4HJ/EugMAKHoNbPq7S
V4kun31J2FhOVp80Z0mB2LVnL4qo3u4K/eM3ZoTSDMiGDGvB1h+WMkA7Izu8UvbE
83BOavOkj/B729hHSgAQcZEJj0Xj+GkgqRmUOCJ0CZVbuns6zdHLpYBoV8yEUUIW
PbsDos4uZwA/f7qOCOtCpv8RvXvUFov795yETcP1lyJBfGWnb2HHax1R9EYtnGBn
EveTE4J1jTncX9ot8p0SVJJWAKBAzEoEzZhTv6pACHlCyy3NkUkMlM9rX3bhlm82
TiffAu7MgEpjD8JtxS1Vsb7imU/4nwZsGyzidfhZVy4XfspweAfFF/OsFi7BJCqK
uBrEYv9jauOEGqzVIgXhfE+k99qzwK2ZU0wJr2lRJxRkcZHa+9H6XXpmszhKMt+v
+/340bpgr00iqQ2KsBCA8r1EvsTM0g0GVl2+ih18ZcZCIzuiGPjnjCjkJ6DKu8XW
U6fsRyAfSbHkgC7UXovn8vUjakMgnVs1BjS1vNWJrHsLf2t5iW5hAb0fV8j9EURY
q606+VaX5yWQ4jtdfaRWjonDYfqNS7YaSJ/a3U1MKwtPb7vZMmJR1HyjpK+QeEjF
7tPNYSoUSlTOgJdveT8YXdlODxqZio/dvBN/rcIW2orL+l4vpDyJz0iLttimDuKp
fODIhgJ6FTCGD9PnR9BH
=cNmZ
-----END PGP SIGNATURE-----

--nextPart5514748.IJprMVcx25--


From MAILER-DAEMON Tue Apr 24 04:24:12 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMb2i-0006oV-Cr
	for mharc-bug-bash@gnu.org; Tue, 24 Apr 2012 04:24:12 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39566)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jstcdr@gmail.com>) id 1SMb2b-0006o1-AD
	for bug-bash@gnu.org; Tue, 24 Apr 2012 04:24:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jstcdr@gmail.com>) id 1SMb2U-0006Xt-HM
	for bug-bash@gnu.org; Tue, 24 Apr 2012 04:24:04 -0400
Received: from mail-pb0-f41.google.com ([209.85.160.41]:53467)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jstcdr@gmail.com>) id 1SMb2U-0006Xj-5P
	for bug-bash@gnu.org; Tue, 24 Apr 2012 04:23:58 -0400
Received: by pbcup15 with SMTP id up15so4929434pbc.0
	for <bug-bash@gnu.org>; Tue, 24 Apr 2012 01:23:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=uDzl/KtYeCwfys1d1zbxuyAAnODqNUHfxLpY4zlJ1BQ=;
	b=KEzH3CQHiMpxDw8tf5smzZJM0Iv6LPKJLN4HHkh3J9GGH8489vTnebjidU4f4f7QLf
	t7VdxsU41x9GPRZzupg1A861fWtfFSzDoNVsrgqvmKUkyMmdDmlZ+h2cJ6lzSASRivvP
	9qPgS8YLxdxDBh35VlHhX/Kt7ITUBaNBzr3FmLwCMfV2x9uqYImuV1xRXjt7OpTxO5j7
	rtLSyJAlCH+FNQ0cIYWkYg/VgVntw2OYmXVDTvRn0ODubthVc9fucez0hpPLNbUM9IpI
	9zz3C9szTuai7vGGUp7XNrts1hve7HYa+EiH97DgNlfeRmoKkpamrK4N+1YbDE2N/4eI
	dAeA==
MIME-Version: 1.0
Received: by 10.68.220.232 with SMTP id pz8mr2293177pbc.87.1335255836162; Tue,
	24 Apr 2012 01:23:56 -0700 (PDT)
Received: by 10.68.74.7 with HTTP; Tue, 24 Apr 2012 01:23:55 -0700 (PDT)
In-Reply-To: <m2fwbuxui0.fsf@igel.home>
References: <CAEZVQT5PJ1Mb_Zh8LT5qz8sv+-9Q6hGfQ5DU9ZxdJ+gV7xBUaQ@mail.gmail.com>
	<20120423153754.GD22241@eeg.ccf.org> <m2fwbuxui0.fsf@igel.home>
Date: Tue, 24 Apr 2012 12:23:55 +0400
Message-ID: <CAEZVQT4egxxDRe67xp_+nJExwZXfs3VPpYDdO6zD6QgpXvpwxg@mail.gmail.com>
Subject: Re: Internal 'echo' command doesn't handle I/O errors on close file
From: Andrey Zaitsev <jstcdr@gmail.com>
To: Andreas Schwab <schwab@linux-m68k.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.160.41
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: Greg Wooledge <wooledg@eeg.ccf.org>, bug-bash@gnu.org, kirillx@gmail.com
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 24 Apr 2012 08:24:11 -0000

23 =C1=D0=D2=C5=CC=D1 2012 =C7. 20:50 =D0=CF=CC=D8=DA=CF=D7=C1=D4=C5=CC=D8 =
Andreas Schwab
<schwab@linux-m68k.org>=CE=C1=D0=C9=D3=C1=CC:

> Greg Wooledge <wooledg@eeg.ccf.org> writes:
>
> > On Mon, Apr 23, 2012 at 02:38:47PM +0400, Andrey Zaitsev wrote:
> >> Strace show that errors from /bin/bash were ignored:
> >>
> >> [user@host ~]# strace echo "bla-bla-bla" > /mnt/fs/out.txt
> >> execve("/bin/echo", ["echo", "bla-bla-bla"], [/* 22 vars */]) =3D 0
> >
> > If you want an strace of the internal echo, you have to do it this
> > way:
> >
> > # strace bash -c 'echo "bla-bla-bla" > /mnt/fs/out.txt'
> >
> > In fact it's the redirection whose failure you really care about.
>
> The redirection itself won't fail, unless the device is out of inodes.
>
> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint =3D 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED=
5
> "And now for something completely different."
>

>On Mon, Apr 23, 2012 at 06:50:31PM +0200, Andreas Schwab wrote:
>> The redirection itself won't fail, unless the device is out of inodes.
>Greg Wooledge wrote:
>Ah... OK, I can see how that might be the case.  Or depending on the
>file system implementation, it might fail if an additional block of
>disk space would need to be allocated to the directory to hold the
>new filename.  Which should be somewhat rare in practice.

Hello
This can occur often when target file placed on some networking file system
or on FUSE, or when used disk quota.

>From close's man:
      "Not  checking the return value of close() is a common but
nevertheless serious programming error.  It is quite possible that errors
on a previous write(2) operation are first reported at the final close().
Not checking the return value when closing the file may lead to silent loss
of data. This can especially be observed with NFS and with disk quota."

From MAILER-DAEMON Tue Apr 24 08:23:27 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMemE-0002Th-SK
	for mharc-bug-bash@gnu.org; Tue, 24 Apr 2012 08:23:26 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49797)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMem1-0001pB-Js
	for bug-bash@gnu.org; Tue, 24 Apr 2012 08:23:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMelv-0005ef-9R
	for bug-bash@gnu.org; Tue, 24 Apr 2012 08:23:13 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:15399)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMelv-0005eS-4b
	for bug-bash@gnu.org; Tue, 24 Apr 2012 08:23:07 -0400
Received: from mpv6.cwru.edu (mpv6.tis.CWRU.Edu [129.22.104.221])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKD11373;
	Tue, 24 Apr 2012 08:23:05 -0400
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWA45408 (AUTH cpr);
	Tue, 24 Apr 2012 08:23:05 -0400 (EDT)
Message-ID: <4F969B28.60203@case.edu>
Date: Tue, 24 Apr 2012 08:23:04 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Mike Frysinger <vapier@gentoo.org>
Subject: Re: [patch] fix building when readline is disabled
References: <201204230022.23283.vapier@gentoo.org>
	<201204231940.54468.vapier@gentoo.org> <4F95EEFA.8020906@case.edu>
	<201204240000.14821.vapier@gentoo.org>
In-Reply-To: <201204240000.14821.vapier@gentoo.org>
X-Enigmail-Version: 1.4.1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 24 Apr 2012 12:23:23 -0000

On 4/24/12 12:00 AM, Mike Frysinger wrote:

>> OK, so you've stripped the local readline copy out of the source tree?
> 
> yes
> 
>> Then configured it to build with a system readline library installation
>> that you remove?
> 
> the system doesn't have readline at all

Why?

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


From MAILER-DAEMON Tue Apr 24 10:45:08 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMgzM-0001Wu-Pt
	for mharc-bug-bash@gnu.org; Tue, 24 Apr 2012 10:45:08 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58426)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMgzE-00018h-8a
	for bug-bash@gnu.org; Tue, 24 Apr 2012 10:45:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMgz6-0003He-Lm
	for bug-bash@gnu.org; Tue, 24 Apr 2012 10:44:59 -0400
Received: from smtp.gentoo.org ([140.211.166.183]:57084)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SMgz6-0003Ch-AC
	for bug-bash@gnu.org; Tue, 24 Apr 2012 10:44:52 -0400
Received: from vapier.localnet (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id 2F3101B4024;
	Tue, 24 Apr 2012 14:44:49 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: chet.ramey@case.edu
Subject: Re: [patch] fix building when readline is disabled
Date: Tue, 24 Apr 2012 10:46:20 -0400
User-Agent: KMail/1.13.7 (Linux/3.4.0-rc1; KDE/4.6.5; x86_64; ; )
References: <201204230022.23283.vapier@gentoo.org>
	<201204240000.14821.vapier@gentoo.org> <4F969B28.60203@case.edu>
In-Reply-To: <4F969B28.60203@case.edu>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart2653619.cVUqokoTXB";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
Message-Id: <201204241046.21558.vapier@gentoo.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 140.211.166.183
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 24 Apr 2012 14:45:06 -0000

--nextPart2653619.cVUqokoTXB
Content-Type: Text/Plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

On Tuesday 24 April 2012 08:23:04 Chet Ramey wrote:
> On 4/24/12 12:00 AM, Mike Frysinger wrote:
> >> OK, so you've stripped the local readline copy out of the source tree?
> >=20
> > yes
> >=20
> >> Then configured it to build with a system readline library installation
> >> that you remove?
> >=20
> > the system doesn't have readline at all
>=20
> Why?

because it's a small system which has no need for things like readline.  i=
=20
don't think this is a terribly unusual use case.
=2Dmike

--nextPart2653619.cVUqokoTXB
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJPlry9AAoJEEFjO5/oN/WBMIwP/RV3nLwf2dRdx26y4qz4j3FZ
xkdAMxqe8lA+xrdtSyXyCUqkZH0RYPDO98MdoNwVchR3BryH8x7Un4QcGR11rDyK
8OWpeGhhhU7e7qpzAhqJ8DTrkmsxpcBdXYPlfwZiUXQJZDxS0UA+9GH4v0ZZhN7p
nifYP4QfGqj6fP3ab/KzupfMoqschpn3VRS/f4i1bsxBaIX8IX6sMx6rGFEsbRUi
dm5i/Mdt6z1Fx66hAK5ZWMSVthwhPBrW8Dmn45svnuSkBmGsCvl8vaOLvCRbTRqG
N0UhPh+dJYJnjLgJxDVrDiM3sVnxz52u9DgmIXPgrs9QT24EyqYxxhUqtq6KOMxK
nNxhKbeORz8tUv9zWPCP1/TwpveMp/n8gXei4OXTG3WEVyoCp43MURZuR2JSlZd5
P6pGddKxeMfOAZVW5xiKmU2n3RDfH24koZLLHxZWgH3XpNMpzuNozJAjMMMiCymX
UjwYGVp8D9NjxYSrH6uYBE5B6/tIEhYM0xQ9uvt9+Hxc3phT7i/H/qe346BEzbJ0
Ws8jgu1jPq/IH3hnxLsoqiF8MgSy8+04YJRw4ZTziiibATpWFTA4pxJKXZKzo2Lm
1BoQOag6/hzdZ1h4qHBHpDA84YH/bH+dGSAP9HhX//2NiRqDSblb8SDlXehbpBHN
wzVbxwpC4xRibzHZ5sIi
=WsGA
-----END PGP SIGNATURE-----

--nextPart2653619.cVUqokoTXB--


From MAILER-DAEMON Tue Apr 24 15:50:05 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMlkT-00074n-LZ
	for mharc-bug-bash@gnu.org; Tue, 24 Apr 2012 15:50:05 -0400
Received: from eggs.gnu.org ([208.118.235.92]:35835)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMlkQ-00072O-9E
	for bug-bash@gnu.org; Tue, 24 Apr 2012 15:50:03 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMlkO-000239-7O
	for bug-bash@gnu.org; Tue, 24 Apr 2012 15:50:01 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:7105)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMlkO-00022o-3E
	for bug-bash@gnu.org; Tue, 24 Apr 2012 15:50:00 -0400
Received: from mpv6.cwru.edu (mpv6.tis.CWRU.Edu [129.22.104.221])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKD59509;
	Tue, 24 Apr 2012 15:49:57 -0400
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWB23115 (AUTH cpr);
	Tue, 24 Apr 2012 15:49:57 -0400 (EDT)
Message-ID: <4F9703E5.5030004@case.edu>
Date: Tue, 24 Apr 2012 15:49:57 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Mike Frysinger <vapier@gentoo.org>
Subject: Re: [patch] fix building when readline is disabled
References: <201204230022.23283.vapier@gentoo.org>
	<201204240000.14821.vapier@gentoo.org> <4F969B28.60203@case.edu>
	<201204241046.21558.vapier@gentoo.org>
In-Reply-To: <201204241046.21558.vapier@gentoo.org>
X-Enigmail-Version: 1.4.1
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 24 Apr 2012 19:50:03 -0000

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

On 4/24/12 10:46 AM, Mike Frysinger wrote:
> On Tuesday 24 April 2012 08:23:04 Chet Ramey wrote:
>> On 4/24/12 12:00 AM, Mike Frysinger wrote:
>>>> OK, so you've stripped the local readline copy out of the source tree?
>>>
>>> yes
>>>
>>>> Then configured it to build with a system readline library installation
>>>> that you remove?
>>>
>>> the system doesn't have readline at all
>>
>> Why?
> 
> because it's a small system which has no need for things like readline.  i 
> don't think this is a terribly unusual use case.

Sure, there are systems that don't want or need the readline library
installed or things linked to it.  That's not unusual.  It's not what
we're talking about here.

What we're talking about is removing about 1 MB of source code
(lib/readline) from the bash source tree *wherever you're building it*.
This doesn't have anything to do with readline being built or installed.
I don't have any doubt that you encountered a build error when you removed
lib/readline from the bash source tree.  What I'm wondering is what you
thought you would gain by doing it.

Chet
- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+XA+UACgkQu1hp8GTqdKuspgCfUVItQ7qYcjqv8WrJFyAcfE1v
BWwAn08gbn+b6gbUigVCfTgm5hiMATtA
=8/xm
-----END PGP SIGNATURE-----


From MAILER-DAEMON Tue Apr 24 20:49:28 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMqQC-0001tG-DW
	for mharc-bug-bash@gnu.org; Tue, 24 Apr 2012 20:49:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37529)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMqQ8-0001su-GT
	for bug-bash@gnu.org; Tue, 24 Apr 2012 20:49:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMqQ6-0004sW-ER
	for bug-bash@gnu.org; Tue, 24 Apr 2012 20:49:24 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:17463)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SMqQ6-0004lb-9Q
	for bug-bash@gnu.org; Tue, 24 Apr 2012 20:49:22 -0400
Received: from mpv7.tis.cwru.edu (EHLO mpv7.case.edu) ([129.22.104.170])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXZ18380 (AUTH cpr);
	Tue, 24 Apr 2012 20:49:20 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TLI86209 (AUTH cpr);
	Tue, 24 Apr 2012 20:49:20 -0400 (EDT)
Message-ID: <4F974A0E.60806@case.edu>
Date: Tue, 24 Apr 2012 20:49:18 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Andrey Zaitsev <jstcdr@gmail.com>
Subject: Re: Internal 'echo' command doesn't handle I/O errors on close file
References: <CAEZVQT5PJ1Mb_Zh8LT5qz8sv+-9Q6hGfQ5DU9ZxdJ+gV7xBUaQ@mail.gmail.com>
In-Reply-To: <CAEZVQT5PJ1Mb_Zh8LT5qz8sv+-9Q6hGfQ5DU9ZxdJ+gV7xBUaQ@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: multipart/mixed; boundary="------------020300070808070801060807"
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 25 Apr 2012 00:49:26 -0000

This is a multi-part message in MIME format.
--------------020300070808070801060807
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On 4/23/12 6:38 AM, Andrey Zaitsev wrote:

> Bash Version: 4.1
> Patch Level: 2
> Release Status: release
> 
> Description:
> Internal 'echo' command doesn't handle I/O errors on close file when I try
> redirect
> standart output to mounted filesystem without free space.

This is hard for me to test, but see if the attached patch provides the
behavior you'd like.

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

--------------020300070808070801060807
Content-Type: text/x-patch;
 name="redir-close.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="redir-close.patch"

*** ../bash-4.2-patched/redir.c	2011-01-02 16:00:31.000000000 -0500
--- redir.c	2012-04-24 20:42:12.000000000 -0400
***************
*** 1092,1099 ****
  #if defined (BUFFERED_INPUT)
  	  check_bash_input (redirector);
! 	  close_buffered_fd (redirector);
  #else /* !BUFFERED_INPUT */
! 	  close (redirector);
  #endif /* !BUFFERED_INPUT */
  	}
        break;
--- 1092,1101 ----
  #if defined (BUFFERED_INPUT)
  	  check_bash_input (redirector);
! 	  r = close_buffered_fd (redirector);
  #else /* !BUFFERED_INPUT */
! 	  r = close (redirector);
  #endif /* !BUFFERED_INPUT */
+ 	  if (r < 0 && (flags & RX_INTERNAL) && (errno == EIO || errno == ENOSPC))
+ 	    REDIRECTION_ERROR (r, errno, -1);
  	}
        break;

--------------020300070808070801060807--



From MAILER-DAEMON Wed Apr 25 00:25:36 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMtnM-0004mk-Hi
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 00:25:36 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48108)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tedokuzumi@gmail.com>) id 1SMp2k-0003oE-Ny
	for bug-bash@gnu.org; Tue, 24 Apr 2012 19:21:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <tedokuzumi@gmail.com>) id 1SMp2i-0001or-L5
	for bug-bash@gnu.org; Tue, 24 Apr 2012 19:21:10 -0400
Received: from mail-wi0-f177.google.com ([209.85.212.177]:41200)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tedokuzumi@gmail.com>) id 1SMp2i-0001oZ-9R
	for bug-bash@gnu.org; Tue, 24 Apr 2012 19:21:08 -0400
Received: by wibhj13 with SMTP id hj13so983552wib.12
	for <bug-bash@gnu.org>; Tue, 24 Apr 2012 16:21:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=sBVaJXNYLG8Of4I7hzYGg51a39xkeKGZRDTJhNQIfpw=;
	b=neA7mXmGaL+QbFrmuF6Jx1RgC5FIeJ0/T8ugTdThIwLfU+xQ6JWQU+VvAXxe4I+ZSW
	YL8+dgEfUBxkL78di3RQkwdLDQaKfkEaX9UHq1VNNVroge3PvSt1dWmLi3kF5G6D+Xr0
	WE7zlz3rlVdfsxoNuY/UdAeGC7Cv1wyZ6uZkkq1vKjqT7CDcPKgxJbAQFpKHlDfIKZFx
	uthNj9yOZVofc+9QixIiP4+jjpF0w2K4Ndof9FRx+YKFDD2i4Q7q/jrqFZqh9vJ9rx50
	4+48HAwiRI3WWNivqFQoHN4r17F9u+hX8ZVaUOwsv9grb3mJ7Tq3goaP485EGmmEUpC2
	af0g==
MIME-Version: 1.0
Received: by 10.216.132.169 with SMTP id o41mr167654wei.121.1335309665901;
	Tue, 24 Apr 2012 16:21:05 -0700 (PDT)
Received: by 10.180.85.40 with HTTP; Tue, 24 Apr 2012 16:21:05 -0700 (PDT)
Date: Tue, 24 Apr 2012 16:21:05 -0700
Message-ID: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
Subject: Severe Bash Bug with Arrays
From: Ted Okuzumi <tedokuzumi@gmail.com>
To: bug-bash@gnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.212.177
X-Mailman-Approved-At: Wed, 25 Apr 2012 00:25:35 -0400
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 24 Apr 2012 23:21:12 -0000

I am writing this e-mai to report to report a bug in bash.

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-unknown-linux-gnu'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib
-g \
-O2
uname output: Linux concour5 2.6.18-274.3.1.el5xen #1 SMP Tue Sep 6
20:57:11 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.2
Patch Level: 0
Release Status: release

Description:
        Cannot redirect into an array from multiline variable

Does not work:
echo "$mydata" | while read line; do myarray+=( "$line" ); done


Works:
while read -r line; do myarray+=( "$line" ); done < <(echo "$mydata")


Repeat-By:
Here is exact code that shows the bug.  I create a multiline variable

mydata="aaa aaaa aaaaa
bbb bbbb bbbbb
ccc cccc ccccc"

Trying to place the file into an array fails.
Technique 1)
echo "$mydata" | while read -r line; do myarray+=( "$line" ); done

This fails.  It should work but doesn't.  This is a bug in bash.

Fix:

Technique 2)
while read -r line; do myarray+=( "$line" ); done < <(echo "$mydata")

This works

Technique 3)
Create a file foo
echo "$mydata" > foo
while read -r line; do myarray+=( "$line" ); done < foo

This works, but requires using external files which is undesired.

You can view what is in the array with this command:
echo "${myarray[@]}"

Please let me know if I can provide any more information about the bug.  It
is easily reproducible with the code I have included.


For your convenience, here is a little script which summarizes the above.

#! /bin/bash

#First creating a multiline data file
mydata="aaa aaaa aaaaa
bbb bbbb bbbbb
ccc cccc ccccc"

# Populating the Array with mydata using technique 1
echo "Poplulating the Array using technique 1"
unset myarray
echo "$mydata" | while read -r line; do myarray+=( "$line" ); done
echo "${myarray[@]}"
# THERE IS NO OUTPUT.  THIS IS A BUG WITH BASH

read -n1 -r -p "Press any key to continue..." key ; echo ""


# Poplulating the Array with mydata using technique 2
echo "Poplulating the Array using technique 2"
unset myarray
while read -r line; do myarray+=( "$line" ); done < <(echo "$mydata")
echo "${myarray[@]}"
# This works

read -n1 -r -p "Press any key to continue..." key ; echo ""

# Poplulating the Array with mydata using technique 3
echo "Poplulating the Array using technique 3"
echo "$mydata" > foo
unset myarray
while read -r line; do myarray+=( "$line" ); done < foo
rm foo
echo "${myarray[@]}"
# This works but requires using files, which is undesired

From MAILER-DAEMON Wed Apr 25 01:23:52 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMuhk-00079T-OG
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 01:23:52 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34570)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SMuhh-00079K-DR
	for bug-bash@gnu.org; Wed, 25 Apr 2012 01:23:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SMuhf-0005Eg-99
	for bug-bash@gnu.org; Wed, 25 Apr 2012 01:23:48 -0400
Received: from acsinet15.oracle.com ([141.146.126.227]:30195)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SMuhf-0005EX-2L
	for bug-bash@gnu.org; Wed, 25 Apr 2012 01:23:47 -0400
Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94])
	by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with
	ESMTP id q3P5NepJ018690
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 05:23:40 GMT
Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156])
	by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
	q3P5NdOt018265
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 05:23:39 GMT
Received: from abhmt113.oracle.com (abhmt113.oracle.com [141.146.116.65])
	by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id
	q3P5Ndx2004900
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 00:23:39 -0500
Received: from mail-ob0-f169.google.com (/209.85.214.169)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Tue, 24 Apr 2012 22:23:38 -0700
Received: by obbeh20 with SMTP id eh20so2350276obb.0
	for <bug-bash@gnu.org>; Tue, 24 Apr 2012 22:23:38 -0700 (PDT)
Received: by 10.182.232.38 with SMTP id tl6mr1725267obc.16.1335331418516; Tue,
	24 Apr 2012 22:23:38 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.182.75.37 with HTTP; Tue, 24 Apr 2012 22:23:18 -0700 (PDT)
In-Reply-To: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
From: Clark Wang <clark.wang@oracle.com>
Date: Wed, 25 Apr 2012 13:23:18 +0800
Message-ID: <CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
Subject: Re: Severe Bash Bug with Arrays
To: Ted Okuzumi <tedokuzumi@gmail.com>
X-Source-IP: ucsinet22.oracle.com [156.151.31.94]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1)
X-Received-From: 141.146.126.227
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 05:23:51 -0000

On Wed, Apr 25, 2012 at 07:21, Ted Okuzumi <tedokuzumi@gmail.com> wrote:

> I am writing this e-mai to report to report a bug in bash.
>
> 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-unknown-linux-gnu'
> -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale'
> -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib
> -g \
> -O2
> uname output: Linux concour5 2.6.18-274.3.1.el5xen #1 SMP Tue Sep 6
> 20:57:11 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-unknown-linux-gnu
>
> Bash Version: 4.2
> Patch Level: 0
> Release Status: release
>
> Description:
>        Cannot redirect into an array from multiline variable
>
> Does not work:
> echo "$mydata" | while read line; do myarray+=( "$line" ); done
>

Here the whole *while* statement runs in a subshell. See
http://mywiki.wooledge.org/BashPitfalls#grep_foo_bar_.7C_while_read_-r.3B_do_.28.28count.2B-.2B-.29.29.3B_done.

>
>
> Works:
> while read -r line; do myarray+=( "$line" ); done < <(echo "$mydata")
>
>

From MAILER-DAEMON Wed Apr 25 10:48:22 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN3W2-0006qI-2O
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 10:48:22 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48495)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN3Vu-0006pN-IX
	for bug-bash@gnu.org; Wed, 25 Apr 2012 10:48:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN3Vp-000821-KY
	for bug-bash@gnu.org; Wed, 25 Apr 2012 10:48:14 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:21741)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN3Vp-00081W-9n
	for bug-bash@gnu.org; Wed, 25 Apr 2012 10:48:09 -0400
Received: from mpv6.cwru.edu (mpv6.tis.CWRU.Edu [129.22.104.221])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKD97559;
	Wed, 25 Apr 2012 08:40:11 -0400
Received: from casewireless02.CWRU.Edu (EHLO z4.local) ([129.22.1.18])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWB79668 (AUTH cpr);
	Wed, 25 Apr 2012 08:40:11 -0400 (EDT)
Message-ID: <4F97F0AB.5050901@case.edu>
Date: Wed, 25 Apr 2012 08:40:11 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Ted Okuzumi <tedokuzumi@gmail.com>
Subject: Re: Severe Bash Bug with Arrays
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
In-Reply-To: <CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: Clark Wang <clark.wang@oracle.com>, bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 25 Apr 2012 14:48:20 -0000

On 4/25/12 1:23 AM, Clark Wang wrote:

>> Bash Version: 4.2
>> Patch Level: 0
>> Release Status: release
>>
>> Description:
>>        Cannot redirect into an array from multiline variable
>>
>> Does not work:
>> echo "$mydata" | while read line; do myarray+=( "$line" ); done
>>
> 
> Here the whole *while* statement runs in a subshell. See
> http://mywiki.wooledge.org/BashPitfalls#grep_foo_bar_.7C_while_read_-r.3B_do_.28.28count.2B-.2B-.29.29.3B_done.

Since you're using bash-4.2, you can experiment with the `lastpipe' shopt
option.  If that's enabled, bash runs the last element of a pipeline in
the parent shell context without creating a subshell.

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


From MAILER-DAEMON Wed Apr 25 10:55:47 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN3dD-00012D-Q7
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 10:55:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52146)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN3d6-000108-6h
	for bug-bash@gnu.org; Wed, 25 Apr 2012 10:55:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN3d1-0003B4-Fu
	for bug-bash@gnu.org; Wed, 25 Apr 2012 10:55:39 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45174
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN3d1-000318-8m
	for bug-bash@gnu.org; Wed, 25 Apr 2012 10:55:35 -0400
Received: (qmail 8505 invoked from network); 25 Apr 2012 14:55:10 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 25 Apr 2012 10:55:10 -0400
Received: (qmail 1987 invoked by uid 563); 25 Apr 2012 14:55:10 -0000
Date: Wed, 25 Apr 2012 10:55:10 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120425145510.GJ22241@eeg.ccf.org>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F97F0AB.5050901@case.edu>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 14:55:46 -0000

On Wed, Apr 25, 2012 at 08:40:11AM -0400, Chet Ramey wrote:
> Since you're using bash-4.2, you can experiment with the `lastpipe' shopt
> option.  If that's enabled, bash runs the last element of a pipeline in
> the parent shell context without creating a subshell.

I actually started writing a response that mentioned that, but when I
was testing it, it didn't seem to work.

The manual says job control has to be off, so I did it as a script:

imadev:~$ cat foo
#!/bin/bash
set +m
shopt -s lastpipe
echo hi | read foo
echo "<$foo>"
printf '%s\n' some words | while read -r line; do myarray+=("$line"); done
printf '<%s> ' "${myarray[@]}"; echo
imadev:~$ ./foo
<>
<> 
imadev:~$ /bin/bash -c 'echo $BASH_VERSION'
4.2.20(8)-release

This is the first time I've ever attempted to use lastpipe, so I'm not
sure what's wrong.


From MAILER-DAEMON Wed Apr 25 11:08:10 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN3pC-00045g-F1
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 11:08:10 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37442)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN3p9-00045L-KE
	for bug-bash@gnu.org; Wed, 25 Apr 2012 11:08:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN3p1-0007wO-Hz
	for bug-bash@gnu.org; Wed, 25 Apr 2012 11:08:07 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:32874)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN3p1-0007wG-Cy
	for bug-bash@gnu.org; Wed, 25 Apr 2012 11:07:59 -0400
Received: from mpv6.tis.CWRU.Edu (EHLO mpv6.cwru.edu) ([129.22.104.221])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXZ58280; Wed, 25 Apr 2012 11:07:57 -0400 (EDT)
Received: from casewireless02.CWRU.Edu (EHLO z4.local) ([129.22.1.18])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWC05100 (AUTH cpr);
	Wed, 25 Apr 2012 11:07:57 -0400 (EDT)
Message-ID: <4F98134D.9040109@case.edu>
Date: Wed, 25 Apr 2012 11:07:57 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: Severe Bash Bug with Arrays
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu> <20120425145510.GJ22241@eeg.ccf.org>
In-Reply-To: <20120425145510.GJ22241@eeg.ccf.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, Chet Ramey <chet.ramey@case.edu>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 25 Apr 2012 15:08:09 -0000

On 4/25/12 10:55 AM, Greg Wooledge wrote:
> On Wed, Apr 25, 2012 at 08:40:11AM -0400, Chet Ramey wrote:
>> Since you're using bash-4.2, you can experiment with the `lastpipe' shopt
>> option.  If that's enabled, bash runs the last element of a pipeline in
>> the parent shell context without creating a subshell.
> 
> I actually started writing a response that mentioned that, but when I
> was testing it, it didn't seem to work.
> 
> The manual says job control has to be off, so I did it as a script:
> 
> imadev:~$ cat foo
> #!/bin/bash
> set +m
> shopt -s lastpipe
> echo hi | read foo
> echo "<$foo>"

z4.local(1)$ cat x3
#! ../bash-4.2-patched/bash
shopt -s lastpipe

echo foo | read bar
echo $bar
z4.local(1)$ ../bash-4.2-patched/bash -c 'echo $BASH_VERSION'
4.2.24(9)-release
z4.local(1)$ ../bash-4.2-patched/bash ./x3
foo
z4.local(1)$ ./x3
foo

The set +m doesn't matter, since scripts do not have job control enabled
by default.  Adding it doesn't change the behavior.

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


From MAILER-DAEMON Wed Apr 25 11:28:01 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN48P-00044i-89
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 11:28:01 -0400
Received: from eggs.gnu.org ([208.118.235.92]:38364)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN480-0003gb-Pw
	for bug-bash@gnu.org; Wed, 25 Apr 2012 11:27:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN47Y-0008K9-OW
	for bug-bash@gnu.org; Wed, 25 Apr 2012 11:27:36 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45189
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN47Y-0008HO-Hc
	for bug-bash@gnu.org; Wed, 25 Apr 2012 11:27:08 -0400
Received: (qmail 8883 invoked from network); 25 Apr 2012 15:27:04 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 25 Apr 2012 11:27:04 -0400
Received: (qmail 2245 invoked by uid 563); 25 Apr 2012 15:27:03 -0000
Date: Wed, 25 Apr 2012 11:27:03 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120425152703.GK22241@eeg.ccf.org>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu> <20120425145510.GJ22241@eeg.ccf.org>
	<4F98134D.9040109@case.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F98134D.9040109@case.edu>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 15:27:59 -0000

On Wed, Apr 25, 2012 at 11:07:57AM -0400, Chet Ramey wrote:
> z4.local(1)$ ../bash-4.2-patched/bash -c 'echo $BASH_VERSION'
> 4.2.24(9)-release
> z4.local(1)$ ../bash-4.2-patched/bash ./x3
> foo
> z4.local(1)$ ./x3
> foo

I grabbed patches 21-24 and applied them.  No change.

imadev:/var/tmp/bash/bash-4.2$ cat ~/foo
#!/bin/bash
shopt -s lastpipe
echo hi | read foo
echo "<$foo>"
imadev:/var/tmp/bash/bash-4.2$ ./bash -c 'echo $BASH_VERSION'
4.2.24(9)-release
imadev:/var/tmp/bash/bash-4.2$ ./bash ~/foo
<>


From MAILER-DAEMON Wed Apr 25 12:15:51 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN4sh-000527-Dr
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 12:15:51 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41357)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN4sb-00051f-JA
	for bug-bash@gnu.org; Wed, 25 Apr 2012 12:15:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN4sV-0004WF-8Q
	for bug-bash@gnu.org; Wed, 25 Apr 2012 12:15:45 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:36222)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN4sV-0004UW-4Y
	for bug-bash@gnu.org; Wed, 25 Apr 2012 12:15:39 -0400
Received: from mpv6.cwru.edu (mpv6.tis.CWRU.Edu [129.22.104.221])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKE21033;
	Wed, 25 Apr 2012 12:15:37 -0400
Received: from casewireless02.CWRU.Edu (EHLO z4.local) ([129.22.1.18])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWC16019 (AUTH cpr);
	Wed, 25 Apr 2012 12:15:37 -0400 (EDT)
Message-ID: <4F982328.0@case.edu>
Date: Wed, 25 Apr 2012 12:15:36 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: Severe Bash Bug with Arrays
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu> <20120425145510.GJ22241@eeg.ccf.org>
	<4F98134D.9040109@case.edu> <20120425152703.GK22241@eeg.ccf.org>
In-Reply-To: <20120425152703.GK22241@eeg.ccf.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, Chet Ramey <chet.ramey@case.edu>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 25 Apr 2012 16:15:49 -0000

On 4/25/12 11:27 AM, Greg Wooledge wrote:
> On Wed, Apr 25, 2012 at 11:07:57AM -0400, Chet Ramey wrote:
>> z4.local(1)$ ../bash-4.2-patched/bash -c 'echo $BASH_VERSION'
>> 4.2.24(9)-release
>> z4.local(1)$ ../bash-4.2-patched/bash ./x3
>> foo
>> z4.local(1)$ ./x3
>> foo
> 
> I grabbed patches 21-24 and applied them.  No change.

OK.  I get the same working behavior on Mac OS X, Solaris 8/10, RHEL 5,
BSD/OS (old), and Fedora 15.  I'm not sure what to tell you.

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


From MAILER-DAEMON Wed Apr 25 12:26:31 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN531-0001oY-N3
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 12:26:31 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41759)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrakus@redhat.com>) id 1SN52v-0001o1-5a
	for bug-bash@gnu.org; Wed, 25 Apr 2012 12:26:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <rrakus@redhat.com>) id 1SN52s-0000Pv-Dh
	for bug-bash@gnu.org; Wed, 25 Apr 2012 12:26:24 -0400
Received: from mx1.redhat.com ([209.132.183.28]:2083)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rrakus@redhat.com>) id 1SN52s-0000PU-5N
	for bug-bash@gnu.org; Wed, 25 Apr 2012 12:26:22 -0400
Received: from int-mx02.intmail.prod.int.phx2.redhat.com
	(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3PGQKum030579
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 12:26:20 -0400
Received: from dhcp-25-98.brq.redhat.com (dhcp-25-98.brq.redhat.com
	[10.34.25.98])
	by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
	id q3PGQJuI009560
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 12:26:19 -0400
Message-ID: <4F9825AA.3060109@redhat.com>
Date: Wed, 25 Apr 2012 18:26:18 +0200
From: Roman Rakus <rrakus@redhat.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:11.0) Gecko/20120329 Thunderbird/11.0.1
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: Severe Bash Bug with Arrays
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu> <20120425145510.GJ22241@eeg.ccf.org>
	<4F98134D.9040109@case.edu>
	<20120425152703.GK22241@eeg.ccf.org> <4F982328.0@case.edu>
In-Reply-To: <4F982328.0@case.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.132.183.28
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 16:26:31 -0000

On 04/25/2012 06:15 PM, Chet Ramey wrote:
> On 4/25/12 11:27 AM, Greg Wooledge wrote:
>> On Wed, Apr 25, 2012 at 11:07:57AM -0400, Chet Ramey wrote:
>>> z4.local(1)$ ../bash-4.2-patched/bash -c 'echo $BASH_VERSION'
>>> 4.2.24(9)-release
>>> z4.local(1)$ ../bash-4.2-patched/bash ./x3
>>> foo
>>> z4.local(1)$ ./x3
>>> foo
>> I grabbed patches 21-24 and applied them.  No change.
> OK.  I get the same working behavior on Mac OS X, Solaris 8/10, RHEL 5,
> BSD/OS (old), and Fedora 15.  I'm not sure what to tell you.
>
> Chet
On Fedora 16 it works as expected.
$ rpm -q bash
bash-4.2.24-1.fc16.x86_64

RR


From MAILER-DAEMON Wed Apr 25 12:55:25 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN5Uz-0000gF-GJ
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 12:55:25 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55511)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN5Us-0000fD-Hb
	for bug-bash@gnu.org; Wed, 25 Apr 2012 12:55:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN5Uo-0003mU-IB
	for bug-bash@gnu.org; Wed, 25 Apr 2012 12:55:18 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45238
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN5Uo-0003lt-BU
	for bug-bash@gnu.org; Wed, 25 Apr 2012 12:55:14 -0400
Received: (qmail 9620 invoked from network); 25 Apr 2012 16:55:09 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 25 Apr 2012 12:55:08 -0400
Received: (qmail 2369 invoked by uid 563); 25 Apr 2012 16:55:06 -0000
Date: Wed, 25 Apr 2012 12:55:06 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: bug-bash@gnu.org
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120425165506.GL22241@eeg.ccf.org>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu> <20120425145510.GJ22241@eeg.ccf.org>
	<4F98134D.9040109@case.edu>
	<20120425152703.GK22241@eeg.ccf.org> <4F982328.0@case.edu>
	<4F9825AA.3060109@redhat.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F9825AA.3060109@redhat.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 16:55:24 -0000

On Wed, Apr 25, 2012 at 06:26:18PM +0200, Roman Rakus wrote:
> On 04/25/2012 06:15 PM, Chet Ramey wrote:
> >OK.  I get the same working behavior on Mac OS X, Solaris 8/10, RHEL 5,
> >BSD/OS (old), and Fedora 15.  I'm not sure what to tell you.

> On Fedora 16 it works as expected.
> $ rpm -q bash
> bash-4.2.24-1.fc16.x86_64

It fails on HP-UX 10.20 in bash 4.2.20 and 4.2.24 (from source).
It also fails on OpenBSD 5.0 using bash 4.2.10 from ports.  Since those
are the first two cases I tried, I was quite puzzled.

It works on Debian 6.0 in bash 4.2.10 (from source), which I just happened
to have lying around.  So far everyone has reported success on any Linux
system, so that doesn't surprise me.


From MAILER-DAEMON Wed Apr 25 13:10:44 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN5jo-000594-CD
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 13:10:44 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58229)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN5ji-00058C-7J
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:10:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN5jd-0000tb-Hq
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:10:37 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45241
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN5jd-0000tL-B3
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:10:33 -0400
Received: (qmail 9710 invoked from network); 25 Apr 2012 17:10:30 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 25 Apr 2012 13:10:30 -0400
Received: (qmail 2415 invoked by uid 563); 25 Apr 2012 17:10:30 -0000
Date: Wed, 25 Apr 2012 13:10:30 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: bug-bash@gnu.org
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120425171030.GM22241@eeg.ccf.org>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu> <20120425145510.GJ22241@eeg.ccf.org>
	<4F98134D.9040109@case.edu>
	<20120425152703.GK22241@eeg.ccf.org> <4F982328.0@case.edu>
	<4F9825AA.3060109@redhat.com> <20120425165506.GL22241@eeg.ccf.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20120425165506.GL22241@eeg.ccf.org>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 17:10:43 -0000

On Wed, Apr 25, 2012 at 12:55:06PM -0400, Greg Wooledge wrote:
> It also fails on OpenBSD 5.0 using bash 4.2.10 from ports.

And it also fails on OpenBSD 5.0 using bash 4.2.24 straight from the
original sources.

cyclops:/var/tmp/bash/bash-4.2$ ./bash -c 'echo $BASH_VERSION'
4.2.24(1)-release
cyclops:/var/tmp/bash/bash-4.2$ cat ~/foo
#!/bin/bash
shopt -s lastpipe
echo hi | read foo
echo "<$foo>"
cyclops:/var/tmp/bash/bash-4.2$ ./bash ~/foo
<>
cyclops:/var/tmp/bash/bash-4.2$ uname -a
OpenBSD cyclops.wooledge.org 5.0 GENERIC.MP#63 amd64


From MAILER-DAEMON Wed Apr 25 13:11:15 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN5kJ-0005NC-HO
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 13:11:15 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58301)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN5kG-0005MA-Gh
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:11:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN5kE-0000vu-7R
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:11:12 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:39409)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN5kE-0000vh-1i
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:11:10 -0400
Received: from mpv6.cwru.edu (mpv6.tis.CWRU.Edu [129.22.104.221])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKE25988;
	Wed, 25 Apr 2012 13:11:08 -0400
Received: from casewireless02.CWRU.Edu (EHLO z4.local) ([129.22.1.18])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWC24246 (AUTH cpr);
	Wed, 25 Apr 2012 13:11:08 -0400 (EDT)
Message-ID: <4F98302B.8090905@case.edu>
Date: Wed, 25 Apr 2012 13:11:07 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Artur Rataj <arturrataj@gmail.com>
Subject: Re: Directory completion problems
References: <CACO3_sB-R3yo9+6Stw=aJYwoFaLi_kkCVAN4jDY3WcxM24Zbgg@mail.gmail.com>
	<CACO3_sAq95kv4k6LUphuPOkFtA2GLQYV67VOhg8Fk7Xq7Q+2sA@mail.gmail.com>
	<4F8FF6A5.1060301@redhat.com>
	<CACO3_sAEttH522NAxar8xLpK9H9MQimJpiHoR7O-0fHvqgptuQ@mail.gmail.com>
	<4F9005E0.2090006@case.edu>
	<CACO3_sA2s6ou+wfht+ssL6zNR_tPhKC-zEEVS9xm_M_1iVPWww@mail.gmail.com>
	<CACO3_sAeOHdY2XDUqJ=6Cz0n8eWCZP8W8WVPgMFx++hkeKjETg@mail.gmail.com>
	<4F946FB7.50807@case.edu>
	<CACO3_sDbj7LV_00Q7HkZykbhg++DC0memQw1rjRW+4R91J9KNg@mail.gmail.com>
In-Reply-To: <CACO3_sDbj7LV_00Q7HkZykbhg++DC0memQw1rjRW+4R91J9KNg@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 25 Apr 2012 17:11:14 -0000

On 4/23/12 3:57 AM, Artur Rataj wrote:
> To be exact, symlink is in the directory ~/a, and it points to ~/test and
> there is also a directory ~/.java. So, after cd ~/a/symlink, there are two
> ../.java files -- one in the physical parent, and one in the logical
> parent. The former is a directory, the latter is a plain file.
> 
> ~/a/symlink$ cd ../
> 
> produces one alternative: .java, but only if the plain file .java exists.

OK, we're back to completion again.  My previous post was intended to
illustrate the effect of a logical view of the file system.

I can't reproduce very much of what you're seeing.  I can only conclude
that there is a completion specification for `cd' that is getting in the
way and complicating things.  For instance, after a `cd symlink', hitting
TAB after "cd ../" gives me the alternatives `i' and `symlink'.  Hitting
TAB after "cd symlink/../" in `a' gives me the same two alternatives.
You're not seeing that, so I have to think you're using some other function
to generate the completions.

One thing, however, could make a difference.  If, for some reason, you
get .java as a completion and there is a file named .java in the logical
parent and a directory named .java in the physical parent, cd will work.
This is a case of cd trying to be helpful: directory canonicalization
fails, so the shell tries to use the argument as supplied as a last resort.
In this case, that succeeds.

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


From MAILER-DAEMON Wed Apr 25 13:31:22 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN63m-0004BU-1i
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 13:31:22 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45786)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN63f-0004AO-ME
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:31:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN63d-0008FD-Ug
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:31:15 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:52796)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN63d-0008Ew-PO
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:31:13 -0400
Received: from mpv5.cwru.edu (mpv5.tis.CWRU.Edu [129.22.105.51])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKE27714;
	Wed, 25 Apr 2012 13:31:11 -0400
Received: from casewireless02.CWRU.Edu (EHLO z4.local) ([129.22.1.18])
	by mpv5.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWM29961 (AUTH cpr);
	Wed, 25 Apr 2012 13:31:11 -0400 (EDT)
Message-ID: <4F9834DF.6080800@case.edu>
Date: Wed, 25 Apr 2012 13:31:11 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: Severe Bash Bug with Arrays
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu> <20120425145510.GJ22241@eeg.ccf.org>
	<4F98134D.9040109@case.edu>
	<20120425152703.GK22241@eeg.ccf.org> <4F982328.0@case.edu>
	<4F9825AA.3060109@redhat.com> <20120425165506.GL22241@eeg.ccf.org>
	<20120425171030.GM22241@eeg.ccf.org>
In-Reply-To: <20120425171030.GM22241@eeg.ccf.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 25 Apr 2012 17:31:20 -0000

On 4/25/12 1:10 PM, Greg Wooledge wrote:
> On Wed, Apr 25, 2012 at 12:55:06PM -0400, Greg Wooledge wrote:
>> It also fails on OpenBSD 5.0 using bash 4.2.10 from ports.
> 
> And it also fails on OpenBSD 5.0 using bash 4.2.24 straight from the
> original sources.

OK.  Maybe someone with OpenBSD can debug the appropriate code in
execute_cmd.c:execute_pipeline.  Maybe the call to move_to_high_fd
fails.

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


From MAILER-DAEMON Wed Apr 25 13:37:00 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN69E-0005aC-TM
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 13:37:00 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48542)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tedokuzumi@gmail.com>) id 1SN69C-0005Zs-Fh
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:36:59 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <tedokuzumi@gmail.com>) id 1SN69A-0001hP-BJ
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:36:58 -0400
Received: from mail-vx0-f169.google.com ([209.85.220.169]:52055)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tedokuzumi@gmail.com>) id 1SN69A-0001h3-3J
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:36:56 -0400
Received: by vcbfy7 with SMTP id fy7so308619vcb.0
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 10:36:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=8qWHo7SUIy9BLoZSYcg7Iu1Z7SpziCE5BQjP2einSbA=;
	b=St8IPkoQVYfLuPcAn1C1Tv6DsXA3L2IG7+Fn6DB2XHOk78RUPFcYGoStHci8UA7wKm
	kuZDnUSmkzfB5IbQweFY1Gys/iiSIBoJuyeJD/lqAuDOwlwT/1qV9w/zkWEgcHMHNpgq
	AGQMT1qHOziz747cu2b0V0s/bl+Yn+gSjVdGV48/x7Uass/c16xFwKnfoyMlKYxNeMR7
	EN3T4/rRgXJhe+Q/30ECl9TV6jA7AJqAPq9554X2Hx+03OunEoeQoGux1ZFsgK48wHx2
	R0QLtFp5IzRvR9hdKJmG+WHheIxLLpfeUFPYkAd38WYwzr6aVCR4aB2RP18nkwQAa8Di
	K5Jg==
MIME-Version: 1.0
Received: by 10.52.178.103 with SMTP id cx7mr2909199vdc.22.1335375413817; Wed,
	25 Apr 2012 10:36:53 -0700 (PDT)
Received: by 10.220.210.79 with HTTP; Wed, 25 Apr 2012 10:36:53 -0700 (PDT)
In-Reply-To: <CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
Date: Wed, 25 Apr 2012 10:36:53 -0700
Message-ID: <CAHtRY2xE+RaAjvm0XzgPuzrvjQtbqFe90j7rLMGbAxo9JKkvmg@mail.gmail.com>
Subject: Re: Severe Bash Bug with Arrays
From: Ted Okuzumi <tedokuzumi@gmail.com>
To: Clark Wang <clark.wang@oracle.com>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.220.169
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 17:37:00 -0000

Please note that if I use a different command in the while loop it works.

So instead of
echo "$mydata" | while read -r line; do myarray+=( "$line" ); done

if I say:
echo "$mydata" | while read -r line; do echo "$line" ; done

Then it works.  To pipe output into a while statement works, normally,
however it fails when the array+=( )  is used.  It doesn't fail on other
commands that I've seen.

This is why I am saying it is definitely a bug.  Do you not agree?

Thanks,
Ted

On Tue, Apr 24, 2012 at 10:23 PM, Clark Wang <clark.wang@oracle.com> wrote:

> On Wed, Apr 25, 2012 at 07:21, Ted Okuzumi <tedokuzumi@gmail.com> wrote:
>
>> I am writing this e-mai to report to report a bug in bash.
>>
>> 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-unknown-linux-gnu'
>> -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale'
>> -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib
>> -g \
>> -O2
>> uname output: Linux concour5 2.6.18-274.3.1.el5xen #1 SMP Tue Sep 6
>> 20:57:11 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
>> Machine Type: x86_64-unknown-linux-gnu
>>
>> Bash Version: 4.2
>> Patch Level: 0
>> Release Status: release
>>
>> Description:
>>        Cannot redirect into an array from multiline variable
>>
>> Does not work:
>> echo "$mydata" | while read line; do myarray+=( "$line" ); done
>>
>
> Here the whole *while* statement runs in a subshell. See
> http://mywiki.wooledge.org/BashPitfalls#grep_foo_bar_.7C_while_read_-r.3B_do_.28.28count.2B-.2B-.29.29.3B_done.
>
>>
>>
>> Works:
>> while read -r line; do myarray+=( "$line" ); done < <(echo "$mydata")
>>
>>
>

From MAILER-DAEMON Wed Apr 25 13:44:03 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN6G3-0006JG-4r
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 13:44:03 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59405)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN6G1-0006It-66
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:44:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN6Fy-0003jJ-P3
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:44:00 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45256
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN6Fx-0003jD-TZ
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:43:58 -0400
Received: (qmail 10087 invoked from network); 25 Apr 2012 17:43:54 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 25 Apr 2012 13:43:54 -0400
Received: (qmail 2459 invoked by uid 563); 25 Apr 2012 17:43:54 -0000
Date: Wed, 25 Apr 2012 13:43:54 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Ted Okuzumi <tedokuzumi@gmail.com>
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120425174353.GN22241@eeg.ccf.org>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<CAHtRY2xE+RaAjvm0XzgPuzrvjQtbqFe90j7rLMGbAxo9JKkvmg@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAHtRY2xE+RaAjvm0XzgPuzrvjQtbqFe90j7rLMGbAxo9JKkvmg@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 17:44:02 -0000

On Wed, Apr 25, 2012 at 10:36:53AM -0700, Ted Okuzumi wrote:
> Please note that if I use a different command in the while loop it works.
> 
> So instead of
> echo "$mydata" | while read -r line; do myarray+=( "$line" ); done
> 
> if I say:
> echo "$mydata" | while read -r line; do echo "$line" ; done

You do not appear to understand the issue here.  Each command in a pipeline
is run in a separate subshell.  That means "echo" runs in its own subshell,
and the entire "while" loop runs in its own subshell.

In the first example, you are populating a variable inside this subshell.

After the pipeline ends, that subshell is gone, and so is the variable
that you populated.

In the second example, you are simply writing things to stdout.  You are
not populating variables that need to persist beyond the lifespan of the
subshell.

> Then it works.  To pipe output into a while statement works, normally,
> however it fails when the array+=( )  is used.  It doesn't fail on other
> commands that I've seen.
> 
> This is why I am saying it is definitely a bug.  Do you not agree?

I do not agree.


From MAILER-DAEMON Wed Apr 25 13:50:50 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN6Mc-0007Xb-78
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 13:50:50 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41468)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SN6MZ-0007XA-82
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:50:48 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SN6MX-0006ur-Dp
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:50:46 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:42944)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SN6MX-0006uO-6b
	for bug-bash@gnu.org; Wed, 25 Apr 2012 13:50:45 -0400
Received: by obbeh20 with SMTP id eh20so454927obb.0
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 10:50:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=9nV2ws5WsuM2faMr1IYfbFQ9IX3gNEhZ/qjNO9iI8fo=;
	b=rNaRg/fl0ymT/55sL+XocdBtktiZF+sj53fvDsJ/5nN4x9mX0oa5/4//gwy1d9c5N1
	2+UIn/GZkTb0d2yWv1JwBXWwmMk3PtZ0Neocm1TQdfXXecv1gnMNaBd/6InxdM4M1TrL
	j7UprmP0vtPySz0LHf0IbmhEduMXpOUOC9sVQOG9xq+eHRTnl8uXTETbptrLZHy5erVx
	inqqoCxtx2jQYG6ptYxC5RfctTSi0Ihwdj8K0rV7R5yS4TOoQE0d2cFvlzL2JaC7WayM
	fCZb7xQh6byzQirSr2pYd/jJyTCeKX9o4l9vPgR43hr7+pOsGo6gyRvXYYUINT8qxPsw
	cLTw==
MIME-Version: 1.0
Received: by 10.182.119.6 with SMTP id kq6mr4871772obb.67.1335376242476; Wed,
	25 Apr 2012 10:50:42 -0700 (PDT)
Sender: pyroinajar@gmail.com
Received: by 10.60.33.199 with HTTP; Wed, 25 Apr 2012 10:50:42 -0700 (PDT)
In-Reply-To: <CAHtRY2xE+RaAjvm0XzgPuzrvjQtbqFe90j7rLMGbAxo9JKkvmg@mail.gmail.com>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<CAHtRY2xE+RaAjvm0XzgPuzrvjQtbqFe90j7rLMGbAxo9JKkvmg@mail.gmail.com>
Date: Wed, 25 Apr 2012 13:50:42 -0400
X-Google-Sender-Auth: 7u0Tn9zHKrgyHmbbLVZ-QIQWeaY
Message-ID: <CAPg6Z0-UeotwgxgO3XifUZjt-jU0+5xFw7mPYYEkuw6obAZJTQ@mail.gmail.com>
Subject: Re: Severe Bash Bug with Arrays
From: DJ Mills <danielmills1@gmail.com>
To: Ted Okuzumi <tedokuzumi@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Cc: Clark Wang <clark.wang@oracle.com>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 17:50:48 -0000

On Wed, Apr 25, 2012 at 1:36 PM, Ted Okuzumi <tedokuzumi@gmail.com> wrote:
> Please note that if I use a different command in the while loop it works.
>
> So instead of
> echo "$mydata" | while read -r line; do myarray+=3D( "$line" ); done
>
> if I say:
> echo "$mydata" | while read -r line; do echo "$line" ; done
>
> Then it works. =A0To pipe output into a while statement works, normally,
> however it fails when the array+=3D( ) =A0is used. =A0It doesn't fail on =
other
> commands that I've seen.
>
> This is why I am saying it is definitely a bug. =A0Do you not agree?
>
> Thanks,
> Ted



It is NOT a bug. POSIX specifies this behavior. The echo is still run
in a subshell...

The issue is that commands in a pipeline are run in a subshell. This
means that assignments and changes in PWD do not persist afterwards.
See http://mywiki.wooledge.org/BashFAQ/024.

The lastpipe shopt will work, as discussed before. The other options
are process substitution, or (POSIXly) a fifo.

Examples:

# Process substitution:
while read -r line; do
  array+=3D("$line")
done < <(some_command)


# FIFO:
mkfifo myfifo || exit
trap 'rm -f myfifo' EXIT

some_command > myfifo &
while read -r line; do
  array+=3D("$line")
done < myfifo


# Or, since it's a string you're using in your example, you could use
a here string or here document
while read -r line; do array+=3D("$line"); done <<<"$mydata"

while read -r line; do array+=3D("$line"); done <<EOF
$mydata
EOF

mapfile, with bash4, is also an option for this particular case.


From MAILER-DAEMON Wed Apr 25 14:05:03 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN6aN-0001gg-AS
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 14:05:03 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45208)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN6aH-0001fy-8z
	for bug-bash@gnu.org; Wed, 25 Apr 2012 14:05:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN6a7-0003P1-BJ
	for bug-bash@gnu.org; Wed, 25 Apr 2012 14:04:56 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45269
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN6a7-0003LB-65
	for bug-bash@gnu.org; Wed, 25 Apr 2012 14:04:47 -0400
Received: (qmail 10352 invoked from network); 25 Apr 2012 18:04:44 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 25 Apr 2012 14:04:44 -0400
Received: (qmail 2535 invoked by uid 563); 25 Apr 2012 18:04:43 -0000
Date: Wed, 25 Apr 2012 14:04:43 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120425180443.GO22241@eeg.ccf.org>
References: <CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu> <20120425145510.GJ22241@eeg.ccf.org>
	<4F98134D.9040109@case.edu>
	<20120425152703.GK22241@eeg.ccf.org> <4F982328.0@case.edu>
	<4F9825AA.3060109@redhat.com> <20120425165506.GL22241@eeg.ccf.org>
	<20120425171030.GM22241@eeg.ccf.org> <4F9834DF.6080800@case.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F9834DF.6080800@case.edu>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 18:05:01 -0000

On Wed, Apr 25, 2012 at 01:31:11PM -0400, Chet Ramey wrote:
> OK.  Maybe someone with OpenBSD can debug the appropriate code in
> execute_cmd.c:execute_pipeline.  Maybe the call to move_to_high_fd
> fails.

Breakpoint 1 at 0x41d5fc: file execute_cmd.c, line 2107.
Breakpoint 2 at 0x414aa3: file general.c, line 444.
(gdb) run ~/foo
...
Breakpoint 1, execute_pipeline (command=0x202665680, asynchronous=0,
    pipe_in=-1, pipe_out=-1, fds_to_close=0x20e5bd660) at execute_cmd.c:2107
2107      BLOCK_CHILD (set, oset);
(gdb) cont
Continuing.

Breakpoint 2, move_to_high_fd (fd=0, check_new=0, maxfd=255) at general.c:444
444       if (maxfd < 20)
(gdb) n
453         nfds = maxfd;
(gdb) n
455       for (nfds--; check_new && nfds > 3; nfds--)
(gdb) n
459       if (nfds > 3 && fd != nfds && (script_fd = dup2 (fd, nfds)) != -1)
(gdb) n
468       return (fd);
(gdb) print fd
$1 = 0
(gdb) n
469     }

Is that saying it's searching for an available file descriptor starting
at or near 255?

cyclops:/var/tmp/bash/bash-4.2$ ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) 524288
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) 2631052
max memory size         (kbytes, -m) 7888636
open files                      (-n) 128
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 4096
cpu time               (seconds, -t) unlimited
max user processes              (-u) 128
virtual memory          (kbytes, -v) 528384

That's the OpenBSD box.  The HP-UX box is even more extreme:

$ ulimit -a
core file size          (blocks, -c) 2097151
data seg size           (kbytes, -d) 65536
file size               (blocks, -f) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 60
pipe size            (512 bytes, -p) 16
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 76
virtual memory          (kbytes, -v) unlimited

Maybe it only works on boxes with a very large "open files" resource
limit.  Perhaps the hard-coded 255 should be replaced with something
involving getrlimit() or similar?


From MAILER-DAEMON Wed Apr 25 14:54:15 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN7Lz-0003NM-51
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 14:54:15 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50223)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN7Lv-0003Fi-V3
	for bug-bash@gnu.org; Wed, 25 Apr 2012 14:54:13 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN7Lu-0004WF-0Z
	for bug-bash@gnu.org; Wed, 25 Apr 2012 14:54:11 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:17988)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN7Lt-0004Vx-T4
	for bug-bash@gnu.org; Wed, 25 Apr 2012 14:54:09 -0400
Received: from mpv6.tis.CWRU.Edu (EHLO mpv6.cwru.edu) ([129.22.104.221])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXZ80364; Wed, 25 Apr 2012 14:54:07 -0400 (EDT)
Received: from casewireless02.CWRU.Edu (EHLO z4.local) ([129.22.1.18])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWC41927 (AUTH cpr);
	Wed, 25 Apr 2012 14:54:07 -0400 (EDT)
Message-ID: <4F98484F.6040900@case.edu>
Date: Wed, 25 Apr 2012 14:54:07 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: Severe Bash Bug with Arrays
References: <CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<4F97F0AB.5050901@case.edu> <20120425145510.GJ22241@eeg.ccf.org>
	<4F98134D.9040109@case.edu>
	<20120425152703.GK22241@eeg.ccf.org> <4F982328.0@case.edu>
	<4F9825AA.3060109@redhat.com> <20120425165506.GL22241@eeg.ccf.org>
	<20120425171030.GM22241@eeg.ccf.org> <4F9834DF.6080800@case.edu>
	<20120425180443.GO22241@eeg.ccf.org>
In-Reply-To: <20120425180443.GO22241@eeg.ccf.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, Chet Ramey <chet.ramey@case.edu>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 25 Apr 2012 18:54:13 -0000

On 4/25/12 2:04 PM, Greg Wooledge wrote:

> Maybe it only works on boxes with a very large "open files" resource
> limit.  Perhaps the hard-coded 255 should be replaced with something
> involving getrlimit() or similar?

I see two potential fixes here.  First, try changing the 255 to -1 and
see what happens.

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


From MAILER-DAEMON Wed Apr 25 15:10:01 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN7bF-0006U8-IF
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 15:10:01 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50802)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN7bD-0006U2-JV
	for bug-bash@gnu.org; Wed, 25 Apr 2012 15:10:00 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN7b8-00026T-Jc
	for bug-bash@gnu.org; Wed, 25 Apr 2012 15:09:59 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45288
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN7b8-000262-Ep
	for bug-bash@gnu.org; Wed, 25 Apr 2012 15:09:54 -0400
Received: (qmail 10901 invoked from network); 25 Apr 2012 19:09:49 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 25 Apr 2012 15:09:49 -0400
Received: (qmail 2648 invoked by uid 563); 25 Apr 2012 19:09:48 -0000
Date: Wed, 25 Apr 2012 15:09:48 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120425190948.GP22241@eeg.ccf.org>
References: <20120425145510.GJ22241@eeg.ccf.org> <4F98134D.9040109@case.edu>
	<20120425152703.GK22241@eeg.ccf.org> <4F982328.0@case.edu>
	<4F9825AA.3060109@redhat.com> <20120425165506.GL22241@eeg.ccf.org>
	<20120425171030.GM22241@eeg.ccf.org> <4F9834DF.6080800@case.edu>
	<20120425180443.GO22241@eeg.ccf.org> <4F98484F.6040900@case.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F98484F.6040900@case.edu>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 19:10:01 -0000

On Wed, Apr 25, 2012 at 02:54:07PM -0400, Chet Ramey wrote:
> On 4/25/12 2:04 PM, Greg Wooledge wrote:
> 
> > Maybe it only works on boxes with a very large "open files" resource
> > limit.  Perhaps the hard-coded 255 should be replaced with something
> > involving getrlimit() or similar?
> 
> I see two potential fixes here.  First, try changing the 255 to -1 and
> see what happens.

That broke something pretty badly.

cyclops:/var/tmp/bash/bash-4.2$ cat ~/foo
#!/bin/bash
shopt -s lastpipe
echo hi | read foo
echo "<$foo>"
cyclops:/var/tmp/bash/bash-4.2$ ./bash ~/foo
cyclops:/var/tmp/bash/bash-4.2$ ./bash -c 'shopt -s lastpipe; echo hi | read foo; echo "<$foo>"'
<hi>

So it seems to work with -c but not when reading from a file.  I'm guessing
the file descriptor move somehow made bash lose track of the file it was
reading commands from.

The move_to_high_fd part looks happier:

Breakpoint 2, move_to_high_fd (fd=0, check_new=0, maxfd=-1) at general.c:444
444       if (maxfd < 20)
(gdb) n
446           nfds = getdtablesize ();
(gdb) n
447           if (nfds <= 0)
(gdb) n
449           if (nfds > HIGH_FD_MAX)
(gdb) n
455       for (nfds--; check_new && nfds > 3; nfds--)
(gdb) n
459       if (nfds > 3 && fd != nfds && (script_fd = dup2 (fd, nfds)) != -1)
(gdb) n
461           if (check_new == 0 || fd != fileno (stderr))      /* don't close stderr */
(gdb) n
462             close (fd);
(gdb) n
463           return (script_fd);
(gdb) print script_fd
$1 = 127
(gdb) n
469     }
(gdb) n

But after that I have no idea what's happening (or failing to happen):

execute_pipeline (command=0x209d2c260, asynchronous=0, pipe_in=-1,
    pipe_out=-1, fds_to_close=0x202b8ca10) at execute_cmd.c:2209
2209          if (lstdin > 0)
(gdb) n
2211              do_piping (prev, pipe_out);
(gdb) n
2212              prev = NO_PIPE;
(gdb) n
2213              add_unwind_protect (restore_stdin, lstdin);
(gdb) n
2214              lastpipe_flag = 1;
(gdb) n
2215              freeze_jobs_list ();
(gdb) n
2216              lastpipe_jid = stop_pipeline (0, (COMMAND *)NULL);    /* XXX */
(gdb) n
2217              add_unwind_protect (lastpipe_cleanup, lastpipe_jid);
f (cmd)
(gdb) n
2220            cmd->flags |= CMD_LASTPIPE;
(gdb) n
2222      if (prev >= 0)
(gdb) n
2226      exec_result = execute_command_internal (cmd, asynchronous, prev, pipe_out, fds_to_close);
(gdb) n
2229      if (lstdin > 0)
(gdb) n
2230        restore_stdin (lstdin);
(gdb) n
2233      if (prev >= 0)
(gdb) n
2237      UNBLOCK_CHILD (oset);
(gdb) n
2240      QUIT;
(gdb) n
2242      if (lastpipe_flag)
(gdb) n
2245          append_process (savestring (the_printed_command), dollar_dollar_pid, exec_result, lastpipe_jid);
(gdb) n
2247          lstdin = wait_for (lastpid);
(gdb) n
2249          exec_result = job_exit_status (lastpipe_jid);
(gdb) n
2251          unfreeze_jobs_list ();
(gdb) n
2254      discard_unwind_frame ("lastpipe-exec");
(gdb) n
2256      return (exec_result);
(gdb) n
2257    }
(gdb) n
execute_connection (command=0x209d2c260, asynchronous=0, pipe_in=-1, 
    pipe_out=-1, fds_to_close=0x202b8ca10) at execute_cmd.c:2338
2338          if (was_error_trap && ignore_return == 0 && invert == 0 && exec_result != EXECUTION_SUCCESS)
(gdb) cont
Continuing.

Program exited normally.
(gdb) 


From MAILER-DAEMON Wed Apr 25 16:05:23 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN8Sp-00069J-Fe
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 16:05:23 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53538)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN8Sm-000698-Q0
	for bug-bash@gnu.org; Wed, 25 Apr 2012 16:05:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN8Sk-00058X-6x
	for bug-bash@gnu.org; Wed, 25 Apr 2012 16:05:20 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:43225)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SN8Sk-00056m-1k
	for bug-bash@gnu.org; Wed, 25 Apr 2012 16:05:18 -0400
Received: from mpv5.tis.CWRU.Edu (EHLO mpv5.cwru.edu) ([129.22.105.51])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BXZ86933; Wed, 25 Apr 2012 16:05:16 -0400 (EDT)
Received: from casewireless02.CWRU.Edu (EHLO z4.local) ([129.22.1.18])
	by mpv5.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWM54723 (AUTH cpr);
	Wed, 25 Apr 2012 16:05:15 -0400 (EDT)
Message-ID: <4F9858FB.4050809@case.edu>
Date: Wed, 25 Apr 2012 16:05:15 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: Severe Bash Bug with Arrays
References: <20120425145510.GJ22241@eeg.ccf.org> <4F98134D.9040109@case.edu>
	<20120425152703.GK22241@eeg.ccf.org> <4F982328.0@case.edu>
	<4F9825AA.3060109@redhat.com> <20120425165506.GL22241@eeg.ccf.org>
	<20120425171030.GM22241@eeg.ccf.org> <4F9834DF.6080800@case.edu>
	<20120425180443.GO22241@eeg.ccf.org> <4F98484F.6040900@case.edu>
	<20120425190948.GP22241@eeg.ccf.org>
In-Reply-To: <20120425190948.GP22241@eeg.ccf.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, Chet Ramey <chet.ramey@case.edu>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 25 Apr 2012 20:05:22 -0000

On 4/25/12 3:09 PM, Greg Wooledge wrote:
> On Wed, Apr 25, 2012 at 02:54:07PM -0400, Chet Ramey wrote:
>> On 4/25/12 2:04 PM, Greg Wooledge wrote:
>>
>>> Maybe it only works on boxes with a very large "open files" resource
>>> limit.  Perhaps the hard-coded 255 should be replaced with something
>>> involving getrlimit() or similar?
>>
>> I see two potential fixes here.  First, try changing the 255 to -1 and
>> see what happens.
> 
> That broke something pretty badly.

OK.  Now make the call move_to_high_fd(0, 1, -1) and see if that fixes it.


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


From MAILER-DAEMON Wed Apr 25 16:15:37 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN8cj-0000Ne-Na
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 16:15:37 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51125)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN8ch-0000NY-Cb
	for bug-bash@gnu.org; Wed, 25 Apr 2012 16:15:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN8cf-0000J3-Bk
	for bug-bash@gnu.org; Wed, 25 Apr 2012 16:15:34 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45323
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SN8cf-0000In-33
	for bug-bash@gnu.org; Wed, 25 Apr 2012 16:15:33 -0400
Received: (qmail 11242 invoked from network); 25 Apr 2012 20:15:27 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Wed, 25 Apr 2012 16:15:26 -0400
Received: (qmail 2704 invoked by uid 563); 25 Apr 2012 20:15:24 -0000
Date: Wed, 25 Apr 2012 16:15:24 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120425201524.GQ22241@eeg.ccf.org>
References: <20120425152703.GK22241@eeg.ccf.org> <4F982328.0@case.edu>
	<4F9825AA.3060109@redhat.com> <20120425165506.GL22241@eeg.ccf.org>
	<20120425171030.GM22241@eeg.ccf.org> <4F9834DF.6080800@case.edu>
	<20120425180443.GO22241@eeg.ccf.org> <4F98484F.6040900@case.edu>
	<20120425190948.GP22241@eeg.ccf.org> <4F9858FB.4050809@case.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F9858FB.4050809@case.edu>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 20:15:36 -0000

On Wed, Apr 25, 2012 at 04:05:15PM -0400, Chet Ramey wrote:
> OK.  Now make the call move_to_high_fd(0, 1, -1) and see if that fixes it.

cyclops:/var/tmp/bash/bash-4.2$ ./bash ~/foo                                    <hi>
cyclops:/var/tmp/bash/bash-4.2$ ./bash -c 'shopt -s lastpipe; echo hi | read foo; echo "<$foo>"'
<hi>
cyclops:/var/tmp/bash/bash-4.2$ ./bash < ~/foo
<hi>

So those three cases work.  I tried one other test for grins (remember
that ulimit -n is 128):

cyclops:/var/tmp/bash/bash-4.2$ ./bash -c 'shopt -s lastpipe; exec 3</dev/null 4</dev/null 5</dev/null 125</dev/null 126</dev/null; echo hi | read foo; echo "<$foo>"'
<hi>

Looks good at first glance.


From MAILER-DAEMON Wed Apr 25 17:17:56 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SN9b2-0003g6-G5
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 17:17:56 -0400
Received: from eggs.gnu.org ([208.118.235.92]:43459)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tedokuzumi@gmail.com>) id 1SN9az-0003fi-Lu
	for bug-bash@gnu.org; Wed, 25 Apr 2012 17:17:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <tedokuzumi@gmail.com>) id 1SN9ax-00051X-KT
	for bug-bash@gnu.org; Wed, 25 Apr 2012 17:17:53 -0400
Received: from mail-wi0-f171.google.com ([209.85.212.171]:47817)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tedokuzumi@gmail.com>) id 1SN9ax-00051R-89
	for bug-bash@gnu.org; Wed, 25 Apr 2012 17:17:51 -0400
Received: by wibhj13 with SMTP id hj13so4224462wib.12
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 14:17:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=NdGuPt/YHWZbgXVYT6LWJgrSesfqsvXYIl69lCXULgM=;
	b=HpvE/R85aeIgC3PgWaq51TS7RibjH6+e4pwbHuj8bkEf6FjSz3BoK1EwVeAnaPuil4
	dAf8amajAZxe98SyWJbhtyklkiPnsKWikR5yvarU0t4okFRX9rC96Ky9F9j2uI9czevf
	mLCaSjbonUJWnHUrYcXrbtNjoNehScMAAZtLxmN7YKoSY2BwF4nB/TiGDXZff/JgOiIt
	0rtLIkb/1s6MBGshdhWuDEzlTnlNhHkiY5IXV4Wyy6NE1wflCt19Bu8EVKMDVus1on1O
	ibtfcYxonAiDyD7DhbqlWTtU83uhOEJFRfkuIG18uPnwspBicum7Peh9El0GgwuIEaop
	J7yw==
MIME-Version: 1.0
Received: by 10.180.8.231 with SMTP id u7mr880333wia.9.1335388668818; Wed, 25
	Apr 2012 14:17:48 -0700 (PDT)
Received: by 10.180.85.40 with HTTP; Wed, 25 Apr 2012 14:17:48 -0700 (PDT)
In-Reply-To: <CAPg6Z0-UeotwgxgO3XifUZjt-jU0+5xFw7mPYYEkuw6obAZJTQ@mail.gmail.com>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<CADv8-ohuurq7xCjqfjU2Mg7bvp9y5=qWwxtmn5Sbq1fgndaZAg@mail.gmail.com>
	<CAHtRY2xE+RaAjvm0XzgPuzrvjQtbqFe90j7rLMGbAxo9JKkvmg@mail.gmail.com>
	<CAPg6Z0-UeotwgxgO3XifUZjt-jU0+5xFw7mPYYEkuw6obAZJTQ@mail.gmail.com>
Date: Wed, 25 Apr 2012 14:17:48 -0700
Message-ID: <CAHtRY2y=nN7=3p1rX8Pvd8K4V14uEGk3i3GAQcQVJTi94cs-Tw@mail.gmail.com>
Subject: Re: Severe Bash Bug with Arrays
From: Ted Okuzumi <tedokuzumi@gmail.com>
To: DJ Mills <danielmills1@gmail.com>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.212.171
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: Clark Wang <clark.wang@oracle.com>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 21:17:55 -0000

Thank you for that detailed information.  I really appreciate the 2
workarounds you provided.

I can confirm by adding in this line to my script:

shopt -s lastpipe

fixes the problem, confirming that it was indeed a subshell issue.

Best regards,
Ted

On Wed, Apr 25, 2012 at 10:50 AM, DJ Mills <danielmills1@gmail.com> wrote:

> On Wed, Apr 25, 2012 at 1:36 PM, Ted Okuzumi <tedokuzumi@gmail.com> wrote:
> > Please note that if I use a different command in the while loop it works.
> >
> > So instead of
> > echo "$mydata" | while read -r line; do myarray+=( "$line" ); done
> >
> > if I say:
> > echo "$mydata" | while read -r line; do echo "$line" ; done
> >
> > Then it works.  To pipe output into a while statement works, normally,
> > however it fails when the array+=( )  is used.  It doesn't fail on other
> > commands that I've seen.
> >
> > This is why I am saying it is definitely a bug.  Do you not agree?
> >
> > Thanks,
> > Ted
>
>
>
> It is NOT a bug. POSIX specifies this behavior. The echo is still run
> in a subshell...
>
> The issue is that commands in a pipeline are run in a subshell. This
> means that assignments and changes in PWD do not persist afterwards.
> See http://mywiki.wooledge.org/BashFAQ/024.
>
> The lastpipe shopt will work, as discussed before. The other options
> are process substitution, or (POSIXly) a fifo.
>
> Examples:
>
> # Process substitution:
> while read -r line; do
>   array+=("$line")
> done < <(some_command)
>
>
> # FIFO:
> mkfifo myfifo || exit
> trap 'rm -f myfifo' EXIT
>
> some_command > myfifo &
> while read -r line; do
>   array+=("$line")
> done < myfifo
>
>
> # Or, since it's a string you're using in your example, you could use
> a here string or here document
> while read -r line; do array+=("$line"); done <<<"$mydata"
>
> while read -r line; do array+=("$line"); done <<EOF
> $mydata
> EOF
>
> mapfile, with bash4, is also an option for this particular case.
>

From MAILER-DAEMON Wed Apr 25 19:18:35 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNBTn-0005BR-9h
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 19:18:35 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53105)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNBTk-0005Ae-Km
	for bug-bash@gnu.org; Wed, 25 Apr 2012 19:18:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNBTj-0006VB-0V
	for bug-bash@gnu.org; Wed, 25 Apr 2012 19:18:32 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:51161
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNBTi-0006UN-Ff
	for bug-bash@gnu.org; Wed, 25 Apr 2012 19:18:30 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3PNILqf015890; Wed, 25 Apr 2012 16:18:24 -0700
Message-ID: <4F98863D.7070005@tlinx.org>
Date: Wed, 25 Apr 2012 16:18:21 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Ted Okuzumi <tedokuzumi@gmail.com>
Subject: Re: Severe Bash Bug with Arrays
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
In-Reply-To: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 23:18:33 -0000



Ted Okuzumi wrote:

> I am writing this e-mai to report to report a bug in bash
> 
> Description:
>         Cannot redirect into an array from multiline variable
> 
> Does not work:
> echo "$mydata" | while read line; do myarray+=( "$line" ); done

----
Have you tried this?


Ishtar:> a='this
  is
   a
    test'
Ishtar:> echo "$a"
this
  is
   a
    test
Ishtar:> readarray b < <(echo "$a")
Ishtar:> echo ${#b[*]}
4
Ishtar:> echo ${b[*]}
this is a test
Ishtar:> echo "${b[*]}"
this
   is
    a
     test

Ishtar:> echo -n "${b[*]}"
this
   is
    a
     test
Ishtar:> readarray -t b < <(echo "$a")
Ishtar:> echo "${b[*]}"
this  is   a    test
Ishtar:> echo ${b[*]}
this is a test
Ishtar:>

-------------

Seeems like you can have it anyway you want it...?

Does the above work for you?



From MAILER-DAEMON Wed Apr 25 19:46:13 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNBuX-0006j3-Eu
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 19:46:13 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41227)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNBuV-0006iZ-1D
	for bug-bash@gnu.org; Wed, 25 Apr 2012 19:46:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNBuT-0001Zo-0u
	for bug-bash@gnu.org; Wed, 25 Apr 2012 19:46:10 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:51637
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNBuS-0001Z2-BH
	for bug-bash@gnu.org; Wed, 25 Apr 2012 19:46:08 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3PNk1OE006835; Wed, 25 Apr 2012 16:46:04 -0700
Message-ID: <4F988CBA.5070800@tlinx.org>
Date: Wed, 25 Apr 2012 16:46:02 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Clark Wang <clark.wang@oracle.com>
Subject: Re: Passing variables by reference conflicts with local
References: <20100501081803.GA4615@rebase.prov>	<n2kaca4c5091005010226p1e98d791h71e0fd5af8f325c3@mail.gmail.com>	<r2pc440c9801005010240o2388c72fjb8ce0aa6b123d19c@mail.gmail.com>	<20100501112118.GB4615@rebase.prov>	<o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>	<20100501221925.GA4054@rebase.prov>	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>	<20100502113559.GA3670@rebase.prov>	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>	<20100503213852.GB3988@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
In-Reply-To: <CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 25 Apr 2012 23:46:12 -0000



Clark Wang wrote:

> On Wed, May 5, 2010 at 01:57, Freddy Vulto <fvulto@gmail.com> wrote:
> 
>> It appears that `unset' is capable of traversing down the call-stack and
>> unsetting variables repeatedly:
>>
>>    a=0 b=0 c=0 d=0 e=0
>>    _unset() { unset -v b c c d d d e; }
>>    t1() {
>>        local a=1 b=1 c=1 d=1
>>        t2
>>    }
>>    t2() {
>>        local a=2 b=2 c=2 d=2 e=2
>>        _unset
>>        echo a:$a b:$b c:$c d:$d e:$e
>>    }
>>    t1  # Outputs: a:2 b:1 c:0 d: e:0
>>        #            ^   ^   ^   ^  ^-- unset once (skipped t1)
>>        #            |   |   |   +----- unset thrice to global
>>        #            |   |   +--------- unset twice till global
>>        #            |   +------------- unset once till t1
>>        #            +----------------- unset not
>>
>> It seems to work on bash-3.0, 3.2, 4.0 and 4.1.
>> Is this a bug or a feature?
>>
> 
> When I revisit this 2 years old thread I don't understand why following
> foo() function does not output the global var:
> 
> $ cat foo.sh
> var=global
> foo()
> {
>     local var=foo
>     unset var
>     echo foo: $var
> }
> bar_unset()
> {
>     unset var
> }
> bar()
> {
>     local var=bar
>     bar_unset
>     echo bar: $var
> }
> foo
> bar
> $ bash foo.sh
> foo:
> bar: global
> $
> 
> In foo() it unsets its local var so why doesn't the subsequent $var refer
> to the global var?

----
The above is pretty deep stuff, but I would guess from this:


Ishtar:> foo() { local var=foo; echo -n "type=\""; typeset -p var;echo -n "\""; 
unset var; typeset -p var ;echo foo: $var; }
Ishtar:> foo
type="declare -- var="foo"
"-bash: typeset: var: not found
foo:
----
I would guess (without looking at the codE), that
when you do a local, it creates another copy of 'var' at the end of an array.
like var[0][1]
so global is at 0, and local is at 1.
So let #=the index of the last position in the array so at
global var[#]='global',
local var[#]=foo, but 'local adds one to the var array, so it's going into var[1].
Now if you unset var[1], function foo still is using it's incremented value
of '#' (1) to tell you it has no value.

However, if you call a second function 'bar_unset', to unset the var
it deletes var[1], and sets # to 0,
so now when control returns to original
foo,
foo Can't assume # is unchanged (you've called another function,
it might have done something to # (the count of copies of var -- which it
did!)...
so it knows it did a "local", so it's copy of 'var' would be "last"
on the "var" value array --
but # has been reset to 0,
so now foo picks up var[0]...

That's just a guess based on how I might implement such behavior if I wanted
it to behave that way.

As to whether or not it is "correct" by some arbitrarily set standard or 
definition of "correct" -- that's a matter for nit-pickers and POSIXies.  :-)

I'm sure someone more qualified with the internals can give a more accurate 
description of what happened, but that's my high level, "black-box" view.



From MAILER-DAEMON Wed Apr 25 21:51:09 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNDrR-0007eU-4d
	for mharc-bug-bash@gnu.org; Wed, 25 Apr 2012 21:51:09 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55002)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNDrO-0007dn-Lp
	for bug-bash@gnu.org; Wed, 25 Apr 2012 21:51:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNDrM-0002Tn-P2
	for bug-bash@gnu.org; Wed, 25 Apr 2012 21:51:06 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:53868
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNDrM-0002Sf-3p
	for bug-bash@gnu.org; Wed, 25 Apr 2012 21:51:04 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3Q1otog011716; Wed, 25 Apr 2012 18:50:57 -0700
Message-ID: <4F98A9FF.30204@tlinx.org>
Date: Wed, 25 Apr 2012 18:50:55 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Victor Engmark <victor.engmark@gmail.com>, bug-bash <bug-bash@gnu.org>
Subject: Re: Shouldn't "type" and "command" complain if there are no
	parameters?
References: <5596614.529.1334755575982.JavaMail.geo-discussion-forums@ynbr30>
In-Reply-To: <5596614.529.1334755575982.JavaMail.geo-discussion-forums@ynbr30>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 01:51:08 -0000



Victor Engmark wrote:

> Re-post from <http://unix.stackexchange.com/questions/36752/why-are-parameters-to-bashs-command-and-type-optional>:
> 
> [T]hese commands print nothing and return exit code 0 if no parameters are provided. But [...] `help command` and `help type` both state that at least one parameter is mandatory. Is this a bug, a feature, or did I misunderstand something?
> 


command executes the named argument as a command.

It is perfectly valid to type in nothing at the command line and expect
no error.

A similar argument like can be proposed for type.

You give it nothing as input, why would you expect output?

Conversely, would you want it to give you an error every time you
hit 'Enter' at the prompt?

it's similar to the annoyance caused by getting an error for unexpected ";"
when ";" is meant, in such context, to be taken for a line separator.
;-/





From MAILER-DAEMON Thu Apr 26 00:26:24 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNGHg-0004yU-DG
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 00:26:24 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47071)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNGHd-0004xZ-1N
	for bug-bash@gnu.org; Thu, 26 Apr 2012 00:26:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNGHZ-0006CS-KC
	for bug-bash@gnu.org; Thu, 26 Apr 2012 00:26:20 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:56592
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNGHZ-0006Bu-3Q
	for bug-bash@gnu.org; Thu, 26 Apr 2012 00:26:17 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3Q4QAVR007315
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 21:26:13 -0700
Message-ID: <4F98CE62.3040601@tlinx.org>
Date: Wed, 25 Apr 2012 21:26:10 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: Is it possible or RFE to expand ranges of *arrays*
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 04:26:22 -0000

I know I can get
a="abcdef" echo "${a[2:4]}" = cde

  how do I do:
typeset -a a=(apple berry cherry date); then get:

echo ${a[1:2]} = "berry" "cherry"  ( non-grouped args)

I tried to do it in a function and hurt myself.




From MAILER-DAEMON Thu Apr 26 00:30:27 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNGLb-0005z2-D8
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 00:30:27 -0400
Received: from eggs.gnu.org ([208.118.235.92]:35801)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SNGLZ-0005yw-0F
	for bug-bash@gnu.org; Thu, 26 Apr 2012 00:30:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SNGLX-0007fZ-9y
	for bug-bash@gnu.org; Thu, 26 Apr 2012 00:30:24 -0400
Received: from fmmailgate01.web.de ([217.72.192.221]:54198)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SNGLX-0007dX-3Z
	for bug-bash@gnu.org; Thu, 26 Apr 2012 00:30:23 -0400
Received: from moweb002.kundenserver.de (moweb002.kundenserver.de
	[172.19.20.108])
	by fmmailgate01.web.de (Postfix) with ESMTP id A567A1AD4227D
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 06:30:20 +0200 (CEST)
Received: from [192.168.178.49] ([93.134.85.137]) by smtp.web.de (mrweb002)
	with ESMTPA (Nemesis) id 0Lecda-1RroXt3yKE-00qQTV;
	Thu, 26 Apr 2012 06:30:20 +0200
Message-ID: <4F98CF5B.6050306@web.de>
Date: Thu, 26 Apr 2012 06:30:19 +0200
From: John Kearney <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:12.0) Gecko/20120420 Thunderbird/12.0
MIME-Version: 1.0
To: Linda Walsh <bash@tlinx.org>
Subject: Re: Is it possible or RFE to expand ranges of *arrays*
References: <4F98CE62.3040601@tlinx.org>
In-Reply-To: <4F98CE62.3040601@tlinx.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:96Im05iqmAORxmk8n5TRVjjAxHDDgjjy6x7RgeOX8/J
	MMx1NSjw8+t618XDq/by8sErn5MuiLoxtFIm26ZF1p0n2RXb8o
	axZ0E1k6YZyEa0y/UMMxAAFIJMS/bgToyGtSiJEDmBv1SeayGd
	o655eMqilevhIIT5R/l66bnMc2kZ7kEuRjiAiespkkskwo7tdj
	npHMAHp/AXs65hxJ3vgCQ==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.221
Cc: bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 04:30:26 -0000

Am 26.04.2012 06:26, schrieb Linda Walsh:
> I know I can get
> a="abcdef" echo "${a[2:4]}" = cde
>
>  how do I do:
> typeset -a a=(apple berry cherry date); then get:
>
> echo ${a[1:2]} = "berry" "cherry"  ( non-grouped args)
>
> I tried to do it in a function and hurt myself.
>
>
>
echo ${a[@]:1:2}


From MAILER-DAEMON Thu Apr 26 01:48:55 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNHZX-0003nR-RD
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 01:48:55 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44801)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <victor.engmark@gmail.com>) id 1SNHZV-0003mP-1k
	for bug-bash@gnu.org; Thu, 26 Apr 2012 01:48:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <victor.engmark@gmail.com>) id 1SNHZS-0008F0-L5
	for bug-bash@gnu.org; Thu, 26 Apr 2012 01:48:52 -0400
Received: from mail-ee0-f41.google.com ([74.125.83.41]:61338)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <victor.engmark@gmail.com>) id 1SNHZS-0008Eb-CQ
	for bug-bash@gnu.org; Thu, 26 Apr 2012 01:48:50 -0400
Received: by eeke53 with SMTP id e53so469553eek.0
	for <bug-bash@gnu.org>; Wed, 25 Apr 2012 22:48:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	bh=yOw9HdICvX1snyJeOdU2DI/Y948MGNJKyU/80u4Zd2E=;
	b=LrHpk1PxNDv/qrHjUReHIXp7GvUkjp2y489hc0epVrOAbvq6RLco/SKhxMyIwPMYme
	D/CFiyQ5uioiSKC9XfK006Rt1HDAUvRSPaMpzmoFRaiJQT//j96y9PWGAH1ZK9MufMy1
	p9vZxtbGxmcO6Cjnu3uMkwGDvW1Lj3KG5NX7jj7ORACzfHdIrdGTmJnE2VpWoM4KvB15
	N4ZZlAD9teG9tEUiGwukJscusG59PWXd8EsVbKpF8wsqtkrShsvprX+2x6gA+/BJnTDP
	SIYxcYAlo4FSaf/YaAfGXoGQpUBrkvGoIE1OzDQga/JbIEpEjgLNHA01rld0H9/8cldO
	C6lg==
MIME-Version: 1.0
Received: by 10.14.119.75 with SMTP id m51mr971246eeh.54.1335419327815; Wed,
	25 Apr 2012 22:48:47 -0700 (PDT)
Received: by 10.213.3.136 with HTTP; Wed, 25 Apr 2012 22:48:47 -0700 (PDT)
In-Reply-To: <4F98A9FF.30204@tlinx.org>
References: <5596614.529.1334755575982.JavaMail.geo-discussion-forums@ynbr30>
	<4F98A9FF.30204@tlinx.org>
Date: Thu, 26 Apr 2012 07:48:47 +0200
Message-ID: <CAA5Ydx8ANq1B+4D=Awdibj149q4ibdOyo-eFDkJkt49kb0_zFQ@mail.gmail.com>
Subject: Re: Shouldn't "type" and "command" complain if there are no
	parameters?
From: Victor Engmark <victor.engmark@gmail.com>
To: Linda Walsh <bash@tlinx.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 74.125.83.41
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 05:48:54 -0000

On Thu, Apr 26, 2012 at 3:50 AM, Linda Walsh <bash@tlinx.org> wrote:

> Victor Engmark wrote:
>
>> Re-post from <http://unix.stackexchange.**com/questions/36752/why-are-**
>> parameters-to-bashs-command-**and-type-optional<http://unix.stackexchange.com/questions/36752/why-are-parameters-to-bashs-command-and-type-optional>
>> >:
>>
>> [T]hese commands print nothing and return exit code 0 if no parameters
>> are provided. But [...] `help command` and `help type` both state that at
>> least one parameter is mandatory. Is this a bug, a feature, or did I
>> misunderstand something?
>>
>
> command executes the named argument as a command.
>
> It is perfectly valid to type in nothing at the command line and expect
> no error.
>

Actually, if you type in a command, and then press Enter more than once,
the exit code is *kept*, as if you had pressed Enter only once. So pressing
Enter on an empty command line is *not* the same as saying `:`, or `true`.

A similar argument like can be proposed for type.
>
> You give it nothing as input, why would you expect output?
>

The issue is rather that the synopsis is *inconsistent* with the
functioning of `type` and `command`. For example, the `watch` command
requires a command string as its last parameter, and without it, it prints
its own synopsis and returns with exit code 1, as expected.

My suggestion is simply that unless someone can show that somehow the
synopsis *is* consistent with the functioning of these builtins, the
synopsis should be corrected *or* the functioning of these commands should
be changed, in order to be consistent with most other *nix tools.

Cheers,
V

From MAILER-DAEMON Thu Apr 26 03:57:22 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNJZq-0003Ma-B1
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 03:57:22 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48588)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNJZj-0003MJ-I3
	for bug-bash@gnu.org; Thu, 26 Apr 2012 03:57:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNJZZ-0004Ay-KR
	for bug-bash@gnu.org; Thu, 26 Apr 2012 03:57:15 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:60506
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNJZZ-0004AT-5H
	for bug-bash@gnu.org; Thu, 26 Apr 2012 03:57:05 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3Q7uxIv010336
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 00:57:01 -0700
Message-ID: <4F98FFCB.4030004@tlinx.org>
Date: Thu, 26 Apr 2012 00:56:59 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: Re: Is it possible or RFE to expand ranges of *arrays*
References: <4F98CE62.3040601@tlinx.org> <4F98CF5B.6050306@web.de>
In-Reply-To: <4F98CF5B.6050306@web.de>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 07:57:21 -0000



John Kearney wrote:


>>
> echo ${a[@]:1:2}

---
	Thanks!...I couldn't believe there wasn't some way to do
it, but darned if I couldn't think of it or find it for that matter...
sigh.

Thanks again!



From MAILER-DAEMON Thu Apr 26 08:11:43 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNNXz-0005mM-JJ
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 08:11:43 -0400
Received: from eggs.gnu.org ([208.118.235.92]:42533)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNNXa-0005dX-8T
	for bug-bash@gnu.org; Thu, 26 Apr 2012 08:11:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNNXO-0007FV-Hj
	for bug-bash@gnu.org; Thu, 26 Apr 2012 08:11:17 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45756
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNNXO-0007EJ-9h
	for bug-bash@gnu.org; Thu, 26 Apr 2012 08:11:06 -0400
Received: (qmail 17122 invoked from network); 26 Apr 2012 12:11:01 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Thu, 26 Apr 2012 08:11:01 -0400
Received: (qmail 3592 invoked by uid 563); 26 Apr 2012 12:11:00 -0000
Date: Thu, 26 Apr 2012 08:11:00 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Linda Walsh <bash@tlinx.org>
Subject: Re: Passing variables by reference conflicts with local
Message-ID: <20120426121100.GR22241@eeg.ccf.org>
References: <20100501112118.GB4615@rebase.prov>
	<o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
	<4F988CBA.5070800@tlinx.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F988CBA.5070800@tlinx.org>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: Clark Wang <clark.wang@oracle.com>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 12:11:41 -0000

On Wed, Apr 25, 2012 at 04:46:02PM -0700, Linda Walsh wrote:
> I would guess (without looking at the codE), that
> when you do a local, it creates another copy of 'var' at the end of an 
> array.
> like var[0][1]
> so global is at 0, and local is at 1.

I'm pretty sure bash doesn't use a multidimensional array to do variable
scoping.  I'd expect some sort of a stack.

> As to whether or not it is "correct" by some arbitrarily set standard or 
> definition of "correct" -- that's a matter for nit-pickers and POSIXies.  
> :-)

Bash uses "dynamic scoping", which is a somewhat controversial choice, and
has led to a whole lot of confusion in the past.  Most other shells use
static scoping.  POSIX has nothing to say on the matter; "local" is not
defined in POSIX, and POSIX does not even require functions to implement
local variables at all (let alone dictate what kind of scoping to use).

POSIX on functions:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05

Wikipedia on dynamic scoping:
http://en.wikipedia.org/wiki/Scope_%28computer_science%29#Dynamic_scoping


From MAILER-DAEMON Thu Apr 26 08:28:38 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNNoM-0000Ba-4P
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 08:28:38 -0400
Received: from eggs.gnu.org ([208.118.235.92]:38367)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNNoE-00009i-VD
	for bug-bash@gnu.org; Thu, 26 Apr 2012 08:28:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNNo4-0005Wj-Hy
	for bug-bash@gnu.org; Thu, 26 Apr 2012 08:28:30 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45765
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNNo4-0005WQ-CP
	for bug-bash@gnu.org; Thu, 26 Apr 2012 08:28:20 -0400
Received: (qmail 17224 invoked from network); 26 Apr 2012 12:28:17 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Thu, 26 Apr 2012 08:28:17 -0400
Received: (qmail 3637 invoked by uid 563); 26 Apr 2012 12:28:16 -0000
Date: Thu, 26 Apr 2012 08:28:16 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Clark Wang <clark.wang@oracle.com>
Subject: Re: Passing variables by reference conflicts with local
Message-ID: <20120426122816.GS22241@eeg.ccf.org>
References: <r2pc440c9801005010240o2388c72fjb8ce0aa6b123d19c@mail.gmail.com>
	<20100501112118.GB4615@rebase.prov>
	<o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 12:28:36 -0000

On Mon, Apr 23, 2012 at 04:56:09PM +0800, Clark Wang wrote:
> When I revisit this 2 years old thread I don't understand why following
> foo() function does not output the global var:
> 
> $ cat foo.sh
> var=global
> foo()
> {
>     local var=foo
>     unset var
>     echo foo: $var
> }
> bar_unset()
> {
>     unset var
> }
> bar()
> {
>     local var=bar
>     bar_unset
>     echo bar: $var
> }
> foo
> bar
> $ bash foo.sh
> foo:
> bar: global
> $
> 
> In foo() it unsets its local var so why doesn't the subsequent $var refer
> to the global var?

Well, the manual certainly doesn't give enough information to figure it
out.

      unset [-fv] [name ...]
           For each name, remove the corresponding variable or function.  If
           no options are supplied, or the -v option is given, each name
           refers to a shell variable.  Read-only variables may not be
           unset.  If -f is specified, each name refers to a shell function,
           and the function definition is removed.  Each unset variable or
           function is removed from the environment passed to subsequent
           commands.  If any of COMP_WORDBREAKS, RANDOM, SECONDS, LINENO,
           HISTCMD, FUNCNAME, GROUPS, or DIRSTACK are unset, they lose their
           special properties, even if they are subsequently reset.  The
           exit status is true unless a name is readonly.

Apparently there's a lot more going on than just "remove the corresponding
variable or function".

http://fvue.nl/wiki/Bash:_Unset says that unset will "traverse down the
call-stack and unset variables repeatedly", which is fine, but that
still doesn't explain what you're asking.

So, here's my guess: when you unset a local variable within the same
function where the variable was defined, bash assumes you explicitly
want the variable to remain unset within that function.  In foo(),
you make a local var and then unset var.  Bash believes you expect $var
to be empty for that function.

However, when you unset a variable from a different function where it's
*not* locally defined, then unset traverses back through the dynamic
scope stack of definitions for that variable, and whacks the topmost one.
Thus, in bar_unset(), you call unset var, but there's no local copy of
var, so it looks back through the stack, finds one in bar(), and gets
rid of that one.  Then the only remaining definition of var is the global
one.  So when you return to bar(), only the global one remains.


From MAILER-DAEMON Thu Apr 26 11:54:49 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNR1t-0007GY-SJ
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 11:54:49 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34565)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SNR1n-0007GN-28
	for bug-bash@gnu.org; Thu, 26 Apr 2012 11:54:48 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SNR1g-00031Q-PU
	for bug-bash@gnu.org; Thu, 26 Apr 2012 11:54:42 -0400
Received: from mail-ey0-f169.google.com ([209.85.215.169]:61018)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SNR1g-0002wF-Cu
	for bug-bash@gnu.org; Thu, 26 Apr 2012 11:54:36 -0400
Received: by eaal1 with SMTP id l1so390475eaa.0
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 08:54:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=BkgO49mEbHY9yt2cxjBIYCwKpd8SBQODRKi+J+3fjag=;
	b=AVczHeZN8XCxEx6hfg8yLlqe7NrAaDzh83xQx6vpp4jhbXEwQF64wUEJB6difqNcBz
	CWqgNru2K6qR2GVb2RGkbozfkZz8wd8hu59hG2JMuKOoE109A7BMIebmhTwlzhGcjbE9
	fcSfhEiMLCs5QfUtf9DmqA5k3H1pNj5Sx0RsI=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=BkgO49mEbHY9yt2cxjBIYCwKpd8SBQODRKi+J+3fjag=;
	b=l/nxu4MXeVT+GeYERI2Mw3s1sqEn+Fb8OsNppam8VLkdUqqNexerXl4nLUcTIOMfRZ
	Ifu56tbGfhFBmTxcL9iLPKdsvnxY1l2Z/QnIX41w0V0DXJthMnlytqK8wNUcQI7A+04y
	LZFuKwt0WLhM3NmpwyC5yGKK2ja4RKBt1nV9yS7f7Pr1e6ygLEGbfzJT1H4q7ZOiILa2
	dV8oqW7nEF77a9OXQWcRtsifiVYI1MXX41f798cE2Dau9C3IBazpB4Fd1KUmJebMZ1hK
	4/+GPimFPhuxuCmN4WPT/8cAQ3ctkc0L8Fare/194U+VWW3taLLxzE/zGmEuZH4Ag8D2
	E6jg==
Received: by 10.14.94.195 with SMTP id n43mr1834889eef.57.1335455673278;
	Thu, 26 Apr 2012 08:54:33 -0700 (PDT)
Received: from [10.5.0.13] (satura.lyndir.com. [178.63.61.197])
	by mx.google.com with ESMTPS id m42sm16413791eef.0.2012.04.26.08.54.29
	(version=TLSv1/SSLv3 cipher=OTHER);
	Thu, 26 Apr 2012 08:54:31 -0700 (PDT)
Subject: Re: Severe Bash Bug with Arrays
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_5320748F-B631-4321-B91B-8479DF110C87";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <4F98863D.7070005@tlinx.org>
Date: Thu, 26 Apr 2012 17:54:27 +0200
Message-Id: <7825D6C5-E66D-4EB3-80D3-8A525AC6434F@lyndir.com>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<4F98863D.7070005@tlinx.org>
To: Linda Walsh <bash@tlinx.org>
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQnSLdH+ewYRr7tMWxMlxePrmiDo7rtwMd9rNm/HO3qyDBW5o5RQdSeZu0h0/OHwoJH4sJ+e
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.215.169
Cc: Ted Okuzumi <tedokuzumi@gmail.com>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 15:54:48 -0000


--Apple-Mail=_5320748F-B631-4321-B91B-8479DF110C87
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 26 Apr 2012, at 01:18, Linda Walsh wrote:
>=20
> Ishtar:> echo "${b[*]}"

Please note that expanding array elements using [*] is usually NOT what =
anyone wants.  Be careful about recommending it to anyone.

"${b[*]}" # This throws away any usefulness of the array by merging all =
the array elements into one single string (argument), concatenating the =
elements using the first character of IFS.
${b[*]} # Never do this.  On top of throwing away the usefulness of your =
array like above, you then follow up by re-splitting the whole thing =
using standard wordsplitting, not to mention pathname expanding the =
resulting words.

"${b[@]}" # Expands each array element as a separate argument, =
protecting it from wordsplitting and pathname expansion mutilation.
${b[@]} # Identical to and just as broken as ${b[*]}.  Never do this.

You should always recommend the "${b[@]}" variant.  "${b[*]}" is rarely =
useful in the event that your intent is to merge the array into a single =
string, eg. for displaying elements to a user:
dirs=3D(*/)
(IFS=3D,; echo "The dirs are: ${dirs[*]}")

But anyway, that's an aside from this topic, which has very little to do =
with this.=

--Apple-Mail=_5320748F-B631-4321-B91B-8479DF110C87
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDI2MTU1NDI4WjAjBgkqhkiG9w0BCQQx
FgQUVja7tdKYyra0E/CKaTg2NqVl560wgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGAGVo3TJvxL/r0/XP8M5vOtzeP
S8VgSF1v2TZzOiJ/JwOF+Lfp0bBvUpuJ/Nmv4aDYhtQD8eHarVdqCjpv3BRvhfKgKO+y3ekrLq9q
Xrkc8W/iPdHi+sxFnFs8J7cJPkxwUW5JU5i9hmCo0LRUEcscdXZJsKrUnkIqTj0z2bdVVeAAAAAA
AAA=

--Apple-Mail=_5320748F-B631-4321-B91B-8479DF110C87--


From MAILER-DAEMON Thu Apr 26 12:00:17 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNR7B-00020E-Mp
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 12:00:17 -0400
Received: from eggs.gnu.org ([208.118.235.92]:38265)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SNR70-0001go-Da
	for bug-bash@gnu.org; Thu, 26 Apr 2012 12:00:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SNR6r-0004zr-Pm
	for bug-bash@gnu.org; Thu, 26 Apr 2012 12:00:05 -0400
Received: from mail-ey0-f169.google.com ([209.85.215.169]:42458)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lhunath@lyndir.com>) id 1SNR6r-0004zf-Gl
	for bug-bash@gnu.org; Thu, 26 Apr 2012 11:59:57 -0400
Received: by eaal1 with SMTP id l1so392250eaa.0
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 08:59:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndir.com; s=google;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer;
	bh=pfQPrZlb+rzwrKa3HCg8WigZRq9PoV8BV+lCw2AjaaE=;
	b=WNjzyWc7br1NhrUz+LkaCCZj2M36B4QGzKRy4djtrwhSpwqbmUY3XVJtZB/vlkKmQl
	eIKQ40xDm4NP+i6KQ4mWBG1GtviKvjUlyUgd128VwejxuOMJOLwfMKK8IywmauMeZQU/
	zGYeeh0L0o2IJSSpmZUa7GFzQiUIgjJS2lYh4=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=subject:mime-version:content-type:from:in-reply-to:date:cc
	:message-id:references:to:x-mailer:x-gm-message-state;
	bh=pfQPrZlb+rzwrKa3HCg8WigZRq9PoV8BV+lCw2AjaaE=;
	b=P9uSxCb1Kenrb/pCABUy55A74ovb7a1udbb7oSCTqqEUlL0SYxfLekHJ/FnBspTnv2
	nLpMRE70hAJ+YHSH+vzX8n2w78LVH4j2lQJ+SwpnNVi/k3Yyy6AYnEa/4lnwV9Hseudq
	E7q47CKAQaVchE11nbYkJjxx1ejo6fyDGOSaBY7pwyupx37xFu9FhJg7zoblQj6K2Wkw
	7TWvIHxCmdeImsU8MuP1a/6KfJ5uQIGBO+4WbQ7iHYTyX4Ewi7+k90MrHFWvrxbzPBIw
	/hSYEN5kYVH4HCrO1K/+XBaC4SFMhbL26a/f20U+Hv+ethXveR9q8cJo0kjjd51wJ/Dw
	Xzyw==
Received: by 10.14.98.75 with SMTP id u51mr1844448eef.35.1335455995274;
	Thu, 26 Apr 2012 08:59:55 -0700 (PDT)
Received: from [10.5.0.13] (satura.lyndir.com. [178.63.61.197])
	by mx.google.com with ESMTPS id d54sm16408700eei.9.2012.04.26.08.59.53
	(version=TLSv1/SSLv3 cipher=OTHER);
	Thu, 26 Apr 2012 08:59:54 -0700 (PDT)
Subject: Re: Is it possible or RFE to expand ranges of *arrays*
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_1DFDC304-A41C-48FD-A47B-C270035EA17D";
	protocol="application/pkcs7-signature"; micalg=sha1
From: Maarten Billemont <lhunath@lyndir.com>
In-Reply-To: <4F98CF5B.6050306@web.de>
Date: Thu, 26 Apr 2012 17:59:51 +0200
Message-Id: <17EB4457-C08E-4BCF-9788-2716954A06DB@lyndir.com>
References: <4F98CE62.3040601@tlinx.org> <4F98CF5B.6050306@web.de>
To: John Kearney <dethrophes@web.de>
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQk5WDoBnVXuwllcw2tOLtQSezQ33zWjtDOHxOVsMDN39e11LC78Jzn9HVmSTMVIdQMC5/qt
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.215.169
Cc: Linda Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 16:00:15 -0000


--Apple-Mail=_1DFDC304-A41C-48FD-A47B-C270035EA17D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 26 Apr 2012, at 06:30, John Kearney wrote:
> Am 26.04.2012 06:26, schrieb Linda Walsh:
>> I know I can get
>> a=3D"abcdef" echo "${a[2:4]}" =3D cde
>>=20
>> how do I do:
>> typeset -a a=3D(apple berry cherry date); then get:
>>=20
>> echo ${a[1:2]} =3D "berry" "cherry"  ( non-grouped args)
>>=20
>> I tried to do it in a function and hurt myself.
>>=20
>>=20
>>=20
> echo ${a[@]:1:2}
>=20

I see little reason to ask bash to wordsplit the elements after =
expanding them.  You ought to quote that expansion.=

--Apple-Mail=_1DFDC304-A41C-48FD-A47B-C270035EA17D
Content-Disposition: attachment;
	filename=smime.p7s
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDujCCA7Yw
ggKeoAMCAQICAhAJMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJCRTEYMBYGA1UECBMPT29z
dCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYDVQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5
bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2luZm9AbHluZGlyLmNv
bTAeFw0xMTEyMTkxMDM1NTVaFw0xMjEyMTgxMDM1NTVaMGQxCzAJBgNVBAYTAkJFMRgwFgYDVQQI
Ew9Pb3N0IFZsYWFuZGVyZW4xDTALBgNVBAcTBEdlbnQxDzANBgNVBAoTBkx5bmRpcjEbMBkGA1UE
AxQSbGh1bmF0aEBseW5kaXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuWlkIn09T
3Q21oZau4Eg/sZinlXAeOt/LfH6iuDvfq9uyNkuIBDvuFVyXhZW06p32V6TGplJ/NFH9yBorri5K
tbI+haHz9BUqKWLQ4sfvS5ofAMOUUVSkMxd5zIsZAZzocQRhw5oArQntcWxF1cRI9Ts1Q4n/RaUl
jUg4D/iU+wIDAQABo4HKMIHHMAkGA1UdEwQCMAAwHQYDVR0OBBYEFP/K5sYiDjhhP3T21jlpXtx/
HnbXMB8GA1UdIwQYMBaAFAQZYDwDUZk4gQgebrI2O+oG8Jn7MB0GA1UdEQQWMBSBEmxodW5hdGhA
bHluZGlyLmNvbTAaBgNVHRIEEzARgQ9pbmZvQGx5bmRpci5jb20wPwYJYIZIAYb4QgEEBDIWMGh0
dHBzOi8vc3NsLmx5bmRpci5jb20vcGtpL2NybC9jYS5seW5kaXIuY29tLnBlbTANBgkqhkiG9w0B
AQUFAAOCAQEAUrQSsbacRMfs1aKNzO3cOvmPZzw/fSsSF0xnieD2Q+dOZeZlIq40Q/gzQylXBNeX
wOQD5KpTo0amoA5HACA5x7KT9/FPLiB+Er6fH7fSNbTDwSE1cPR7igRRGJKCy12ZCzlIpX7BhI/h
XEaFysf9I095crExLT8ouFCvXsj3FuvZOMhBBSZ90roQAxzU9MRz9BozBWfCqZQhP7/AV5yYEiJu
rmqx5fUk+cBmL29RVtoTQS9ebYPAsZsklmfHwcpsKD+QupxxCKmgv3vJCn7/+64zvg21MWGsNxw3
S4GjrC33LKqRSOyv7jHCUYuo6IAeoq9T2ZRIcC35AtY+mEtYfzGCAvEwggLtAgEBMIGVMIGOMQsw
CQYDVQQGEwJCRTEYMBYGA1UECBMPT29zdCBWbGFhbmRlcmVuMQ0wCwYDVQQHEwRHZW50MQ8wDQYD
VQQKEwZMeW5kaXIxJTAjBgNVBAMTHEx5bmRpciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHjAcBgkq
hkiG9w0BCQEWD2luZm9AbHluZGlyLmNvbQICEAkwCQYFKw4DAhoFAKCCAbEwGAYJKoZIhvcNAQkD
MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTIwNDI2MTU1OTUxWjAjBgkqhkiG9w0BCQQx
FgQUwWF9apGNux4OI+R1rpJ0GBXokcgwgaYGCSsGAQQBgjcQBDGBmDCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMIGoBgsqhkiG9w0BCRACCzGBmKCBlTCBjjELMAkGA1UEBhMC
QkUxGDAWBgNVBAgTD09vc3QgVmxhYW5kZXJlbjENMAsGA1UEBxMER2VudDEPMA0GA1UEChMGTHlu
ZGlyMSUwIwYDVQQDExxMeW5kaXIgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkB
Fg9pbmZvQGx5bmRpci5jb20CAhAJMA0GCSqGSIb3DQEBAQUABIGARGAl4AmOgFWde1Pi6lpw+XX9
V5DenDHrRg0RwRx5QxOjz+4aKHmW0Mo78+Zx9sZ867/6awLZN1vk9yEDZSoFmsJepHRP7dcspAaG
L3CI1WuNUeD68mCLDMmXtx+z93UwitK5S08Mcut17aYjMIn3r3GQqFwSmn7HycUaxTLtrqQAAAAA
AAA=

--Apple-Mail=_1DFDC304-A41C-48FD-A47B-C270035EA17D--


From MAILER-DAEMON Thu Apr 26 14:02:28 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNT1Q-0007vN-IA
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 14:02:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57393)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bill@ycc.com>) id 1SNT1N-0007uL-Ns
	for bug-bash@gnu.org; Thu, 26 Apr 2012 14:02:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bill@ycc.com>) id 1SNT1L-000289-Kp
	for bug-bash@gnu.org; Thu, 26 Apr 2012 14:02:25 -0400
Received: from mail-lpp01m010-f41.google.com ([209.85.215.41]:49871)
	by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <bill@ycc.com>)
	id 1SNT1L-00027e-8l
	for bug-bash@gnu.org; Thu, 26 Apr 2012 14:02:23 -0400
Received: by lagz14 with SMTP id z14so1373656lag.0
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 11:02:20 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=mime-version:x-originating-ip:in-reply-to:references:date
	:message-id:subject:from:cc:content-type:x-gm-message-state;
	bh=dn2e4QWuSKNg8gAttvSbta5kzCTj46o5IX8Ekthcyq8=;
	b=Hgcg2SBRxELYsRhfgeMTvC60NzqBXEgBHd6+VxavNgjfV3DmNsBaVGGhjx8yl0s+ib
	2j2qEX01eK4qrNaLyC1emMNGpIzmXpR8aCulpnlvt8+DUZGJH9TrdmQF7TH+ENcT22iC
	KLawzuMmByxTCWNcen6JYfCCUvY+bQiuoIFjKzbNFjjmLLRqikrIsUyiPHPflQRjVE3E
	mKKrm2K3/I5k6FejtFedULmTujoM5cLnhGy3emkXBqV9UFr9x7BrRO0ghObtp1zGvN7n
	TnqKf9XX9tuLX/Nqhqv8aTEtwnINe8gn4DRQR3qdLWiprYm9Avrw+ayml0ycSzW3VkFn
	urGw==
MIME-Version: 1.0
Received: by 10.112.48.6 with SMTP id h6mr3691394lbn.94.1335463340585; Thu, 26
	Apr 2012 11:02:20 -0700 (PDT)
Received: by 10.112.109.106 with HTTP; Thu, 26 Apr 2012 11:02:20 -0700 (PDT)
X-Originating-IP: [186.2.144.37]
In-Reply-To: <20120426122816.GS22241@eeg.ccf.org>
References: <r2pc440c9801005010240o2388c72fjb8ce0aa6b123d19c@mail.gmail.com>
	<20100501112118.GB4615@rebase.prov>
	<o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
	<20120426122816.GS22241@eeg.ccf.org>
Date: Thu, 26 Apr 2012 12:02:20 -0600
Message-ID: <CAFyvKit4rt7bAk8nNEsXFXXe+tz+YVQ3FWOA-2CDC1fP_b4=Pw@mail.gmail.com>
Subject: Re: Passing variables by reference conflicts with local
From: Bill Gradwohl <bill@ycc.com>
Cc: bug-bash@gnu.org
X-Gm-Message-State: ALoCoQl0s82xGz+EMyiK/KeIJSDPoQV4s3kdis4PUvvcnOu8mdcIXPT1glmtVoHKu0cpB9Vq4NLM
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.215.41
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 18:02:27 -0000

I added a bit if code to show some things that I did and did not expect.

#!/bin/bash

var=global

foo() {
    echo
    local var=foo
    unset var
    echo ${FUNCNAME[@]}: $var
    displayVar

    displayVarfoo() {
       echo ${FUNCNAME[@]}: $var
    }
    displayVarfoo
}

bar_unset() {
    unset var
    echo ${FUNCNAME[@]}: $var
    displayVar
    displayVarbar_unset() {
       echo ${FUNCNAME[@]}: $var
    }
    displayVarbar_unset
    echo
    newVar=bar_unset
}

bar() {
    echo
    local var=bar
    bar_unset
    echo ${FUNCNAME[@]}: $var $newVar
    displayVar
    displayVarbar() {
       echo ${FUNCNAME[@]}: $var $newVar
    }
    displayVarbar
}

displayVar() {
   echo ${FUNCNAME[@]}: $var $newVar
}

foo
bar
echo $var $newVar

Produces:
root@billlaptop ycc# ./zzz

foo main:
displayVar foo main:
displayVarfoo foo main:

bar_unset bar main: global
displayVar bar_unset bar main: global
displayVarbar_unset bar_unset bar main: global

bar main: global bar_unset
displayVar bar main: global bar_unset
displayVarbar bar main: global bar_unset
global bar_unset

With both internal and external display functions, I don't see a change in
their view of the world. That was expected as there's no such thing as a
nested or sub function from what I've been able to determine. All functions
live just below main and no matter how defined nested or not, they all end
up at the same level.   Correct?

It appears that in foo, once the name is unset, any sub function in the
call chain can no longer see that name. So, if you want to make sure a sub
function can't touch a variable, put another function in between that
localises and then unsets the variable.

When newVar is created in bar_unset, it is created at the main level.
bar_unset is long gone and the variable it created lives on in Main. The
tail wagging the dog comes to mind.

If there's another interpretation than the one I came up with, please
correct me as much of this is guess work on my part.

-- 
Bill Gradwohl

From MAILER-DAEMON Thu Apr 26 14:16:38 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNTF8-0003rh-3f
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 14:16:38 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56991)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNTF6-0003r1-5q
	for bug-bash@gnu.org; Thu, 26 Apr 2012 14:16:37 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNTF3-00081Y-Cv
	for bug-bash@gnu.org; Thu, 26 Apr 2012 14:16:35 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45860
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNTF3-0007wE-6F
	for bug-bash@gnu.org; Thu, 26 Apr 2012 14:16:33 -0400
Received: (qmail 20287 invoked from network); 26 Apr 2012 18:16:07 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Thu, 26 Apr 2012 14:16:07 -0400
Received: (qmail 4062 invoked by uid 563); 26 Apr 2012 18:16:06 -0000
Date: Thu, 26 Apr 2012 14:16:06 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Maarten Billemont <lhunath@lyndir.com>
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120426181606.GT22241@eeg.ccf.org>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<4F98863D.7070005@tlinx.org>
	<7825D6C5-E66D-4EB3-80D3-8A525AC6434F@lyndir.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <7825D6C5-E66D-4EB3-80D3-8A525AC6434F@lyndir.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 18:16:37 -0000

On Thu, Apr 26, 2012 at 05:54:27PM +0200, Maarten Billemont wrote:
> On 26 Apr 2012, at 01:18, Linda Walsh wrote:
> > 
> > Ishtar:> echo "${b[*]}"
> 
> You should always recommend the "${b[@]}" variant.  "${b[*]}" is rarely useful in the event that your intent is to merge the array into a single string, eg. for displaying elements to a user:
> dirs=(*/)
> (IFS=,; echo "The dirs are: ${dirs[*]}")
> 
> But anyway, that's an aside from this topic, which has very little to do with this.

If the goal is to see the contents of an array, I'd use one of these,
depending on how much detail I need:

printf '<%s> ' "${array[@]}"; echo

declare -p array


From MAILER-DAEMON Thu Apr 26 14:49:21 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNTkn-0003d2-KY
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 14:49:21 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34440)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNTkk-0003X0-LX
	for bug-bash@gnu.org; Thu, 26 Apr 2012 14:49:19 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNTkf-00072R-E6
	for bug-bash@gnu.org; Thu, 26 Apr 2012 14:49:18 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45874
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNTkf-0006uq-7f
	for bug-bash@gnu.org; Thu, 26 Apr 2012 14:49:13 -0400
Received: (qmail 20556 invoked from network); 26 Apr 2012 18:49:09 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Thu, 26 Apr 2012 14:49:09 -0400
Received: (qmail 4168 invoked by uid 563); 26 Apr 2012 18:49:08 -0000
Date: Thu, 26 Apr 2012 14:49:08 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Bill Gradwohl <bill@ycc.com>
Subject: Re: Passing variables by reference conflicts with local
Message-ID: <20120426184908.GV22241@eeg.ccf.org>
References: <o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
	<20120426122816.GS22241@eeg.ccf.org>
	<CAFyvKit4rt7bAk8nNEsXFXXe+tz+YVQ3FWOA-2CDC1fP_b4=Pw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAFyvKit4rt7bAk8nNEsXFXXe+tz+YVQ3FWOA-2CDC1fP_b4=Pw@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 18:49:20 -0000

On Thu, Apr 26, 2012 at 12:02:20PM -0600, Bill Gradwohl wrote:
> bar_unset() {
>     unset var
>     echo ${FUNCNAME[@]}: $var
>     displayVar
>     displayVarbar_unset() {
>        echo ${FUNCNAME[@]}: $var
>     }
>     displayVarbar_unset
>     echo
>     newVar=bar_unset
> }

> When newVar is created in bar_unset, it is created at the main level.
> bar_unset is long gone and the variable it created lives on in Main. The
> tail wagging the dog comes to mind.

All variables are global unless declared local.  Since you don't have
newVar defined in any local scope, the final assignment in bar_unset
creates it at the global scope.

I don't see this as a surprise.  It's how you return values from functions
in bash.  Pick a global variable (r, ret, whatever you want) and stuff the
return value into that.  You can even declare your "r" locally somewhere
so that the value never propagates up higher than that point in the call
chain.

For example:

# Return random number from 0 to ($1-1) in variable "r"
rand() {
  local max=$((32768 / $1 * $1));
  while (( (r=$RANDOM) >= max )); do :; done
  r=$((r % $1))
}

foo() {
  local r
  rand 42
  ... use $r ...
}

foo
... we don't see "r" here because it was scoped only within foo & its kids ...


From MAILER-DAEMON Thu Apr 26 15:38:06 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNUVy-0007KV-6M
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 15:38:06 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59527)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bill@ycc.com>) id 1SNUVv-0007KG-3x
	for bug-bash@gnu.org; Thu, 26 Apr 2012 15:38:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bill@ycc.com>) id 1SNUVt-00037u-7E
	for bug-bash@gnu.org; Thu, 26 Apr 2012 15:38:02 -0400
Received: from mail-lb0-f169.google.com ([209.85.217.169]:45975)
	by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <bill@ycc.com>)
	id 1SNUVs-00037b-RB
	for bug-bash@gnu.org; Thu, 26 Apr 2012 15:38:01 -0400
Received: by lbbgg6 with SMTP id gg6so1463411lbb.0
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 12:37:57 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=google.com; s=20120113;
	h=mime-version:x-originating-ip:in-reply-to:references:date
	:message-id:subject:from:cc:content-type:x-gm-message-state;
	bh=r0LqimWY2lo8GqqBojlhw37bEN0CKITKbAKm8A8w3E8=;
	b=kTLdpmQK+tQ5lRSyE65+xrMe+X50+06MRrMkSak9mcanQ5Cefs9wTjVRgOnxN7h5wu
	/EcdOzbG7q+OJ3A9ncN8zbk6nnHU8CikuienpDrzqx92yMPy8wi3+A8GFdmClwkrTko+
	3jqNolcRrLx2DNCHxlhcMmHeaRwze+WiCsUkTf4mOp5ozJKfKShA0CWzr8kGSkSlOyTd
	qTkuHOI7o3wHLXwU/rBZmLC3OQJnqetDlsoa7M1HoRtDmKJjmlYHKI+v26VWDWT4Q7rQ
	78m2Q+0trU8O5eRQMjyL6ECuqWL9NL2B5S1BJHO/l0+4Swcm/vJXgzf5IHircFesEAyo
	vN5Q==
MIME-Version: 1.0
Received: by 10.112.48.6 with SMTP id h6mr3853951lbn.94.1335469077474; Thu, 26
	Apr 2012 12:37:57 -0700 (PDT)
Received: by 10.112.109.106 with HTTP; Thu, 26 Apr 2012 12:37:57 -0700 (PDT)
X-Originating-IP: [186.2.144.37]
In-Reply-To: <20120426184908.GV22241@eeg.ccf.org>
References: <o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
	<20120426122816.GS22241@eeg.ccf.org>
	<CAFyvKit4rt7bAk8nNEsXFXXe+tz+YVQ3FWOA-2CDC1fP_b4=Pw@mail.gmail.com>
	<20120426184908.GV22241@eeg.ccf.org>
Date: Thu, 26 Apr 2012 13:37:57 -0600
Message-ID: <CAFyvKivC1VB9pqdG6C+msCHttj2MOwX_N3gYvE36WVw0HCBXDw@mail.gmail.com>
Subject: Re: Passing variables by reference conflicts with local
From: Bill Gradwohl <bill@ycc.com>
Cc: bug-bash@gnu.org
X-Gm-Message-State: ALoCoQnZ0pkr8MLXHWFFLx041YExOD/sP67Hfg1Iu/PBHisFf57Fl4OEp3B+og9BSgoNKZ5DgXjw
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.217.169
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 19:38:04 -0000

On Thu, Apr 26, 2012 at 12:49 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:

> I don't see this as a surprise.  It's how you return values from functions
> in bash.  Pick a global variable (r, ret, whatever you want) and stuff the
> return value into that.  You can even declare your "r" locally somewhere
> so that the value never propagates up higher than that point in the call
> chain.
>
> For example:
>
> # Return random number from 0 to ($1-1) in variable "r"
> rand() {
>  local max=$((32768 / $1 * $1));
>  while (( (r=$RANDOM) >= max )); do :; done
>  r=$((r % $1))
> }
>
> foo() {
>  local r
>  rand 42
>  ... use $r ...
> }
>
> foo
> ... we don't see "r" here because it was scoped only within foo & its kids
> ...
>


Your example is what I always do. I create a variable (local or global -
its non of the called functions business which) and then I call a function
and allow it to use that variable to return an answer. When the function
ends it hasn't altered the global name space.

In the example I presented, the opposite is occurring. The function being
called creates the return variable and necessarily does it in the global
name space. When the function quits, the global it created lives on. It
just never occurred to me to try that and was surprised that the tail could
wag the dog.

If I'm several levels deep into function calls when I create a local
variable and then call a function that I allow to use that variable, that
has a semblance of control. The parent is supplying something the child may
use. When the child creates a global to pass back information, and then
terminates, the parent had no control over that variables creation and is
now stuck with something in the global name space that via the hierarchy of
calls, it doesn't properly own. I would never purposely write code that did
that, and was surprised that bash allows it.

-- 
Bill Gradwohl

From MAILER-DAEMON Thu Apr 26 15:46:11 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNUdn-0007zD-9c
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 15:46:11 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37721)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNUdl-0007yx-Aa
	for bug-bash@gnu.org; Thu, 26 Apr 2012 15:46:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNUdj-0006So-LB
	for bug-bash@gnu.org; Thu, 26 Apr 2012 15:46:08 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:45907
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNUdj-0006Sa-EW
	for bug-bash@gnu.org; Thu, 26 Apr 2012 15:46:07 -0400
Received: (qmail 21122 invoked from network); 26 Apr 2012 19:46:04 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Thu, 26 Apr 2012 15:46:04 -0400
Received: (qmail 4416 invoked by uid 563); 26 Apr 2012 19:46:04 -0000
Date: Thu, 26 Apr 2012 15:46:04 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Bill Gradwohl <bill@ycc.com>
Subject: Re: Passing variables by reference conflicts with local
Message-ID: <20120426194604.GA4278@eeg.ccf.org>
References: <m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
	<20120426122816.GS22241@eeg.ccf.org>
	<CAFyvKit4rt7bAk8nNEsXFXXe+tz+YVQ3FWOA-2CDC1fP_b4=Pw@mail.gmail.com>
	<20120426184908.GV22241@eeg.ccf.org>
	<CAFyvKivC1VB9pqdG6C+msCHttj2MOwX_N3gYvE36WVw0HCBXDw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAFyvKivC1VB9pqdG6C+msCHttj2MOwX_N3gYvE36WVw0HCBXDw@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 19:46:10 -0000

On Thu, Apr 26, 2012 at 01:37:57PM -0600, Bill Gradwohl wrote:
> When the child creates a global to pass back information, and then
> terminates, the parent had no control over that variables creation and is
> now stuck with something in the global name space that via the hierarchy of
> calls, it doesn't properly own. I would never purposely write code that did
> that, and was surprised that bash allows it.

All variables are global by default.  Local variables are a special
bash feature.  POSIX shells don't even necessarily *have* the capability
of making local variables.

Remember, bash is a shell.  It also has a few features that you'd expect
in a programming language, but it is first and foremost a command
interpreter.


From MAILER-DAEMON Thu Apr 26 16:17:39 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNV8F-0005T4-FI
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 16:17:39 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44527)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1SNV8D-0005Sy-JL
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:17:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1SNV8B-000097-NR
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:17:37 -0400
Received: from caiajhbdccac.dreamhost.com ([208.97.132.202]:52506
	helo=homiemail-a2.g.dreamhost.com)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1SNV8B-00008o-AK
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:17:35 -0400
Received: from homiemail-a2.g.dreamhost.com (localhost [127.0.0.1])
	by homiemail-a2.g.dreamhost.com (Postfix) with ESMTP id C5E9D28006D;
	Thu, 26 Apr 2012 13:17:32 -0700 (PDT)
DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:cc:subject
	:date:message-id:mime-version:content-type; q=dns;
	s=jidanni.org
	; b=IDsa/fclMMdGJ/jzC9lYin3XY3HrQvOhAK4QmyJHhTd86BjKJbcojf9ZsrIO
	IyUKzyzzJKl9jcbWfYzgef+0svspHCezZ5rdvPjbTy30bGhpsDWn7/caf3xErDOy
	8vjv6JAcMT7zsncQX3QVUfCDAeXR0cLGwwz24+mtAFonP24=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc
	:subject:date:message-id:mime-version:content-type; s=
	jidanni.org; bh=KxuEu/b79eXgdgv4gefpku8nvR4=; b=TnKvRJRs7w7i67ov
	egQ5Nb8vKJpHzPDbfn5NvlnmTJeLxAGEcZxezoW1kQtcv4XFbLnaE+KdWr9pvWQ2
	L3vvM9TpO+nJMxNnEZJBZ3KAld3k7zhyi5BVVGkf1sW3VE/XNMHC/tWB9o7j0f/k
	o+An83bSd+mLm4YBDL1jrVxRtmY=
Received: from jidanni.org (218-163-18-197.dynamic.hinet.net [218.163.18.197])
	(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 6AD85280069; 
	Thu, 26 Apr 2012 13:17:32 -0700 (PDT)
From: jidanni@jidanni.org
To: bug-bash@gnu.org
Subject: protection against accidental massive pastes into the command line
Date: Fri, 27 Apr 2012 04:17:26 +0800
Message-ID: <87wr52cko9.fsf@jidanni.org>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 208.97.132.202
Cc: dickey@invisible-island.net
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 20:17:38 -0000

Maybe there should be a limit, MAX_INTERACTIVE_COMMAND_LENGTH on how
much can be fed into one bash command line, any more and bash should
beep and reject the whole command.

Otherwise an innocent middle click, or SHIFT INSERT slip of the fingers
could paste an entire book out of the clipboard, into the command line,
which would then cause bash to try to execute every line.


From MAILER-DAEMON Thu Apr 26 16:18:31 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNV95-0005tB-Qf
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 16:18:31 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44632)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1SNV92-0005t5-Mk
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:18:29 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1SNV91-0000Ge-46
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:18:28 -0400
Received: from caiajhbdccah.dreamhost.com ([208.97.132.207]:37943
	helo=homiemail-a61.g.dreamhost.com)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1SNV90-0000GM-SB
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:18:27 -0400
Received: from homiemail-a61.g.dreamhost.com (localhost [127.0.0.1])
	by homiemail-a61.g.dreamhost.com (Postfix) with ESMTP id 07713578077;
	Thu, 26 Apr 2012 13:18:25 -0700 (PDT)
DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:cc:subject
	:date:message-id:mime-version:content-type; q=dns;
	s=jidanni.org
	; b=AVk7qgPPIvrYcXYYmyaCKyrwe7mgi4aVEL3X8zcsMpDgRrALKz07dBug8cjS
	O3BrdcDR1Lv8b7S7TkoQ5pyGwp/9ze9B7C3Z1o9QXuIkMU6bhOcPPuDZR5EwOiHA
	dl71L4imaprmoG3pAZ1Gh47C8NseLwi0CNKG4CVNp5Kba3w=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc
	:subject:date:message-id:mime-version:content-type; s=
	jidanni.org; bh=BNHSC+qcgKk9EDokS8xqjH9sffE=; b=iEXGfnVZZE8ULXVq
	o7mnrhKllWs/Lib0+KNtlacRjGuIpu+uf6DGob006urSS1EBrDVR2/LFfJKlaneO
	LkQHHGt5EvJxmAUd5u6KsP7scSxOfFxEm0zueIT5EHLVPDBbtU/yFl9f0R2ifpbx
	5miP1iZXDOfliQmOl9eGkwHXByg=
Received: from jidanni.org (218-163-18-197.dynamic.hinet.net [218.163.18.197])
	(using TLSv1 with cipher AES256-SHA (256/256 bits))
	(No client certificate requested)
	(Authenticated sender: jidanni@jidanni.org)
	by homiemail-a61.g.dreamhost.com (Postfix) with ESMTPSA id 9A74A578071; 
	Thu, 26 Apr 2012 13:18:24 -0700 (PDT)
From: jidanni@jidanni.org
To: bug-bash@gnu.org
Subject: Re: protection against accidental massive pastes into the command line
Date: Fri, 27 Apr 2012 04:18:21 +0800
Message-ID: <87vckmckmq.fsf@jidanni.org>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 208.97.132.207
Cc: dickey@invisible-island.net
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 20:18:30 -0000

This would also save on later having to clean the massive blob out of
the history list.


From MAILER-DAEMON Thu Apr 26 16:41:31 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNVVL-0000Hx-DD
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 16:41:31 -0400
Received: from eggs.gnu.org ([208.118.235.92]:60682)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SNVVJ-0000H4-94
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:41:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SNVVH-0008KU-HS
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:41:28 -0400
Received: from mail-ob0-f169.google.com ([209.85.214.169]:40890)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <pyroinajar@gmail.com>) id 1SNVVH-0008KJ-A9
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:41:27 -0400
Received: by obbeh20 with SMTP id eh20so44822obb.0
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 13:41:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type;
	bh=R2ftF+lro7QdQwkxaVglppSmYr5f+2n0Be6YlC/ma8o=;
	b=f+naHswkUtBjAm/3VGcbB5jOCD0dxEFG/ZqTcTxDMdUQuYP7Tdp4s+4yUMaCVfCYoG
	vsS7dGEMiSqCyKJbsqPc3Y6+kmqQjz5xx5WwKXDlXqsd3DuBATYJA2+ci3U6K9bfHEKx
	BDQ5mlZS21yCQW4eLGNdS3guarWe8Einowoi/EXfmCBxNSU7b6U7XcQuS8ybE3IuFnDO
	uCA1nbDrlOIeJhIIywEDuQTDjCGgX7cTTNPabuImvJv7y+5dvKdFxGrvpTaDZwVBd3xC
	RXmKNEyUIpLx+x4rvh62Flfg4rfjGn+gCI+K9PBBmgeinsuwiEC4tFG0fWaYUSkIe/SP
	JbIA==
MIME-Version: 1.0
Received: by 10.60.19.106 with SMTP id d10mr9240063oee.40.1335472884376; Thu,
	26 Apr 2012 13:41:24 -0700 (PDT)
Sender: pyroinajar@gmail.com
Received: by 10.60.33.199 with HTTP; Thu, 26 Apr 2012 13:41:24 -0700 (PDT)
In-Reply-To: <20120426181606.GT22241@eeg.ccf.org>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<4F98863D.7070005@tlinx.org>
	<7825D6C5-E66D-4EB3-80D3-8A525AC6434F@lyndir.com>
	<20120426181606.GT22241@eeg.ccf.org>
Date: Thu, 26 Apr 2012 16:41:24 -0400
X-Google-Sender-Auth: PadvYuDZO52yjx5npa92e-6im40
Message-ID: <CAPg6Z083-AOh8EiezxOODRW-rXmb1dtefbDD0DW+jcSg0O7C=g@mail.gmail.com>
Subject: Re: Severe Bash Bug with Arrays
From: DJ Mills <danielmills1@gmail.com>
To: Greg Wooledge <wooledg@eeg.ccf.org>
Content-Type: text/plain; charset=ISO-8859-1
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.214.169
Cc: bug-bash@gnu.org, Maarten Billemont <lhunath@lyndir.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 20:41:30 -0000

On Thu, Apr 26, 2012 at 2:16 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> If the goal is to see the contents of an array, I'd use one of these,
> depending on how much detail I need:
>
> printf '<%s> ' "${array[@]}"; echo
>
> declare -p array
>


Or i'd use the args function Greg has shown before:

args() { printf '%d args:' "$#"; printf ' <%s>' "$@"; echo; }

args "${array[@]}"


From MAILER-DAEMON Thu Apr 26 18:29:41 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNXC1-0006lE-2L
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 18:29:41 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37956)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SNXBy-0006kY-8P
	for bug-bash@gnu.org; Thu, 26 Apr 2012 18:29:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SNXBw-0005ax-F9
	for bug-bash@gnu.org; Thu, 26 Apr 2012 18:29:37 -0400
Received: from smtp.gentoo.org ([140.211.166.183]:49399)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SNXBw-0005Vt-8F
	for bug-bash@gnu.org; Thu, 26 Apr 2012 18:29:36 -0400
Received: from vapier.localnet (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id 232781B402E;
	Thu, 26 Apr 2012 22:29:33 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: chet.ramey@case.edu
Subject: Re: [patch] fix building when readline is disabled
Date: Thu, 26 Apr 2012 18:31:21 -0400
User-Agent: KMail/1.13.7 (Linux/3.4.0-rc1; KDE/4.6.5; x86_64; ; )
References: <201204230022.23283.vapier@gentoo.org>
	<201204241046.21558.vapier@gentoo.org> <4F9703E5.5030004@case.edu>
In-Reply-To: <4F9703E5.5030004@case.edu>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart1749829.VZ3HWz29Rb";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
Message-Id: <201204261831.22504.vapier@gentoo.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 140.211.166.183
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 22:29:39 -0000

--nextPart1749829.VZ3HWz29Rb
Content-Type: Text/Plain;
  charset="windows-1252"
Content-Transfer-Encoding: quoted-printable

On Tuesday 24 April 2012 15:49:57 Chet Ramey wrote:
> On 4/24/12 10:46 AM, Mike Frysinger wrote:
> > On Tuesday 24 April 2012 08:23:04 Chet Ramey wrote:
> >> On 4/24/12 12:00 AM, Mike Frysinger wrote:
> >>>> OK, so you've stripped the local readline copy out of the source tre=
e?
> >>>=20
> >>> yes
> >>>=20
> >>>> Then configured it to build with a system readline library
> >>>> installation that you remove?
> >>>=20
> >>> the system doesn't have readline at all
> >>=20
> >> Why?
> >=20
> > because it's a small system which has no need for things like readline.=
=20
> > i don't think this is a terribly unusual use case.
>=20
> Sure, there are systems that don't want or need the readline library
> installed or things linked to it.  That's not unusual.  It's not what
> we're talking about here.
>=20
> What we're talking about is removing about 1 MB of source code
> (lib/readline) from the bash source tree *wherever you're building it*.
> This doesn't have anything to do with readline being built or installed.
> I don't have any doubt that you encountered a build error when you removed
> lib/readline from the bash source tree.  What I'm wondering is what you
> thought you would gain by doing it.

the local copy is stripped in order to detect cases (which often happens in=
=20
other packages) where headers/funcs are implicitly included and used even w=
hen=20
a feature is turned off.  like in this case where the local readline header=
s=20
are used even though i disabled readline.
=2Dmike

--nextPart1749829.VZ3HWz29Rb
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJPmcy6AAoJEEFjO5/oN/WBOfgQAIPe6MpstEpXuCIYVjSe3Tw5
AsyWNl9UWNZyagm+D4VECioXfjlQtPvxDg+PPMUmbQBQ35oZe4kv+tAmpAHz+n2U
fNhSMH24l7FNFW4rCUYk6uF63dap7NQPiUjxr40QuBmEIzlxH8x5VKII7dRYpshj
56UhhrYNl5aMmrRc3RaPWqi0X+kxntsDGMb2fTXOFFBNsKK2WjbEEAk/9z2Quej3
fJ5sURSasL6LAtjOULVdWYIcnj6eEwu6w5KUYdpswCRYMRBdJNTQ1iRK3hIn7KOG
lVcTevPfLw9m0/lSjn4ZBwMiC3VygqJT+7Yv9CSYpTkn8XKXwzQQY3LZBhhdYzgy
HXpQQnWHqfF/hc0SWY2wRkDMg90Qa1GwNkV7LaMpRGdnUQE9YPMdgQwWp0jKiAge
n+ytSGuemLHWh2vrHFtU08z0au/OqP+rKHB+uw57CboPuAtW9/+tMLI/uZX/1dwf
q0kyiSYqipgMML8RzGQ506IHcRsQNOni8jj9wMnPmtO+psfngFEug4ehDip2/czn
XugXfn7eTaTwMnOZauMPbcDcxf9JPa+gprP/R89zWcR+hLX7M2R+SqZnN9Avlnqb
RTG1JWAYObEhsIXNjByYGJqSQ7KwdlweJLynzAxTtHyF5uzNvvEjk52RAA0tX+cP
UiWLt8vXX//SVUaIdl8G
=ZNXA
-----END PGP SIGNATURE-----

--nextPart1749829.VZ3HWz29Rb--


From MAILER-DAEMON Thu Apr 26 18:32:39 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNXEt-00075u-Lm
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 18:32:39 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55221)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mod-submit@uni-berlin.de>) id 1SNXEp-00075g-91
	for bug-bash@gnu.org; Thu, 26 Apr 2012 18:32:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mod-submit@uni-berlin.de>) id 1SNXEn-0006Nu-AN
	for bug-bash@gnu.org; Thu, 26 Apr 2012 18:32:34 -0400
Received: from moderators.individual.net ([130.133.4.7]:37272)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mod-submit@uni-berlin.de>) id 1SNXEn-0006Mx-3n
	for bug-bash@gnu.org; Thu, 26 Apr 2012 18:32:33 -0400
Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66])
	by moderators.individual.net (Exim 4.69)
	for gnu-bash-bug@moderators.individual.net with esmtp
	(envelope-from <mod-submit@uni-berlin.de>)
	id <1SNXEl-0005pL-TR>; Fri, 27 Apr 2012 00:32:32 +0200
Received: from relay1.zedat.fu-berlin.de ([130.133.4.67])
	by outpost1.zedat.fu-berlin.de (Exim 4.69)
	for gnu-bash-bug@moderators.individual.net with esmtp
	(envelope-from <mod-submit@uni-berlin.de>)
	id <1SNXEj-000278-Dv>; Fri, 27 Apr 2012 00:32:29 +0200
Received: from reader2.zedat.fu-berlin.de ([130.133.4.6])
	by relay1.zedat.fu-berlin.de (Exim 4.69)
	for gnu-bash-bug@moderators.individual.net with esmtp
	(envelope-from <mod-submit@uni-berlin.de>)
	id <1SNXEj-0004ru-BY>; Fri, 27 Apr 2012 00:32:29 +0200
Received: by reader2.zedat.fu-berlin.de (Exim 4.72)
	for gnu-bash-bug@moderators.individual.net with local-bsmtp
	(envelope-from <mod-submit@uni-berlin.de>)
	id <1SNXEi-0004ds-B4>; Fri, 27 Apr 2012 00:32:28 +0200
To: gnu-bash-bug@moderators.individual.net
Path: individual.net!not-for-mail
From: Allodoxaphobia <knock_yourself_out@example.net>
Newsgroups: gnu.bash.bug
Subject: Re: protection against accidental massive pastes into the command line
Date: 26 Apr 2012 22:32:28 GMT
Lines: 10
Message-ID: <slrnjpjjd9.9rj.knock_yourself_out@shell.config.com>
References: <mailman.125.1335471511.855.bug-bash@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Orig-X-Trace: individual.net
	PdmDhnVP9uu2dO9S+yJg+wVFVxFIbcrrg4pUY/wh91Mw2WbN3Y
Cancel-Lock: sha1:i5TGKU3q47y+D7YrKOM/jBCzq0s=
User-Agent: slrn/0.9.9p1 (FreeBSD)
X-Originating-IP: 130.133.4.6
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 130.133.4.7
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 22:32:38 -0000

On Fri, 27 Apr 2012 04:18:21 +0800, jidanni@jidanni.org wrote:
> This would also save on later having to clean the massive blob out of
> the history list.

And, the Murphy's Law case(s) where one of the pasted lines 
contains a 'legitimate' linux command...  
Been there -- got a T-shirt.

Jonesy



From MAILER-DAEMON Thu Apr 26 19:36:02 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNYEE-0000GJ-S5
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 19:36:02 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59521)
	by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <joe@t67.eu>)
	id 1SNVeG-0003DQ-IU
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:50:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <joe@t67.eu>) id 1SNVeD-0003bc-Tu
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:50:44 -0400
Received: from t67.eu ([80.87.131.247]:58375)
	by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <joe@t67.eu>)
	id 1SNVeD-0003aa-N6
	for bug-bash@gnu.org; Thu, 26 Apr 2012 16:50:41 -0400
Received: by t67.eu (Postfix, from userid 1003)
	id 249EC8605D; Thu, 26 Apr 2012 21:50:39 +0100 (BST)
Date: Thu, 26 Apr 2012 21:50:39 +0100
From: Joseph Graham <joe@t67.eu>
To: bug-bash@gnu.org
Subject: declare -ag with assignment bug
Message-ID: <20120426205039.GA8764@t67.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.21 (2010-09-15)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 80.87.131.247
X-Mailman-Approved-At: Thu, 26 Apr 2012 19:36:01 -0400
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 26 Apr 2012 20:50:46 -0000

Configuration Information [Automatically generated, do not change]:
Machine: mips64el
OS: linux-gnu
Compiler: mips64el-unknown-linux-gnu-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='mips64el' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='mips64el-unknown-linux-gnu' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -O2 -march=loongson2f -mabi=n32 -pipe -mplt -Wa,-mfix-loongson2f-nop -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin' -DSTANDARD_UTILS_PATH='/usr/bin:/bin:/usr/sbin:/sbin' -DSYS_BASHRC='/etc/bash.bashrc' -DSYS_BASH_LOGOUT='/etc/bash.bash_logout'
uname output: Linux yeeloong.t67.eu 3.3.0-1-LIBRE #1 PREEMPT Mon Apr 2 18:49:26 UTC 2012 mips64 ICT Loongson-2 V0.3 FPU V0.1 lemote-yeeloong-2f-8.9inches GNU/Linux
Machine Type: mips64el-unknown-linux-gnu

Bash Version: 4.2
Patch Level: 24
Release Status: release

Description:
Arrays defined in a function with declare -ag are not
available outside the function if an assignment is done with the
declaration, though it works if the assignment is done seperately from
the declaration.

Repeat-By:
$ f() { declare -ag a=(my array); }; f; declare -p a
declare -a a='()'
$ f() { declare -ag a; a=(my array); }; f; declare -p a
declare -a a='([0]="my" [1]="array")'


From MAILER-DAEMON Thu Apr 26 21:44:24 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNaES-0008B8-NO
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 21:44:24 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41100)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SNaEQ-0008AI-4i
	for bug-bash@gnu.org; Thu, 26 Apr 2012 21:44:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SNaEO-0000ia-1t
	for bug-bash@gnu.org; Thu, 26 Apr 2012 21:44:21 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:34890)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SNaEN-0000c0-T2
	for bug-bash@gnu.org; Thu, 26 Apr 2012 21:44:19 -0400
Received: from mpv7.tis.CWRU.Edu (EHLO mpv7.case.edu) ([129.22.104.170])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BYA97641; Thu, 26 Apr 2012 21:44:17 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TMI80214 (AUTH cpr);
	Thu, 26 Apr 2012 21:44:13 -0400 (EDT)
Message-ID: <4F99F9E8.3050304@case.edu>
Date: Thu, 26 Apr 2012 21:44:08 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Joseph Graham <joe@t67.eu>
Subject: Re: declare -ag with assignment bug
References: <20120426205039.GA8764@t67.eu>
In-Reply-To: <20120426205039.GA8764@t67.eu>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 27 Apr 2012 01:44:23 -0000

On 4/26/12 4:50 PM, Joseph Graham wrote:

> Bash Version: 4.2
> Patch Level: 24
> Release Status: release
> 
> Description:
> Arrays defined in a function with declare -ag are not
> available outside the function if an assignment is done with the
> declaration, though it works if the assignment is done seperately from
> the declaration.
> 
> Repeat-By:
> $ f() { declare -ag a=(my array); }; f; declare -p a
> declare -a a='()'
> $ f() { declare -ag a; a=(my array); }; f; declare -p a
> declare -a a='([0]="my" [1]="array")'

http://lists.gnu.org/archive/html/help-bash/2012-04/msg00000.html

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


From MAILER-DAEMON Thu Apr 26 22:27:35 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNauF-0004GE-4b
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 22:27:35 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57005)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SNauC-0004Fj-8j
	for bug-bash@gnu.org; Thu, 26 Apr 2012 22:27:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SNau9-0006bK-Q8
	for bug-bash@gnu.org; Thu, 26 Apr 2012 22:27:31 -0400
Received: from rcsinet15.oracle.com ([148.87.113.117]:41369)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SNau9-0006am-J7
	for bug-bash@gnu.org; Thu, 26 Apr 2012 22:27:29 -0400
Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94])
	by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with
	ESMTP id q3R2RPFH021140
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Fri, 27 Apr 2012 02:27:26 GMT
Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158])
	by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
	q3R2ROFh004070
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <bug-bash@gnu.org>; Fri, 27 Apr 2012 02:27:25 GMT
Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69])
	by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id
	q3R2ROX8021706
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 21:27:24 -0500
Received: from mail-ob0-f169.google.com (/209.85.214.169)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Thu, 26 Apr 2012 19:27:24 -0700
Received: by obbeh20 with SMTP id eh20so454801obb.0
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 19:27:24 -0700 (PDT)
Received: by 10.182.232.38 with SMTP id tl6mr12383981obc.16.1335493644176;
	Thu, 26 Apr 2012 19:27:24 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.182.75.37 with HTTP; Thu, 26 Apr 2012 19:27:03 -0700 (PDT)
In-Reply-To: <CAFyvKit4rt7bAk8nNEsXFXXe+tz+YVQ3FWOA-2CDC1fP_b4=Pw@mail.gmail.com>
References: <r2pc440c9801005010240o2388c72fjb8ce0aa6b123d19c@mail.gmail.com>
	<20100501112118.GB4615@rebase.prov>
	<o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov> <20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
	<20120426122816.GS22241@eeg.ccf.org>
	<CAFyvKit4rt7bAk8nNEsXFXXe+tz+YVQ3FWOA-2CDC1fP_b4=Pw@mail.gmail.com>
From: Clark Wang <clark.wang@oracle.com>
Date: Fri, 27 Apr 2012 10:27:03 +0800
Message-ID: <CADv8-ojxq=AMeUTFf1dk6kFZwXRgUwh7PrELe+WsVcV+-8rBNg@mail.gmail.com>
Subject: Re: Passing variables by reference conflicts with local
To: Bill Gradwohl <bill@ycc.com>
X-Source-IP: ucsinet22.oracle.com [156.151.31.94]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1)
X-Received-From: 148.87.113.117
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: "Clark J. WANG" <dearvoid@gmail.com>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 27 Apr 2012 02:27:33 -0000

On Fri, Apr 27, 2012 at 02:02, Bill Gradwohl <bill@ycc.com> wrote:

>
> So, if you want to make sure a sub
> function can't touch a variable, put another function in between that
> localises and then unsets the variable.
>

Sounds interesting. Will see if I can take advantage of this in future. :)

>
>
> --
> Bill Gradwohl
>

From MAILER-DAEMON Thu Apr 26 22:30:12 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNawm-0004Vj-Ik
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 22:30:12 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50188)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SNawj-0004VI-CC
	for bug-bash@gnu.org; Thu, 26 Apr 2012 22:30:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SNawh-00084O-GG
	for bug-bash@gnu.org; Thu, 26 Apr 2012 22:30:08 -0400
Received: from rcsinet15.oracle.com ([148.87.113.117]:41975)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <clark.wang@oracle.com>) id 1SNawg-00080h-Gx
	for bug-bash@gnu.org; Thu, 26 Apr 2012 22:30:07 -0400
Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238])
	by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with
	ESMTP id q3R2U32F022813
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <bug-bash@gnu.org>; Fri, 27 Apr 2012 02:30:04 GMT
Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157])
	by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
	q3R2U3cK025809
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <bug-bash@gnu.org>; Fri, 27 Apr 2012 02:30:03 GMT
Received: from abhmt105.oracle.com (abhmt105.oracle.com [141.146.116.57])
	by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id
	q3R2U3sO021964
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 21:30:03 -0500
Received: from mail-ob0-f169.google.com (/209.85.214.169)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Thu, 26 Apr 2012 19:30:03 -0700
Received: by obbeh20 with SMTP id eh20so457804obb.0
	for <bug-bash@gnu.org>; Thu, 26 Apr 2012 19:30:03 -0700 (PDT)
Received: by 10.60.29.39 with SMTP id g7mr4958922oeh.6.1335493802967; Thu, 26
	Apr 2012 19:30:02 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.182.75.37 with HTTP; Thu, 26 Apr 2012 19:29:42 -0700 (PDT)
In-Reply-To: <20120426184908.GV22241@eeg.ccf.org>
References: <o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov> <20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
	<20120426122816.GS22241@eeg.ccf.org>
	<CAFyvKit4rt7bAk8nNEsXFXXe+tz+YVQ3FWOA-2CDC1fP_b4=Pw@mail.gmail.com>
	<20120426184908.GV22241@eeg.ccf.org>
From: Clark Wang <clark.wang@oracle.com>
Date: Fri, 27 Apr 2012 10:29:42 +0800
Message-ID: <CADv8-ohCU0=JuRSzU=qOqVd9_3Caa7WJYLnmMPfFnVkgdC5Mxw@mail.gmail.com>
Subject: Re: Passing variables by reference conflicts with local
To: Greg Wooledge <wooledg@eeg.ccf.org>
X-Source-IP: acsinet22.oracle.com [141.146.126.238]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1)
X-Received-From: 148.87.113.117
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: "Clark J. WANG" <dearvoid@gmail.com>, "bash.bug list" <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 27 Apr 2012 02:30:10 -0000

On Fri, Apr 27, 2012 at 02:49, Greg Wooledge <wooledg@eeg.ccf.org> wrote:

>
> I don't see this as a surprise.  It's how you return values from functions
> in bash.  Pick a global variable (r, ret, whatever you want) and stuff the
> return value into that.  You can even declare your "r" locally somewhere
> so that the value never propagates up higher than that point in the call
> chain.
>

I can understand this but I've never written code like this. Will try it
later.

>
> For example:
>
> # Return random number from 0 to ($1-1) in variable "r"
> rand() {
>  local max=$((32768 / $1 * $1));
>  while (( (r=$RANDOM) >= max )); do :; done
>  r=$((r % $1))
> }
>
> foo() {
>  local r
>  rand 42
>  ... use $r ...
> }
>
> foo
> ... we don't see "r" here because it was scoped only within foo & its kids
> ...
>
>

From MAILER-DAEMON Thu Apr 26 23:47:54 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNc9y-0001ck-Tn
	for mharc-bug-bash@gnu.org; Thu, 26 Apr 2012 23:47:54 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52322)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNc9v-0001cR-US
	for bug-bash@gnu.org; Thu, 26 Apr 2012 23:47:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNc9t-0001iy-RU
	for bug-bash@gnu.org; Thu, 26 Apr 2012 23:47:51 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:54294
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNc9t-0001hk-AZ
	for bug-bash@gnu.org; Thu, 26 Apr 2012 23:47:49 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3R3ldGU018809; Thu, 26 Apr 2012 20:47:42 -0700
Message-ID: <4F9A16DB.9010602@tlinx.org>
Date: Thu, 26 Apr 2012 20:47:39 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Maarten Billemont <lhunath@lyndir.com>
Subject: Re: Severe Bash Bug with Arrays
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<4F98863D.7070005@tlinx.org>
	<7825D6C5-E66D-4EB3-80D3-8A525AC6434F@lyndir.com>
In-Reply-To: <7825D6C5-E66D-4EB3-80D3-8A525AC6434F@lyndir.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: Ted Okuzumi <tedokuzumi@gmail.com>, bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 27 Apr 2012 03:47:53 -0000



Maarten Billemont wrote:

> On 26 Apr 2012, at 01:18, Linda Walsh wrote:
>> Ishtar:> echo "${b[*]}"
> 
> Please note that expanding array elements using [*] is usually NOT what anyone wants.



---
It was exactly what I wanted for my example to work.  Please don't suggest
non-working solutions to the example code I provided.  ${b[@]}  Will NOT
work as a replacement for [*].  It isn't not BETTER, it is DIFFERENT.
That's why there are both.

> your array like above, you then follow up by re-splitting the 
> whole thing using standard wordsplitting, not to mention pathname 
> expanding the resulting words.



----
I followed up?  I don't understand this.  I gave a progressive example
that showed the results at each step.  It wasn't a canned solution for
the poster's problem, it was a different method of looking at the problem
that they could apply using whatever modifications they would need for their
example.   Obviously, they were not complete beginners to bash -- to be reading
arrays in from vars holding multi-line text?   I would assume they'd have the
intelligence to know when to use * or @ and I wouldn't have to talk down to them
and cover basics.

> 
> "${b[@]}" # Expands each array element as a separate argument, 

>             protecting it from wordsplitting and pathname expansion mutilation.

> ${b[@]} # Identical to and just as broken as ${b[*]}.  Never do this.

----
No.    _NEVER_ USE ${b[@]} when you want the IFS inserted between
elements.   It doesn't work.  (I wish BASH had an OFS, that worked for
such cases as well as other expansions), but with the given system, '@' is
totally unacceptable to suggest when one wants to create an expression with
braces that bash can automatically expand.

> You should always recommend the "${b[@]}" variant.

----
I shouldn't ALWAYS do anything.  It's dangerous.
You can do so for your examples... It won't work in the next
two any more than the last one of the previous...


sort an arg list:

 > args="-dpi -xinerama -clipboard -unixkill -nowinkill -ac +bs -fp -multiwindow"

 > readarray -t dflts< <( a=( $args ); IFS=$'\n'; echo "${a[*]#?}"|sort -k1.2 )

 > printf "  defaults=(%s)" "${dflts[*]}"

   defaults=(-ac +bs -clipboard -dpi -fp -multiwindow -nowinkill -unixkill 
-xinerama)

Want to create pathnames using bash's /path/{}/  feature and have the paths
in an array (for simple paths):

 > a=(lib tmp bin share)
 > (export IFS=,;eval "echo /usr/{${a[*]}}")
/usr/lib /usr/tmp /usr/bin /usr/share



Anything else you wanna tell me NEVER/ALWAYS to do?

(contrarian)


From MAILER-DAEMON Fri Apr 27 00:15:32 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNcai-0003va-0I
	for mharc-bug-bash@gnu.org; Fri, 27 Apr 2012 00:15:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58668)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SNcaf-0003un-L7
	for bug-bash@gnu.org; Fri, 27 Apr 2012 00:15:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SNcae-0006Cr-1m
	for bug-bash@gnu.org; Fri, 27 Apr 2012 00:15:29 -0400
Received: from smtp.gentoo.org ([140.211.166.183]:38360)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SNcad-0006Cg-SN
	for bug-bash@gnu.org; Fri, 27 Apr 2012 00:15:27 -0400
Received: from vapier.localnet (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id 8E93B1B4015;
	Fri, 27 Apr 2012 04:15:24 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: bug-bash@gnu.org
Subject: Re: Severe Bash Bug with Arrays
Date: Fri, 27 Apr 2012 00:17:13 -0400
User-Agent: KMail/1.13.7 (Linux/3.4.0-rc1; KDE/4.6.5; x86_64; ; )
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<7825D6C5-E66D-4EB3-80D3-8A525AC6434F@lyndir.com>
	<4F9A16DB.9010602@tlinx.org>
In-Reply-To: <4F9A16DB.9010602@tlinx.org>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart20887125.OSLHsQtRz1";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
Message-Id: <201204270017.15700.vapier@gentoo.org>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 140.211.166.183
Cc: Ted Okuzumi <tedokuzumi@gmail.com>, Linda Walsh <bash@tlinx.org>,
	Maarten Billemont <lhunath@lyndir.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 27 Apr 2012 04:15:30 -0000

--nextPart20887125.OSLHsQtRz1
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit

On Thursday 26 April 2012 23:47:39 Linda Walsh wrote:
> Anything else you wanna tell me NEVER/ALWAYS to do?

try ALWAYS being polite.  but i guess that'll NEVER happen.

oh well, thankfully kmail can auto-mute based on sender.
-mike

--nextPart20887125.OSLHsQtRz1
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJPmh3LAAoJEEFjO5/oN/WB4yAQAIKxIK1i2ABmRY3jB9UqDVD0
FhU7cHngtKpl/mJDOCP2aCiJ0Ai6l0sbvoRCkePGZTLhBsaWuwn05QPNWsY/FTPn
lBePJNCTdWkYJ3m/l4Xk+Aq+k66uLvRfLHbnLke4DMbgcxk0Xu+s52ijvR+udEJH
Nfy+tC4WDtPPv1AubYY83asQ8MMu1AIn9UD9/9/0KyCYGq5cOM7F01IHsIsTi+XN
N7qw9k6RANOdPZLFivjGgZQhxp/YcO4AUqSkIi5BKfGW6945/OllEGL++hYZxsuc
VFct+OcVKPp5QKU18P2j1Y4KqYORsc7RFe7lH4gEQkFbrqBuAerhPOaEGrHRktRR
VFOtlVu8Q++Tst96HqG4xn0SQO2BHxI7HEyI1q5oEGteB6hozU9hAVrpAkrItF+W
gVMzYd3eTsLv81GRd9DjCObezNtHDIUF+iVynEcvdYVDHftO9G+TBPrBfJa/mbj0
cyvEHJ/9q7SGAS/TbgyCBdSIz1wioz/RNgLEwckJ49hrKCyniTpmhBWyyRi/1EDU
xl0xUKnXXS1eH8v8ZP15IQky0UHsDHqv7uE7zen2SXfT04Iu/P6Y2IdUkpzaXIKB
hCuB5qT1wfMLyf7rxKlI2ex68kTAZi8En95VDYyTzo4c01G6cFasQ3lHANOzOqSI
Qwoa8cr8YPsqQoFwfs7g
=T7lE
-----END PGP SIGNATURE-----

--nextPart20887125.OSLHsQtRz1--


From MAILER-DAEMON Fri Apr 27 08:27:45 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNkH3-0004ZY-Qt
	for mharc-bug-bash@gnu.org; Fri, 27 Apr 2012 08:27:45 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58548)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNkH1-0004Yw-CK
	for bug-bash@gnu.org; Fri, 27 Apr 2012 08:27:44 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNkGw-0000WX-LC
	for bug-bash@gnu.org; Fri, 27 Apr 2012 08:27:42 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:46371
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SNkGw-0000W4-E0
	for bug-bash@gnu.org; Fri, 27 Apr 2012 08:27:38 -0400
Received: (qmail 27641 invoked from network); 27 Apr 2012 12:27:34 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Fri, 27 Apr 2012 08:27:34 -0400
Received: (qmail 5369 invoked by uid 563); 27 Apr 2012 12:27:34 -0000
Date: Fri, 27 Apr 2012 08:27:33 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Linda Walsh <bash@tlinx.org>
Subject: Re: Severe Bash Bug with Arrays
Message-ID: <20120427122733.GB4278@eeg.ccf.org>
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<4F98863D.7070005@tlinx.org>
	<7825D6C5-E66D-4EB3-80D3-8A525AC6434F@lyndir.com>
	<4F9A16DB.9010602@tlinx.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F9A16DB.9010602@tlinx.org>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 27 Apr 2012 12:27:44 -0000

On Thu, Apr 26, 2012 at 08:47:39PM -0700, Linda Walsh wrote:
> Obviously, they were not complete beginners to bash -- to be 
> reading
> arrays in from vars holding multi-line text?   I would assume they'd have 
> the
> intelligence to know when to use * or @ and I wouldn't have to talk down to 
> them
> and cover basics.

Oh, you would be amazed and astonished.  I've learned never to assume
a person possesses advanced knowledge, when it comes to programming
questions.

> > a=(lib tmp bin share)
> > (export IFS=,;eval "echo /usr/{${a[*]}}")
> /usr/lib /usr/tmp /usr/bin /usr/share
> 
> Anything else you wanna tell me NEVER/ALWAYS to do?

NEVER use eval plus a brace expansion to generate a list.  That's just
freakin' evil.  And unsafe:

imadev:~$ a=(lib tmp bin share '`date`')
imadev:~$ (export IFS=,;eval "echo /usr/{${a[*]}}")
/usr/lib /usr/tmp /usr/bin /usr/share /usr/Fri Apr 27 08:25:49 EDT 2012

(Replace `date` with whatever evil command you think is likely to be
put into the array by a malicious user.)


Alternative 1:
a=(lib tmp bin share)
echo "${a[@]/#//usr/}"

Alternative 2:
a=(lib tmp bin share)
printf "/usr/%s " "${a[@]}"


From MAILER-DAEMON Fri Apr 27 15:02:42 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNqRG-0006ox-5e
	for mharc-bug-bash@gnu.org; Fri, 27 Apr 2012 15:02:42 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55947)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNqRD-0006or-S4
	for bug-bash@gnu.org; Fri, 27 Apr 2012 15:02:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNqRC-00032P-1q
	for bug-bash@gnu.org; Fri, 27 Apr 2012 15:02:39 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:43224
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNqRB-00031S-Is
	for bug-bash@gnu.org; Fri, 27 Apr 2012 15:02:37 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3RJ2QqN021158; Fri, 27 Apr 2012 12:02:28 -0700
Message-ID: <4F9AED42.2000100@tlinx.org>
Date: Fri, 27 Apr 2012 12:02:26 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: Severe Bash Bug with Arrays
References: <CAHtRY2xP7yXrs_utDdPjHPw=yy_1_tsJCvMxx2sF9MpAJgsKDg@mail.gmail.com>
	<4F98863D.7070005@tlinx.org>
	<7825D6C5-E66D-4EB3-80D3-8A525AC6434F@lyndir.com>
	<4F9A16DB.9010602@tlinx.org> <20120427122733.GB4278@eeg.ccf.org>
In-Reply-To: <20120427122733.GB4278@eeg.ccf.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 27 Apr 2012 19:02:41 -0000



Greg Wooledge wrote:

> NEVER use eval plus a brace expansion to generate a list.  That's just
> freakin' evil.  And unsafe:

===
But I _like_ evil sometimes!   >:->

> 
> imadev:~$ a=(lib tmp bin share '`date`')
> imadev:~$ (export IFS=,;eval "echo /usr/{${a[*]}}")
> /usr/lib /usr/tmp /usr/bin /usr/share /usr/Fri Apr 27 08:25:49 EDT 2012

----
There can be lots of such problems... I tried it on larger dirs.. parens
quote...all sorts of probs... tried embedded print "%q" ......etc

But reality is things like that save me time in typing in stuff or writing
maint scripts on my machine -- they aren't meant for handling user input.

They take hand editing to gen the paths I want and don't take user input,
so it's a specialized usage in that case....


> 
> Alternative 1:
> a=(lib tmp bin share)
> echo "${a[@]/#//usr/}"
> 
> Alternative 2:
> a=(lib tmp bin share)
> printf "/usr/%s " "${a[@]}"


---
good points....
But I was pointing out that [*] has its place ... I use [@] alot
more often than [*], but will use [*], though a bit irregularly,
when I want to get the # of items in an array (where either would work)..
though I could make a case if it was worth anything to me that #..@ return
# items and #...[*] return total length of all items... but I don't really
care....and it would break all my usages of #..[*]... ;-)....

C'est la vi...



From MAILER-DAEMON Fri Apr 27 15:27:45 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNqpV-0000yW-Ne
	for mharc-bug-bash@gnu.org; Fri, 27 Apr 2012 15:27:45 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50294)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SNqpS-0000xX-SY
	for bug-bash@gnu.org; Fri, 27 Apr 2012 15:27:44 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SNqpQ-0000Qk-Vq
	for bug-bash@gnu.org; Fri, 27 Apr 2012 15:27:42 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:43669
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@gentoo.org>) id 1SNqpQ-0000Pq-Jg
	for bug-bash@gnu.org; Fri, 27 Apr 2012 15:27:40 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3RJRYGT005171; Fri, 27 Apr 2012 12:27:36 -0700
Message-ID: <4F9AF326.9020304@gentoo.org>
Date: Fri, 27 Apr 2012 12:27:34 -0700
From: "(Lnda Wlsh w/faked addr )" <vapier@gentoo.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Mike Frysinger <vapier@gentoo.org>
Subject: Re: reply style (OT) (was Re: Severe Bash Bug w/Arrays)
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id
	q3RJRYGT005171
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 27 Apr 2012 19:27:44 -0000



Mike Frysinger wrote:
>=20
>> Anything else you wanna tell me NEVER/ALWAYS to do?
>=20
> try ALWAYS being polite.  but i guess that'll NEVER happen.
>=20
> oh well, thankfully kmail can auto-mute based on sender.
> -mike


=3D=3D=3D=3D

 =C2=AB"Always" "good to prejudge" "everything someone says" based on how=
=20
they interact with one person [sic].=C2=BB   I am no more likely to use t=
he=20
same style with my mom than I would with a convicted killer, would you?

More often than not if you've read my past replies, my replies will be=20
colored with the flavor of the note that was written to me.  On a good da=
y,
it will be a toned down version of the flavor, on a less good day, it mig=
ht
be an intensified version of the tone....   Depends on how many times I=20
revise it.   That response was my 5th revision...  If you wanted acerbic,
my first reply would have been much more appropriate (and immature).

I tend to find people who auto-judge all content from a person based on=20
responses to annoying people, more than a bit immature given that human=20
interactions are highly contextual.  And I mean immature -- in the sense=20
that they seem to think human responses are 'robotic or preprogrammed',=20
and haven't yet learned that humans are not machines.

It takes dozens of notes from the same person before I begin to=20
recognize their pervasive style, and THEN might start remembering their=20
name.  But usually I won't remember who wrote something by the time I=20
read their next note -- unless they have a pervasive style that I notice=20
over time, or have a protracted discussion with them.

Hopefully you will get this, on the off chance that you haven't=20
auto-muted yourself due to any posting you've ever made in the past that=20
might have offended someone. ;^).


Linda



From MAILER-DAEMON Fri Apr 27 15:33:45 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNqvJ-0001pv-Sa
	for mharc-bug-bash@gnu.org; Fri, 27 Apr 2012 15:33:45 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56956)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNqvH-0001pd-Bf
	for bug-bash@gnu.org; Fri, 27 Apr 2012 15:33:44 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNqvF-00052w-RJ
	for bug-bash@gnu.org; Fri, 27 Apr 2012 15:33:42 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:43811
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNqvF-00051h-DN
	for bug-bash@gnu.org; Fri, 27 Apr 2012 15:33:41 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3RJXVJf013074; Fri, 27 Apr 2012 12:33:34 -0700
Message-ID: <4F9AF48B.2090509@tlinx.org>
Date: Fri, 27 Apr 2012 12:33:31 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: (yet more OT) was (Re: reply style (OT))
References: <4F9AF326.9020304@gentoo.org>
In-Reply-To: <4F9AF326.9020304@gentoo.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 27 Apr 2012 19:33:44 -0000

p.s. - the previous was yet, another example of tailoring
a response to a specific situation (in case that wasn't obvious);
I think it's a first for me to deliberately use someone else's
addr to send such a response.  my apologies to any who were
offended.


From MAILER-DAEMON Fri Apr 27 22:24:12 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNxKW-0002pS-In
	for mharc-bug-bash@gnu.org; Fri, 27 Apr 2012 22:24:12 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51866)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNxKU-0002p5-3w
	for bug-bash@gnu.org; Fri, 27 Apr 2012 22:24:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNxKS-0005BE-CX
	for bug-bash@gnu.org; Fri, 27 Apr 2012 22:24:09 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:51108
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNxKR-000555-Vb
	for bug-bash@gnu.org; Fri, 27 Apr 2012 22:24:08 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3S2O2K6007130
	for <bug-bash@gnu.org>; Fri, 27 Apr 2012 19:24:04 -0700
Message-ID: <4F9B54C2.3010401@tlinx.org>
Date: Fri, 27 Apr 2012 19:24:02 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: bug-bash <bug-bash@gnu.org>
Subject: no-empty-command-line-completion  -- thought fixed in 4.2?  when?
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 28 Apr 2012 02:24:11 -0000

I thought this was fixed in 4.2, yet I'm still seeing it...

when's this going to be fixed?

It's driving me crazy, as bash drops input because it asks questions about
displaying 1000's of completions...).



when I paste a few lines of source in at the shell -- doesn't
matter if it is bash script or perl or written text...

I can't rely on bash not corrupting the text.

Even between single quotes:

a='
<tab>blah
'
will generate autocomplete.

Yet I have no-empty-commandline-completion turned off.

So why isn't this fixed?



From MAILER-DAEMON Fri Apr 27 23:06:12 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNxzA-00064u-Hv
	for mharc-bug-bash@gnu.org; Fri, 27 Apr 2012 23:06:12 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34543)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNxz8-00062e-4K
	for bug-bash@gnu.org; Fri, 27 Apr 2012 23:06:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNxz6-0002MO-Fs
	for bug-bash@gnu.org; Fri, 27 Apr 2012 23:06:09 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:51797
	helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bash@tlinx.org>) id 1SNxz6-0002MF-49
	for bug-bash@gnu.org; Fri, 27 Apr 2012 23:06:08 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
	by Ishtar.sc.tlinx.org (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id
	q3S35Y7x005161; Fri, 27 Apr 2012 20:06:04 -0700
Message-ID: <4F9B5E7E.3010006@tlinx.org>
Date: Fri, 27 Apr 2012 20:05:34 -0700
From: Linda Walsh <bash@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
	rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24
	Mnenhy/0.7.6.666
MIME-Version: 1.0
To: Maarten Billemont <lhunath@lyndir.com>
Subject: Re: Is it possible or RFE to expand ranges of *arrays*
References: <4F98CE62.3040601@tlinx.org> <4F98CF5B.6050306@web.de>
	<17EB4457-C08E-4BCF-9788-2716954A06DB@lyndir.com>
In-Reply-To: <17EB4457-C08E-4BCF-9788-2716954A06DB@lyndir.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 173.164.175.65
Cc: John Kearney <dethrophes@web.de>, bug-bash <bug-bash@gnu.org>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 28 Apr 2012 03:06:11 -0000



Maarten Billemont wrote:

> On 26 Apr 2012, at 06:30, John Kearney wrote:
>> Am 26.04.2012 06:26, schrieb Linda Walsh:
>>> I know I can get
>>> a="abcdef" echo "${a[2:4]}" = cde
>>>
>>> how do I do:
>>> typeset -a a=(apple berry cherry date); then get:
>>>
>>> echo ${a[1:2]} = "berry" "cherry"  ( non-grouped args)
>>>
>>> I tried to do it in a function and hurt myself.
>>>
>>>
>>>
>> echo ${a[@]:1:2}
>>
> 
> I see little reason to ask bash to wordsplit the elements after expanding them. 


 You ought to quote that expansion.

---
	Good point.

Since if you do:

 > a=( 'apple pie' 'berry pie' 'cherry cake' 'dates divine')
 > b=( ${a[@]:1:2} )
 > echo ${#b[*]}
4
#yikes!
 > b=( "${a[@]:1:2}" )
2
#woo!

I'd guess the original poster probably figured, I'd figure out the correct
form pretty quickly in usage.  but thanks for your insight.

( (to all)....*sigh*)



From MAILER-DAEMON Sat Apr 28 03:42:25 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SO2IT-0001Ur-F1
	for mharc-bug-bash@gnu.org; Sat, 28 Apr 2012 03:42:25 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56943)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SO2IQ-0001UK-VX
	for bug-bash@gnu.org; Sat, 28 Apr 2012 03:42:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SO2IP-0000PC-CJ
	for bug-bash@gnu.org; Sat, 28 Apr 2012 03:42:22 -0400
Received: from fmmailgate02.web.de ([217.72.192.227]:48786)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dethrophes@web.de>) id 1SO2IP-0000Ot-62
	for bug-bash@gnu.org; Sat, 28 Apr 2012 03:42:21 -0400
Received: from moweb002.kundenserver.de (moweb002.kundenserver.de
	[172.19.20.108])
	by fmmailgate02.web.de (Postfix) with ESMTP id 70A0D1C3FDCB1
	for <bug-bash@gnu.org>; Sat, 28 Apr 2012 09:42:18 +0200 (CEST)
Received: from [192.168.178.49] ([93.135.140.62]) by smtp.web.de (mrweb001)
	with ESMTPA (Nemesis) id 0MUVvf-1Sni1q42EN-00RLJW;
	Sat, 28 Apr 2012 09:42:18 +0200
Message-ID: <4F9B9F58.7000601@web.de>
Date: Sat, 28 Apr 2012 09:42:16 +0200
From: John Kearney <dethrophes@web.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:12.0) Gecko/20120420 Thunderbird/12.0
MIME-Version: 1.0
To: bug-bash@gnu.org
Subject: Re: Is it possible or RFE to expand ranges of *arrays*
References: <4F98CE62.3040601@tlinx.org> <4F98CF5B.6050306@web.de>
	<17EB4457-C08E-4BCF-9788-2716954A06DB@lyndir.com>
	<4F9B5E7E.3010006@tlinx.org>
In-Reply-To: <4F9B5E7E.3010006@tlinx.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:lSIRZdS0YIvKWPwgYBehbmkE6dv45gJJ1SCrq1oXV1s
	u9WSWDTIt1Tv3KZ6dm9Ww99cgKWH04zWYQ+MDrBhvTjjaTDZBk
	xJ/QmWD2XbNMEb5i+yicu2aBecI07w/6m/8/ge/2/agIeqjPNU
	NTucs+6/h+wjdSMX3lksuhDi7WT5Sb+9yDi0len0qcEZB5R28k
	PfwK8RYs/un94U/X72/QA==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6
X-Received-From: 217.72.192.227
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 28 Apr 2012 07:42:24 -0000

Am 28.04.2012 05:05, schrieb Linda Walsh:
>
>
> Maarten Billemont wrote:
>
>> On 26 Apr 2012, at 06:30, John Kearney wrote:
>>> Am 26.04.2012 06:26, schrieb Linda Walsh:
>>>> I know I can get
>>>> a="abcdef" echo "${a[2:4]}" = cde
>>>>
>>>> how do I do:
>>>> typeset -a a=(apple berry cherry date); then get:
>>>>
>>>> echo ${a[1:2]} = "berry" "cherry"  ( non-grouped args)
>>>>
>>>> I tried to do it in a function and hurt myself.
>>>>
>>>>
>>>>
>>> echo ${a[@]:1:2}
>>>
>>
>> I see little reason to ask bash to wordsplit the elements after 
>> expanding them. 
>
>
> You ought to quote that expansion.
>
> ---
>     Good point.
>
> Since if you do:
>
> > a=( 'apple pie' 'berry pie' 'cherry cake' 'dates divine')
> > b=( ${a[@]:1:2} )
> > echo ${#b[*]}
> 4
> #yikes!
> > b=( "${a[@]:1:2}" )
> 2
> #woo!
>
> I'd guess the original poster probably figured, I'd figure out the 
> correct
> form pretty quickly in usage.  but thanks for your insight.
>
> ( (to all)....*sigh*)
>
>
I "always" quote not sure why I didn't that time.
Except that it was just a quick response to a simple question.
but of course your right.


From MAILER-DAEMON Sat Apr 28 15:01:48 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SOCtw-0005Ef-3d
	for mharc-bug-bash@gnu.org; Sat, 28 Apr 2012 15:01:48 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49126)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOCtt-0005C4-8n
	for bug-bash@gnu.org; Sat, 28 Apr 2012 15:01:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOCtr-00075J-9l
	for bug-bash@gnu.org; Sat, 28 Apr 2012 15:01:44 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:49257)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOCtr-000756-52
	for bug-bash@gnu.org; Sat, 28 Apr 2012 15:01:43 -0400
Received: from mpv8.case.edu (mpv8.tis.cwru.edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKG61526;
	Sat, 28 Apr 2012 15:01:40 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TTO49150 (AUTH cpr);
	Sat, 28 Apr 2012 15:01:38 -0400 (EDT)
Message-ID: <4F9C3E92.60005@case.edu>
Date: Sat, 28 Apr 2012 15:01:38 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Linda Walsh <bash@tlinx.org>
Subject: Re: no-empty-command-line-completion -- thought fixed in 4.2? when?
References: <4F9B54C2.3010401@tlinx.org>
In-Reply-To: <4F9B54C2.3010401@tlinx.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash <bug-bash@gnu.org>, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 28 Apr 2012 19:01:46 -0000

On 4/27/12 10:24 PM, Linda Walsh wrote:
> I thought this was fixed in 4.2, yet I'm still seeing it...
> 
> when's this going to be fixed?

There are a couple of things wrong with your question.  First, the name of
the shopt option is no_empty_cmd_completion.  Second, you haven't
demonstrated a failure mode.  When I enable that option and hit TAB at an
empty PS1 prompt I don't get command completion; it just beeps.

> It's driving me crazy, as bash drops input because it asks questions about
> displaying 1000's of completions...).
> 
> 
> 
> when I paste a few lines of source in at the shell -- doesn't
> matter if it is bash script or perl or written text...
> 
> I can't rely on bash not corrupting the text.
> 
> Even between single quotes:
> 
> a='
> <tab>blah
> '
> will generate autocomplete.

Of course.  It performs filename completion.  That's not a position where
bash is ready to read a command, so the option setting is not relevant.

> So why isn't this fixed?

You haven't actually described a reproducible problem.  Maybe you should
turn off line editing before pasting input.  Clearly you don't need editing
in that case, and bash/readline can't tell the difference between pasted
and keyboard input.

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


From MAILER-DAEMON Sat Apr 28 22:03:54 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SOJUQ-0002Vs-LG
	for mharc-bug-bash@gnu.org; Sat, 28 Apr 2012 22:03:54 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57521)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOJUO-0002V8-8G
	for bug-bash@gnu.org; Sat, 28 Apr 2012 22:03:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOJUM-0004Qh-Ak
	for bug-bash@gnu.org; Sat, 28 Apr 2012 22:03:51 -0400
Received: from mpv1.tis.cwru.edu ([129.22.105.36]:34998)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOJUM-0004Qb-5c
	for bug-bash@gnu.org; Sat, 28 Apr 2012 22:03:50 -0400
Received: from mpv7.tis.CWRU.Edu (EHLO mpv7.case.edu) ([129.22.104.170])
	by mpv1.tis.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id BYC24872; Sat, 28 Apr 2012 22:03:48 -0400 (EDT)
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv7.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TNF21749 (AUTH cpr);
	Sat, 28 Apr 2012 22:03:47 -0400 (EDT)
Message-ID: <4F9CA182.9060200@case.edu>
Date: Sat, 28 Apr 2012 22:03:46 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Greg Wooledge <wooledg@eeg.ccf.org>
Subject: Re: Passing variables by reference conflicts with local
References: <20100501112118.GB4615@rebase.prov>
	<o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
	<4F988CBA.5070800@tlinx.org> <20120426121100.GR22241@eeg.ccf.org>
In-Reply-To: <20120426121100.GR22241@eeg.ccf.org>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
Cc: Clark Wang <clark.wang@oracle.com>, Linda Walsh <bash@tlinx.org>,
	bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 29 Apr 2012 02:03:53 -0000

On 4/26/12 8:11 AM, Greg Wooledge wrote:

> Bash uses "dynamic scoping", which is a somewhat controversial choice, and
> has led to a whole lot of confusion in the past.  Most other shells use
> static scoping.

I really wish people would stop saying "most other shells," unless by that
they mean "ksh93".  Consider this script (it's necessary to use `function'
so that ksh93 turns on static scoping) or a slight variant that uses the
Posix declaration syntax and `local' instead of `typeset' (necessary for
dash and other ash descendents):

var=global

function f1
{
	typeset var=f1-local
	f2
}

function f2
{
	echo f2: $var
}

echo main: $var
f1
echo main2: $var

The following shells print

main: global
f2: f1-local
main2: global

indicating dynamic scoping: bash, zsh, dash, mksh, FreeBSD sh, posh, and
the venerable 4.4 BSD sh.

ksh93 is the only one that prints

main: global
f2: global
main2: global

Unless you export var in f1, in which case you get one level of dynamic
scoping.

> POSIX has nothing to say on the matter; "local" is not
> defined in POSIX, and POSIX does not even require functions to implement
> local variables at all (let alone dictate what kind of scoping to use).

Posix did specify `local' once, in draft 9 of what became the Posix.2
1992 specification.  That specification informed the 4.4 BSD sh
implementation, which used dynamic scoping, since the guy at Berkeley
who prepared sh for 4.4 BSD wrote most of d9 (Marc Teitelbaum).  While I
no longer have my copy of d9 (more's the pity), I believe that it
specified dynamic scoping for its local variables.  This stuff all
predates ksh93.

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


From MAILER-DAEMON Sat Apr 28 22:32:05 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SOJvh-0003Zn-7u
	for mharc-bug-bash@gnu.org; Sat, 28 Apr 2012 22:32:05 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41305)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOJve-0003Z8-5i
	for bug-bash@gnu.org; Sat, 28 Apr 2012 22:32:03 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOJvc-00046O-2Y
	for bug-bash@gnu.org; Sat, 28 Apr 2012 22:32:01 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:10414)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOJvb-00046D-Uh
	for bug-bash@gnu.org; Sat, 28 Apr 2012 22:32:00 -0400
Received: from mpv8.case.edu (mpv8.tis.cwru.edu [129.22.105.116])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKG74000;
	Sat, 28 Apr 2012 22:31:58 -0400
Received: from h163.1.172.72.dynamic.ip.windstream.net (EHLO z4.local)
	([72.172.1.163]) by mpv8.case.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id TTR32871 (AUTH cpr);
	Sat, 28 Apr 2012 22:31:58 -0400 (EDT)
Message-ID: <4F9CA81C.4010808@case.edu>
Date: Sat, 28 Apr 2012 22:31:56 -0400
From: Chet Ramey <chet.ramey@case.edu>
Organization: ITS, Case Western Reserve University
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: Clark Wang <clark.wang@oracle.com>
Subject: Re: Passing variables by reference conflicts with local
References: <20100501081803.GA4615@rebase.prov>
	<n2kaca4c5091005010226p1e98d791h71e0fd5af8f325c3@mail.gmail.com>
	<r2pc440c9801005010240o2388c72fjb8ce0aa6b123d19c@mail.gmail.com>
	<20100501112118.GB4615@rebase.prov>
	<o2waca4c5091005010553le421a3c6g8efd54672006a194@mail.gmail.com>
	<20100501221925.GA4054@rebase.prov>
	<m2laca4c5091005011812ld8a9b92bv56b315f3eedf623e@mail.gmail.com>
	<20100502113559.GA3670@rebase.prov>
	<w2oaca4c5091005020611xe5d6bf0v7624aa92ee4c2077@mail.gmail.com>
	<20100503213852.GB3988@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
In-Reply-To: <CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
X-Enigmail-Version: 1.4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: bug-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 29 Apr 2012 02:32:03 -0000

On 4/23/12 4:56 AM, Clark Wang wrote:

> When I revisit this 2 years old thread I don't understand why following
> foo() function does not output the global var:
> 
> $ cat foo.sh
> var=global
> foo()
> {
>     local var=foo
>     unset var
>     echo foo: $var
> }
> bar_unset()
> {
>     unset var
> }
> bar()
> {
>     local var=bar
>     bar_unset
>     echo bar: $var
> }
> foo
> bar
> $ bash foo.sh
> foo:
> bar: global
> $
> 
> In foo() it unsets its local var so why doesn't the subsequent $var refer
> to the global var?

Greg's explanation in a subsequent message was pretty close.  Back a number
of years ago (16, to be exact), bash behaved like you expect.  Between
bash-1.14 and bash-2.0, I changed it in response to a number of bug reports
that complained that a variable declared local in a function wasn't local
when assigned a value in the function after being unset.  Bash keeps a
placeholder in the function's variable context so subsequent references to
that unset variable don't traverse back through the call chain.  This
placeholder affects functions called by the function unsetting the local
variable in the way you would expect dynamic scoping to work.

This only affects the current function, though: an unset issued from
farther down the call chain, as you discovered, will unset the local
variable without creating a placeholder.

Chet

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


From MAILER-DAEMON Mon Apr 30 05:24:29 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SOmqL-0000Bw-0H
	for mharc-bug-bash@gnu.org; Mon, 30 Apr 2012 05:24:29 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55434)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <ormaaj@gmail.com>) id 1SOmqH-0000BA-Qc
	for bug-bash@gnu.org; Mon, 30 Apr 2012 05:24:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <ormaaj@gmail.com>) id 1SOmqF-0001UB-UZ
	for bug-bash@gnu.org; Mon, 30 Apr 2012 05:24:25 -0400
Received: from mail-iy0-f169.google.com ([209.85.210.169]:33027)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <ormaaj@gmail.com>) id 1SOmqF-0001Q4-MA
	for bug-bash@gnu.org; Mon, 30 Apr 2012 05:24:23 -0400
Received: by iajr24 with SMTP id r24so4936832iaj.0
	for <bug-bash@gnu.org>; Mon, 30 Apr 2012 02:24:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=from:to:cc:subject:date:message-id:user-agent:in-reply-to
	:references:mime-version:content-type:content-transfer-encoding;
	bh=3xmw+r4o0S+KF56SZSgK7V+9nazaz1hAiBioikL8ihc=;
	b=V9P5AqqmS7d5wcjrvweFUkdNeqb+SLR8cpxmOJzSYQsfcETdmpZLWH+V9KwzhkYQrO
	cRNrtTBeYJep+UXEVerOHebuuOQSB6qgQClaBNpK9mVqhkZEwKGYqOM8TqdVqrPgeym9
	xPNfXeSsVN6/v9GJnBmcifq/STU7diPI6cgXfa99+VbNgJ1E4cY/a34Qm8iNIi4/U+0E
	ETEeSdc+cctyq879P+aZrl2EGlIL1+rNYycPe1LIhGpqNJ7jepRnOfOTuBBVRHNIK/Zz
	98eip8iglUUSWqJEFo/gllykID+CDBoTKSs0QqB5AZAWaq2RPjd0VvsVVoCr6xqCRJqk
	U63g==
Received: by 10.42.18.71 with SMTP id w7mr1278220ica.4.1335777860785;
	Mon, 30 Apr 2012 02:24:20 -0700 (PDT)
Received: from smorgbox.localnet (65-128-151-31.mpls.qwest.net.
	[65.128.151.31])
	by mx.google.com with ESMTPS id gf4sm14135163igb.14.2012.04.30.02.24.19
	(version=SSLv3 cipher=OTHER); Mon, 30 Apr 2012 02:24:19 -0700 (PDT)
From: Dan Douglas <ormaaj@gmail.com>
To: bug-bash@gnu.org
Subject: Re: Passing variables by reference conflicts with local
Date: Mon, 30 Apr 2012 02:24:19 -0700 (PDT)
Message-ID: <28430124.VShIv7qHlk@smorgbox>
User-Agent: KMail/4.8.2 (Linux/3.3.4-pf; KDE/4.8.2; x86_64; ; )
In-Reply-To: <CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
References: <20100501081803.GA4615@rebase.prov>
	<20100504175709.GA3757@blondy.prov>
	<CADv8-ohX7OcHePHWPnGWaK3z5ZnsWn1CR9A=5xRTLPEpnf9M1Q@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart3600119.dAhlzWDoqM";
	micalg="pgp-sha1"; protocol="application/pgp-signature"
Content-Transfer-Encoding: 7Bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.85.210.169
Cc: Clark Wang <clark.wang@oracle.com>
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 30 Apr 2012 09:24:27 -0000


--nextPart3600119.dAhlzWDoqM
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

On Monday, April 23, 2012 04:56:09 PM Clark Wang wrote:
> On Wed, May 5, 2010 at 01:57, Freddy Vulto <fvulto@gmail.com> wrote:
> > It appears that `unset' is capable of traversing down the call-stack and
> > ...

I reverse engineered most of this behavior a few months ago and wrote a 
detailed explaination and example here:

http://wiki.bash-hackers.org/commands/builtin/unset#scope

Hopefully most of that is correct.
-- 
Dan Douglas
--nextPart3600119.dAhlzWDoqM
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iEYEABECAAYFAk+eWjkACgkQMmyDamdg+MzZRgCcCvn7MIkFJk7qCEPx1iVWk9bm
OWMAnivcyz/83HAVp7Wm9K6qJ4QpQcEB
=TjtN
-----END PGP SIGNATURE-----

--nextPart3600119.dAhlzWDoqM--



From MAILER-DAEMON Mon Apr 30 09:57:36 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SOr6e-0003Oc-Sc
	for mharc-bug-bash@gnu.org; Mon, 30 Apr 2012 09:57:36 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47994)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOr6Y-0003NK-Kr
	for Bug-bash@gnu.org; Mon, 30 Apr 2012 09:57:35 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>) id 1SOr6T-0000LV-VJ
	for Bug-bash@gnu.org; Mon, 30 Apr 2012 09:57:30 -0400
Received: from mpv2.tis.cwru.edu ([129.22.105.37]:40926)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <chet.ramey@case.edu>)
	id 1SOr6Q-0000L6-9z; Mon, 30 Apr 2012 09:57:22 -0400
Received: from mpv6.cwru.edu (mpv6.tis.cwru.edu [129.22.104.221])
	by mpv2.tis.cwru.edu (MOS 4.3.3-GA) with ESMTP id BKH38326;
	Mon, 30 Apr 2012 09:57:17 -0400
Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211])
	by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued)
	with ESMTP id AWG75839 (AUTH cpr);
	Mon, 30 Apr 2012 09:57:17 -0400 (EDT)
Message-ID: <4F9E9A3C.6090207@case.edu>
Date: Mon, 30 Apr 2012 09:57:16 -0400
From: Chet Ramey <chet.ramey@case.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7;
	rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
To: humpty <humpty@sfr.fr>
Subject: Re: [Help-bash] /proc/.../cdrom/info not completely read
References: <4F9E346D.7080605@sfr.fr>
In-Reply-To: <4F9E346D.7080605@sfr.fr>
X-Enigmail-Version: 1.4.1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.37
Cc: Bug-bash@gnu.org, help-bash@gnu.org, chet.ramey@case.edu
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: chet.ramey@case.edu
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, 30 Apr 2012 13:57:35 -0000

On 4/30/12 2:42 AM, humpty wrote:
> hi,
> 
> I encounter a problem when I try to read /proc/sys/dev/cdrom/info
> 
> whatever method I try, bash doesn't read the whole file
> 
> $ file=/proc/sys/dev/cdrom/info
> $ while read line...done <"$file"
> only outputs the first line
> 
> $ exec {foo}<"$file"
> $ while read -u line
> outputs about six lines, as does
> $ mapfile -t myArray <"$file"
> and
> $ echo "$(<"$file")"
> 
> if I copy "$file" anywhere (say /tmp/) there is no problem any more.
> This happens with BASH 4.2 on Debian, and openSuse (and BASH 3.3.4 on
> archlinux (I've been told))
> 
> what could be the reason for such a behaviour?

This came up on one of the Linux distribution bugzilla sites (I think it
was debian).  The problem is that lseek is either a no-op or doesn't work
correctly on special files in /proc.

Bash reads 128 characters at a time and uses lseek to move the file pointer
back to the last character `read' consumes.  The negative offset to lseek
causes some kind of problem, but it doesn't return an error.  When bash
goes back for more, it gets short reads and incomplete data.

It's a kernel bug apparently introduced in 3.2.  It doesn't require bash
to test.

(I guess it was debian:
http://lists.debian.org/debian-kernel/2012/02/msg00874.html .  The original
report thread is http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659499 .)

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


From MAILER-DAEMON Mon Apr 30 10:10:47 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SOrJP-0007Hf-6w
	for mharc-bug-bash@gnu.org; Mon, 30 Apr 2012 10:10:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44810)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SOrJJ-0007HU-Rb
	for bug-bash@gnu.org; Mon, 30 Apr 2012 10:10:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SOrJG-0005S1-9O
	for bug-bash@gnu.org; Mon, 30 Apr 2012 10:10:41 -0400
Received: from ccfadm.eeg.ccf.org ([139.137.100.1]:47873
	helo=gateway.eeg.ccf.org) by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <wooledg@eeg.ccf.org>) id 1SOrJG-0005Rn-2c
	for bug-bash@gnu.org; Mon, 30 Apr 2012 10:10:38 -0400
Received: (qmail 19757 invoked from network); 30 Apr 2012 14:10:32 -0000
Received: from unknown (HELO imadev.eeg.ccf.org) (10.76.173.78)
	by ccfadm.eeg.ccf.org with SMTP; Mon, 30 Apr 2012 10:10:32 -0400
Received: (qmail 9158 invoked by uid 563); 30 Apr 2012 14:10:31 -0000
Date: Mon, 30 Apr 2012 10:10:31 -0400
From: Greg Wooledge <wooledg@eeg.ccf.org>
To: Chet Ramey <chet.ramey@case.edu>
Subject: Re: [Help-bash] /proc/.../cdrom/info not completely read
Message-ID: <20120430141031.GE4278@eeg.ccf.org>
References: <4F9E346D.7080605@sfr.fr> <4F9E9A3C.6090207@case.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4F9E9A3C.6090207@case.edu>
User-Agent: Mutt/1.4.2.3i
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	2)
X-Received-From: 139.137.100.1
Cc: humpty <humpty@sfr.fr>, Bug-bash@gnu.org, help-bash@gnu.org
X-BeenThere: bug-bash@gnu.org
X-Mailman-Version: 2.1.14
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, 30 Apr 2012 14:10:46 -0000

On Mon, Apr 30, 2012 at 09:57:16AM -0400, Chet Ramey wrote:
> Bash reads 128 characters at a time and uses lseek to move the file pointer
> back to the last character `read' consumes.  The negative offset to lseek
> causes some kind of problem, but it doesn't return an error.  When bash
> goes back for more, it gets short reads and incomplete data.
> 
> It's a kernel bug apparently introduced in 3.2.  It doesn't require bash
> to test.
> 
> (I guess it was debian:
> http://lists.debian.org/debian-kernel/2012/02/msg00874.html .  The original
> report thread is http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659499 .)

That's... interesting, since I got exactly the same failures on a stock
Debian 6.0 system (bash 4.1.5, kernel 2.6.32-5-686).

Is this something that was broken until kernel 3.0 or 3.1, then fixed
briefly, and then broken again?  (I haven't used a Linux 3.x kernel yet.)

Since this fails:

#include <unistd.h>
main() {
    char s[20];
    int n;
    while ((n = read(0, s, 20)) > 0) {
        write(1, s, n);
    }
}

I cannot consider this anything but a kernel bug.  Successive reads
from an open file descriptor without any intervening close() or lseek()
should get the full content of the "file".  The kernel should be putting
the full set of data into a nonvolatile buffer when such a "file" is
opened, and only releasing that buffer when it's closed.


