Re: [Toybox] Would someone please explain what bash is doing here?

2020-06-01 Thread Chet Ramey
On 5/31/20 1:54 AM, Rob Landley wrote: > I can do various forms of cleanup, yes. But individual whack-a-mole will > always > have something else it misses (you can sing "a signal won't always kill > zombies" > to the tune of "my bonnie lies over the ocean"), so I want more systematic >

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-30 Thread Rob Landley
On 5/29/20 1:09 PM, Chet Ramey wrote: > On 5/28/20 6:41 PM, Rob Landley wrote: >>> If you're worried about leaving stray background jobs around, end your >>> test script with `wait'. >> >> Which will hang if the background job is hung. > > It's pretty easy to send yourself a signal from a

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-30 Thread Rob Landley
On 5/29/20 1:10 PM, Chet Ramey wrote: > On 5/29/20 2:09 PM, Chet Ramey wrote: > Bash-5.1 will change the way it does $SECONDS to use gettimeofday(), btw. >>> >>> Meanwhile, I'm fielding: >>> >>> https://github.com/landley/toybox/pull/210 >> >> Ironically, gettimeofday() is more portable. >

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-29 Thread Chet Ramey
On 5/29/20 2:09 PM, Chet Ramey wrote: >>> Bash-5.1 will change the way it does $SECONDS to use gettimeofday(), btw. >> >> Meanwhile, I'm fielding: >> >> https://github.com/landley/toybox/pull/210 > > Ironically, gettimeofday() is more portable. Whoops, I sent that too early:

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-29 Thread Chet Ramey
On 5/28/20 6:41 PM, Rob Landley wrote: >> If you support job control IDs, you're already supporting `%' as a special >> prefix. What's the difference? > > I meant we've resolved that % is one prefix and %? is another prefix with > similar but distinct meaning. I.E. %? is, itself, a special

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-28 Thread Rob Landley
On 5/28/20 4:08 PM, Chet Ramey wrote: > On 5/27/20 6:17 PM, Rob Landley wrote: > >>> But what are you going to do with a shell script when you suspend a >>> pipeline in it? Keep on going with reading commands in the script? That's >>> rarely going to be what the user wants. Most people expect the

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-28 Thread Chet Ramey
On 5/27/20 6:17 PM, Rob Landley wrote: >> But what are you going to do with a shell script when you suspend a >> pipeline in it? Keep on going with reading commands in the script? That's >> rarely going to be what the user wants. Most people expect the shell >> running the script to get suspended

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-27 Thread Rob Landley
On 5/27/20 2:31 PM, Chet Ramey wrote: >> Right. So it CAN include more stuff, it just doesn't. And instead the stuff >> RESUMES. (Is that posix what posix says to do? Does a shell script differ >> from >> interactive behavior here?) > > Yes, that's how you have to handle it. And it doesn't

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-27 Thread Rob Landley
On 5/27/20 2:31 PM, enh wrote: >> Do they have a regression test suite? I'd love to harvest test cases... >> >> Yes they do, and it has a README. Hmmm... > > (remember that mksh has a pretty extensive test suite too.) I'm happy to look at other shells' test suites for tests that _bash_ passes.

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-27 Thread Chet Ramey
On 5/27/20 2:07 PM, Rob Landley wrote: > Ok, I was trying to figure out what "jobs" should display when the pipeline it > stopped is held together by && and || rather than just by | and... apparently > you need parentheses or curly brackets to get it to do that, because suspended > commands exit

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-27 Thread enh via Toybox
On Sat, May 23, 2020 at 8:19 PM Rob Landley wrote: > > On 5/23/20 5:51 PM, Chet Ramey wrote: > > On 5/23/20 1:11 PM, Rob Landley wrote: > >> Starting to open the job control can of worms, and: > >> > >> $ while true; do readlink /proc/self | cat - $$; done > >> 24658 > >> cat: 20032: No

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-27 Thread enh via Toybox
On Mon, May 18, 2020 at 8:41 AM Chet Ramey wrote: > > On 5/17/20 7:11 AM, Rob Landley wrote: > > I had a reply window open to this when my laptop battery died, and > > thunderbird > > doesn't store unfinished messages like kmail and vi and chrome... > > > > Anyway, I was reminded of this thread

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-27 Thread enh via Toybox
On Sun, May 17, 2020 at 4:04 AM Rob Landley wrote: > > I had a reply window open to this when my laptop battery died, and thunderbird > doesn't store unfinished messages like kmail and vi and chrome... > > Anyway, I was reminded of this thread by: > > $ IFS=x; ABC=cxd; for i in +($ABC); do echo

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-27 Thread Rob Landley
On 5/23/20 5:51 PM, Chet Ramey wrote: > On 5/23/20 1:11 PM, Rob Landley wrote: >> Starting to open the job control can of worms, and: >> >> $ while true; do readlink /proc/self | cat - $$; done >> 24658 >> cat: 20032: No such file or directory >> 24660 >> cat: 20032: No such file or

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-25 Thread Chet Ramey
On 5/25/20 6:39 AM, Rob Landley wrote: > On 5/24/20 4:32 PM, Chet Ramey wrote: >>> In new tab: >>> $ echo $LINENO\ >>> > $LINENO >>> 22 >>> $ echo $LINENO >>> 3 >>> >>> It cares about the space. >> >> Of course it does! > > It's not an "of course" for me. My code doesn't work like that.

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-25 Thread Rob Landley
On 5/24/20 4:32 PM, Chet Ramey wrote: >> In new tab: >> $ echo $LINENO\ >> > $LINENO >> 22 >> $ echo $LINENO >> 3 >> >> It cares about the space. > > Of course it does! It's not an "of course" for me. My code doesn't work like that. > The space terminates the token! Unquoted tokens

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-24 Thread Chet Ramey
On 5/24/20 5:05 PM, Rob Landley wrote: > On 5/24/20 3:46 PM, Chet Ramey wrote: >>> No, I meant the LINENO on the second line isn't noticing it's on a later >>> line, >>> it's now reporting the first line for both LINENOs, and I thought my initial >>> confusion was about it NOT doing that? >> >>

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-24 Thread Chet Ramey
On 5/23/20 11:19 PM, Rob Landley wrote: >> Correct. Each element of a pipeline is executed in a subshell. > > Hmmm. > >>> But: >>> >>> $ echo hello | read i; echo $i >>> >>> The read isn't saved because it's happening in a subshell context (so it >>> sets an >>> i that is discarded)? >> >>

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-24 Thread Rob Landley
On 5/24/20 3:46 PM, Chet Ramey wrote: >> No, I meant the LINENO on the second line isn't noticing it's on a later >> line, >> it's now reporting the first line for both LINENOs, and I thought my initial >> confusion was about it NOT doing that? > > I'm not sure myself. > > The backslash-newline

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-24 Thread Chet Ramey
On 5/23/20 8:59 PM, Rob Landley wrote: >>> It's there in each new terminal tab. It's not a thing I typed. >> >> Maybe run `bash -x' or `bash --login -x' and see where it gets set. > > Scrolled off the terminal history. Let's see... > > $ bash -x 2>&1 | tee florp.txt > exit > + exit > >

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-23 Thread Rob Landley
On 5/23/20 3:40 PM, Chet Ramey wrote: > On 5/23/20 1:06 PM, Rob Landley wrote: >> On 5/23/20 9:41 AM, Chet Ramey wrote: >>> On 5/21/20 6:50 PM, Rob Landley wrote: >>> >> But the same command line in the current shell and in bash -c are parsing >> different despite presumably reading the

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-23 Thread Chet Ramey
On 5/23/20 1:11 PM, Rob Landley wrote: > Starting to open the job control can of worms, and: > > $ while true; do readlink /proc/self | cat - $$; done > 24658 > cat: 20032: No such file or directory > 24660 > cat: 20032: No such file or directory > 24662 > > Is calling readlink and

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-23 Thread Chet Ramey
On 5/23/20 1:06 PM, Rob Landley wrote: > On 5/23/20 9:41 AM, Chet Ramey wrote: >> On 5/21/20 6:50 PM, Rob Landley wrote: >> > But the same command line in the current shell and in bash -c are parsing > different despite presumably reading the same .bashrc and friends? My guess is

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-23 Thread Rob Landley
Starting to open the job control can of worms, and: $ while true; do readlink /proc/self | cat - $$; done 24658 cat: 20032: No such file or directory 24660 cat: 20032: No such file or directory 24662 Is calling readlink and cat each time through the loop (true is a builtin), so the

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-23 Thread Rob Landley
On 5/23/20 9:41 AM, Chet Ramey wrote: > On 5/21/20 6:50 PM, Rob Landley wrote: > But the same command line in the current shell and in bash -c are parsing different despite presumably reading the same .bashrc and friends? >>> >>> My guess is that the interactive shell has extglob

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-23 Thread Chet Ramey
On 5/21/20 6:50 PM, Rob Landley wrote: >>> But the same command line in the current shell and in bash -c are parsing >>> different despite presumably reading the same .bashrc and friends? >> >> My guess is that the interactive shell has extglob enabled somehow, whether >> it was in .bashrc or

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-22 Thread scsijon
On 22/5/20 8:03 pm, Rob Landley wrote: On 5/22/20 12:42 AM, scsijon wrote: Mine too, but grep isn't finding extglob under /etc or ~/.* ? from inside /etc/bash.bashrc /cut I'm not entirely sure what you meant here, but I attached /etc/bash.bashrc from devuan 2.0 and it does not contain

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-22 Thread Rob Landley
On 5/22/20 12:42 AM, scsijon wrote: >> Mine too, but grep isn't finding extglob under /etc or ~/.* > > ? from inside /etc/bash.bashrc > > /cut I'm not entirely sure what you meant here, but I attached /etc/bash.bashrc from devuan 2.0 and it does not contain "ext" or "glob". (Or "cut".) Rob #

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-21 Thread scsijon
On 22/5/20 12:49 pm, toybox-requ...@lists.landley.net wrote: Message: 2 Date: Thu, 21 May 2020 17:50:49 -0500 From: Rob Landley To: chet.ra...@case.edu, enh Cc: toybox Subject: Re: [Toybox] Would someone please explain what bash is doing here? Message-ID: <713fa4a5-28ad-6664-7

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-21 Thread Rob Landley
On 5/20/20 8:39 AM, Chet Ramey wrote: > On 5/19/20 4:03 PM, Rob Landley wrote: >> On 5/18/20 10:41 AM, Chet Ramey wrote: >>> On 5/17/20 7:11 AM, Rob Landley wrote: I had a reply window open to this when my laptop battery died, and thunderbird doesn't store unfinished messages like

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-20 Thread Chet Ramey
On 5/19/20 4:03 PM, Rob Landley wrote: > On 5/18/20 10:41 AM, Chet Ramey wrote: >> On 5/17/20 7:11 AM, Rob Landley wrote: >>> I had a reply window open to this when my laptop battery died, and >>> thunderbird >>> doesn't store unfinished messages like kmail and vi and chrome... >>> >>> Anyway, I

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-19 Thread Rob Landley
On 5/18/20 10:41 AM, Chet Ramey wrote: > On 5/17/20 7:11 AM, Rob Landley wrote: >> I had a reply window open to this when my laptop battery died, and >> thunderbird >> doesn't store unfinished messages like kmail and vi and chrome... >> >> Anyway, I was reminded of this thread by: >> >> $

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-18 Thread Chet Ramey
On 5/17/20 7:11 AM, Rob Landley wrote: > I had a reply window open to this when my laptop battery died, and thunderbird > doesn't store unfinished messages like kmail and vi and chrome... > > Anyway, I was reminded of this thread by: > > $ IFS=x; ABC=cxd; for i in +($ABC); do echo =$i=; done >

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-17 Thread Rob Landley
I had a reply window open to this when my laptop battery died, and thunderbird doesn't store unfinished messages like kmail and vi and chrome... Anyway, I was reminded of this thread by: $ IFS=x; ABC=cxd; for i in +($ABC); do echo =$i=; done =+(c= =d)= $ bash -c 'IFS=x; ABC=cxd; for i in

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-11 Thread Chet Ramey
On 5/10/20 7:24 PM, Rob Landley wrote: >>> $ echo \ >>> > $LINENO >>> 2 >>> >>> $ echo $LINENO \ >>> $LINENO >>> 1 1 >> >> Let's look at these two. This is one of the consequences of using a parser >> generator, which builds commands from the bottom up (This Is The House That >> yacc

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-10 Thread Rob Landley
On 5/10/20 12:13 PM, Chet Ramey wrote: >> Somebody on patreon. (I also stopped patreoning.) > > I read the comment. It's too bad that donations come with those kinds of > strings attached. Eh, the new part is just me not handling things well right now. I'm at stress capacity and cannot currently

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-10 Thread Chet Ramey
On 5/8/20 4:17 PM, Rob Landley wrote: > On 5/6/20 2:32 PM, Chet Ramey wrote: >> On 5/6/20 2:08 PM, Rob Landley wrote: >> You're blogging these bash corner cases, too? >>> >>> I was. I was recently asked to stop. >> >> Who asked you to stop? > > Somebody on patreon. (I also stopped

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-06 Thread Chet Ramey
On 5/6/20 2:08 PM, Rob Landley wrote: >> You're blogging these bash corner cases, too? > > I was. I was recently asked to stop. Who asked you to stop? > If you change them, that makes bash a moving target. Bash is evolving, not dead. There is room for bug fixes and improvements everywhere.

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-06 Thread Rob Landley
On 5/5/20 5:33 PM, Chet Ramey wrote: > On 5/5/20 1:47 PM, Rob Landley wrote: >> On 5/4/20 1:16 PM, Chet Ramey wrote: Still trying to work out what the "bash spec" would be, vs implementation details... >>> >>> I'll be interested when you get that spec done. >> >> I'd love to read it

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-05 Thread Chet Ramey
On 5/5/20 1:47 PM, Rob Landley wrote: > On 5/4/20 1:16 PM, Chet Ramey wrote: >>> Still trying to work out what the "bash spec" would be, vs implementation >>> details... >> >> I'll be interested when you get that spec done. > > I'd love to read it myself. Alas, it's corner cases all the way

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-05 Thread Rob Landley
On 5/4/20 1:16 PM, Chet Ramey wrote: >> Still trying to work out what the "bash spec" would be, vs implementation >> details... > > I'll be interested when you get that spec done. I'd love to read it myself. Alas, it's corner cases all the way down: $ bash -c $'echo $LINENO\necho $LINENO'

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-04 Thread Chet Ramey
On 5/4/20 12:20 PM, Rob Landley wrote: > On 5/4/20 8:39 AM, Chet Ramey wrote: >> On 5/2/20 4:01 PM, Rob Landley wrote: >> >>> Why does the export flag on $_ toggle? >> >> It does three different things. It's initially exported if bash inherits it >> from the environment at startup; after that it

Re: [Toybox] Would someone please explain what bash is doing here?

2020-05-04 Thread Chet Ramey
On 5/2/20 4:01 PM, Rob Landley wrote: > Why does the export flag on $_ toggle? It does three different things. It's initially exported if bash inherits it from the environment at startup; after that it does its thing. "_ At shell startup, set to the absolute pathname used to invoke

Re: [Toybox] Would someone please explain what bash is doing here?

2020-04-25 Thread Chet Ramey
On 4/24/20 3:07 PM, Rob Landley wrote: >> I tested on Mac OS using bash-5.0 and bash-4.4. I'm not really interested >> in testing versions before that. > > $ bash --version > GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu) > > Devuan ascii 2.0 which is basically debian. > >

Re: [Toybox] Would someone please explain what bash is doing here?

2020-04-24 Thread Chet Ramey
On 4/24/20 3:07 PM, Rob Landley wrote: > > > On 4/24/20 10:55 AM, Chet Ramey wrote: >> On 4/24/20 9:48 AM, Rob Landley wrote: >>> Try this in bash, and hit ctrl-Z before it returns: >>> >>> /bin/echo $(ls /usr/bin; sleep 5) >>> >>> Now try to get your terminal back. (Prompt doesn't come back,

Re: [Toybox] Would someone please explain what bash is doing here?

2020-04-24 Thread Rob Landley
On 4/24/20 10:55 AM, Chet Ramey wrote: > On 4/24/20 9:48 AM, Rob Landley wrote: >> Try this in bash, and hit ctrl-Z before it returns: >> >> /bin/echo $(ls /usr/bin; sleep 5) >> >> Now try to get your terminal back. (Prompt doesn't come back, timeout doesn't >> happen, ctrl-c doesn't work...)

Re: [Toybox] Would someone please explain what bash is doing here?

2020-04-24 Thread Chet Ramey
On 4/24/20 9:48 AM, Rob Landley wrote: > Try this in bash, and hit ctrl-Z before it returns: > > /bin/echo $(ls /usr/bin; sleep 5) > > Now try to get your terminal back. (Prompt doesn't come back, timeout doesn't > happen, ctrl-c doesn't work...) It has no effect. The command substitution

Re: [Toybox] Would someone please explain what bash is doing here?

2020-04-24 Thread Rob Landley
Try this in bash, and hit ctrl-Z before it returns: /bin/echo $(ls /usr/bin; sleep 5) Now try to get your terminal back. (Prompt doesn't come back, timeout doesn't happen, ctrl-c doesn't work...) Maybe it's been fixed since the version in devuan? Rob

Re: [Toybox] Would someone please explain what bash is doing here?

2020-04-02 Thread Chet Ramey
On 3/31/20 10:23 AM, Rob Landley wrote: > Did you know that when RANDOM is exported, the readonly attribute is ignored > (but prserved!) in a DIFFERENT way? How so? The example doesn't really show that. > $ readonly RANDOM > $ export RANDOM=0 > $ echo $RANDOM > 24315 > $ export RANDOM=42 > $

Re: [Toybox] Would someone please explain what bash is doing here?

2020-04-02 Thread Chet Ramey
On 4/1/20 6:20 PM, Chet Ramey wrote: > Dynamic variables only have their value functions called when the variable > is referenced. When the variables are simply fetched (declare -p, and > similar) or enumerated (building an export array), you get the value > stored in the variable, which is the

Re: [Toybox] Would someone please explain what bash is doing here?

2020-04-01 Thread Chet Ramey
On 3/30/20 6:59 PM, Rob Landley wrote: > Aha: > > $ readonly SECONDS; SECONDS=0; echo $SECONDS; echo hello > $ readonly SECONDS; SECONDS=0 > $ echo $? > 1 > > No error message. Line processing aborted despite ; not being &&. The assignment function for SECONDS ignored it, but the

Re: [Toybox] Would someone please explain what bash is doing here?

2020-04-01 Thread Chet Ramey
On 3/30/20 6:45 PM, Rob Landley wrote: > Bash's handling of $SECONDS is kind of inconsistent: Dynamic variables like SECONDS and RANDOM (and FUNCNAME, and HISTCMD, and BASH_COMMAND, etc.) are different beasts, to be sure. For one thing, dynamic variables have complete freedom over their

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-31 Thread Rob Landley
On 3/31/20 9:23 AM, Rob Landley wrote: > On 3/30/20 5:59 PM, Rob Landley wrote: >> On 3/30/20 5:45 PM, Rob Landley wrote: >>> Bash's handling of $SECONDS is kind of inconsistent: >>> >>> $ SECONDS=0; echo $SECONDS # why does this print nothing? >>> $ readonly SECONDS; declare -p SECONDS ;

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-31 Thread Rob Landley
On 3/30/20 5:59 PM, Rob Landley wrote: > On 3/30/20 5:45 PM, Rob Landley wrote: >> Bash's handling of $SECONDS is kind of inconsistent: >> >> $ SECONDS=0; echo $SECONDS # why does this print nothing? >> $ readonly SECONDS; declare -p SECONDS ; SECONDS=0 >> declare -ir SECONDS="6" >> $ echo

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-30 Thread Rob Landley
On 3/30/20 5:45 PM, Rob Landley wrote: > Bash's handling of $SECONDS is kind of inconsistent: > > $ SECONDS=0; echo $SECONDS # why does this print nothing? > $ readonly SECONDS; declare -p SECONDS ; SECONDS=0 > declare -ir SECONDS="6" > $ echo $SECONDS # readonly was ignored, assignment happened

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-30 Thread Rob Landley
Bash's handling of $SECONDS is kind of inconsistent: $ SECONDS=0; echo $SECONDS # why does this print nothing? $ readonly SECONDS; declare -p SECONDS ; SECONDS=0 declare -ir SECONDS="6" $ echo $SECONDS # readonly was ignored, assignment happened anyway 10 $ SECONDS=123+456 # it STARTS integer,

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-16 Thread Chet Ramey
On 3/16/20 8:54 AM, Rob Landley wrote: > On 3/13/20 1:45 PM, Chet Ramey wrote: >> On 3/13/20 12:27 PM, enh wrote: >> The dash folks would say so. >>> >>> except now you need two shells :-) >> >> Well, that's their bed. I would say you only need one, of course. > > Next question: what's the

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-16 Thread Rob Landley
On 3/13/20 1:45 PM, Chet Ramey wrote: > On 3/13/20 12:27 PM, enh wrote: > >>> The dash folks would say so. >> >> except now you need two shells :-) > > Well, that's their bed. I would say you only need one, of course. Next question: what's the deal with "echo $( input $ echo $(&2) $ echo

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-14 Thread Rob Landley
On 3/13/20 1:42 PM, Chet Ramey wrote: > On 3/13/20 12:25 PM, Rob Landley wrote: > , as does >> dash -c 'echo hello;}' (14 years after ubuntu's /bin/sh)? > > ? > > $ dash -c 'echo hello;}' ; echo $? > dash: 1: Syntax error: "}" unexpected > 2 The devuan ascii one doesn't, I suppose that's fixed

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-13 Thread Chet Ramey
On 3/13/20 12:27 PM, enh wrote: >> The dash folks would say so. > > except now you need two shells :-) Well, that's their bed. I would say you only need one, of course. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-13 Thread Chet Ramey
On 3/13/20 12:25 PM, Rob Landley wrote: >> The dash folks would say so. > > Uh-huh. So it's a _choice_ that "dash /usr/bin" exits with 0 Yes. Most of the ash derivatives (dash, netbsd sh, freebsd sh, etc.) exit with 0 in that case -- none have ever implemented binary file checking, or check

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-13 Thread enh via Toybox
On Fri, Mar 13, 2020 at 6:12 AM Chet Ramey wrote: > > On 3/12/20 7:08 PM, Rob Landley wrote: > > >>> Minimalism and POSIX conformance are the big selling points now, at least > >>> on the shell side of things. > > > > I dunno about minimalism, but I'm trying to get toys/pending/sh.c in under > >

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-13 Thread Chet Ramey
On 3/12/20 7:08 PM, Rob Landley wrote: >>> Minimalism and POSIX conformance are the big selling points now, at least >>> on the shell side of things. > > I dunno about minimalism, but I'm trying to get toys/pending/sh.c in under > 3500 > lines. (It's 2400 now, maybe 100 of which is debug code.

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-12 Thread enh via Toybox
On Thu, Mar 12, 2020 at 4:02 PM Rob Landley wrote: > > On 3/10/20 11:50 AM, enh wrote: > > On Tue, Mar 10, 2020 at 8:42 AM Chet Ramey wrote: > >> On 3/9/20 11:16 PM, Rob Landley wrote: > -- but i can't even imagine a world in > which someone comes to me asking for more *dash*

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-12 Thread Rob Landley
On 3/10/20 11:50 AM, enh wrote: > On Tue, Mar 10, 2020 at 8:42 AM Chet Ramey wrote: >> On 3/9/20 11:16 PM, Rob Landley wrote: -- but i can't even imagine a world in which someone comes to me asking for more *dash* compatibility :-) >>> >>> It was a mistake Ubuntu made and pushed

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-12 Thread Chet Ramey
On 3/12/20 12:53 PM, Rob Landley wrote: > On 3/12/20 9:37 AM, Chet Ramey wrote: >> On 3/11/20 11:55 PM, Rob Landley wrote: >>> Word splitting isn't really a seperate step, exactly? "echo one two three" >>> doesn't care about $IFS, and the output of any of the OTHER substitutions: >> >> It is,

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-12 Thread Rob Landley
On 3/12/20 9:37 AM, Chet Ramey wrote: > On 3/11/20 11:55 PM, Rob Landley wrote: >> Word splitting isn't really a seperate step, exactly? "echo one two three" >> doesn't care about $IFS, and the output of any of the OTHER substitutions: > > It is, because it operates on the output of the other

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-12 Thread Chet Ramey
On 3/11/20 11:55 PM, Rob Landley wrote: > The bash man page says: > > There are seven kinds of expansion performed: brace expansion, > tilde expansion, parameter and variable expansion, command substituā€ > tion, arithmetic expansion, word splitting, and pathname expansion. > > Except

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-12 Thread Chet Ramey
On 3/11/20 10:41 PM, James McMechan wrote: > Well some of that is the glob() function or maybe wordexp(). My thought was > to make it so that when glob() hit a file named "-rf" to expand it would > expand it to "./-rf" to prevent people from being "too clever by half" That defeats the strategy

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-11 Thread Rob Landley
On 3/11/20 9:41 PM, James McMechan wrote: > > > On Sun, Mar 8, 2020, 12:29 Rob Landley > wrote: > > On 3/8/20 11:44 AM, Chet Ramey wrote: > > On 3/8/20 10:53 AM, Rob Landley wrote: > >> > >> I read through the posix shell bits long enough ago it was

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-11 Thread James McMechan
On Sun, Mar 8, 2020, 12:29 Rob Landley wrote: > On 3/8/20 11:44 AM, Chet Ramey wrote: > > On 3/8/20 10:53 AM, Rob Landley wrote: > >> > >> I read through the posix shell bits long enough ago it was probably > SUSv3 rather > >> than v4, but at the moment I'm taking bash as my standard and just

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-10 Thread enh via Toybox
On Tue, Mar 10, 2020 at 8:42 AM Chet Ramey wrote: > > On 3/9/20 11:16 PM, Rob Landley wrote: > > > Oh I imagine just about everything sees use. > > > > $ echo $((2**3)) > > 8 > > $ echo $((2**3.4)) > > bash: 2**3.4: syntax error: invalid arithmetic operator (error token is > > ".4") > >

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-10 Thread Chet Ramey
On 3/9/20 11:16 PM, Rob Landley wrote: > Oh I imagine just about everything sees use. > > $ echo $((2**3)) > 8 > $ echo $((2**3.4)) > bash: 2**3.4: syntax error: invalid arithmetic operator (error token is > ".4") Yeah, bash doesn't do any floating point at all. Use awk or bc. > I

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-10 Thread Chet Ramey
On 3/9/20 6:29 PM, enh wrote: > i can't even imagine a world in > which someone comes to me asking for more *dash* compatibility :-) I get those requests, if indirectly. People ask why bash's posix mode doesn't disable every feature that's not in POSIX, "kind of like dash." They don't realize

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-10 Thread Chet Ramey
On 3/9/20 4:10 PM, Rob Landley wrote: > On 3/8/20 2:57 PM, Chet Ramey wrote: >> Remember the brouhaha (this was at least 15 years ago) about the standard >> saying that `set -e' only applied to simple commands and bash having the >> audacity to implement what the standard said? Good times. > >

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-09 Thread Rob Landley
On 3/9/20 5:29 PM, enh wrote: > On Mon, Mar 9, 2020 at 1:05 PM Rob Landley wrote: >> I want to convince Android to create a "posix container" based on "mkroot >> plus >> stuff" within which AOSP image builds can run to completion on arbitrary >> android >> devices, but first I need to get Linux

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-09 Thread enh via Toybox
On Mon, Mar 9, 2020 at 1:05 PM Rob Landley wrote: > > On 3/8/20 2:57 PM, Chet Ramey wrote: > > Remember the brouhaha (this was at least 15 years ago) about the standard > > saying that `set -e' only applied to simple commands and bash having the > > audacity to implement what the standard said?

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-09 Thread Rob Landley
On 3/8/20 2:57 PM, Chet Ramey wrote: > Remember the brouhaha (this was at least 15 years ago) about the standard > saying that `set -e' only applied to simple commands and bash having the > audacity to implement what the standard said? Good times. Bit too inside baseball for me. Computer history

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-08 Thread Chet Ramey
On 3/8/20 2:55 PM, Rob Landley wrote: > On 3/8/20 11:44 AM, Chet Ramey wrote: >> On 3/8/20 10:53 AM, Rob Landley wrote: >>> >>> I read through the posix shell bits long enough ago it was probably SUSv3 >>> rather >>> than v4, but at the moment I'm taking bash as my standard and just doing >>>

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-08 Thread Rob Landley
On 3/8/20 11:44 AM, Chet Ramey wrote: > On 3/8/20 10:53 AM, Rob Landley wrote: >> >> I read through the posix shell bits long enough ago it was probably SUSv3 >> rather >> than v4, but at the moment I'm taking bash as my standard and just doing >> whatever that does. > > Well, I appreciate

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-08 Thread Chet Ramey
On 3/8/20 10:53 AM, Rob Landley wrote: > > I read through the posix shell bits long enough ago it was probably SUSv3 > rather > than v4, but at the moment I'm taking bash as my standard and just doing > whatever that does. Well, I appreciate that, but there just might be one or two places (or,

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-08 Thread Rob Landley
On 3/7/20 3:38 PM, Chet Ramey wrote: > On 3/6/20 9:05 PM, Rob Landley wrote: >> It turns into echo "=a" "" "bf=" and when I do that from the command line I >> get >> a space before and a space after the NULL argument? But with bash there are >> three? Is it turning into two NULL entries? Ah, it

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-08 Thread Chet Ramey
On 3/6/20 9:05 PM, Rob Landley wrote: >>> you could try chet ramey or the bash mailing list... he joins in a lot >>> of the shell discussions on the POSIX mailing list. >> >> I'm reluctant to trigger a change in bash's behavior that it's been doing >> consistently since at least 2002, but I am

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-06 Thread Rob Landley
On 3/6/20 5:46 PM, Rob Landley wrote: >> On Fri, Mar 6, 2020 at 4:03 AM Rob Landley wrote: >>> >>> Is it just me, or is bash's unquoted $@ processing with a non-whitespace IFS >>> only retaining blank arguments when they're followed by another argument >>> (even >>> if that one is blank)? >>>

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-06 Thread Rob Landley
> On Fri, Mar 6, 2020 at 4:03 AM Rob Landley wrote: >> >> Is it just me, or is bash's unquoted $@ processing with a non-whitespace IFS >> only retaining blank arguments when they're followed by another argument >> (even >> if that one is blank)? >> >> $ func() { bash -c 'IFS=x; for i in $@; do

Re: [Toybox] Would someone please explain what bash is doing here?

2020-03-06 Thread enh via Toybox
you could try chet ramey or the bash mailing list... he joins in a lot of the shell discussions on the POSIX mailing list. On Fri, Mar 6, 2020 at 4:03 AM Rob Landley wrote: > > Is it just me, or is bash's unquoted $@ processing with a non-whitespace IFS > only retaining blank arguments when

[Toybox] Would someone please explain what bash is doing here?

2020-03-06 Thread Rob Landley
Is it just me, or is bash's unquoted $@ processing with a non-whitespace IFS only retaining blank arguments when they're followed by another argument (even if that one is blank)? $ func() { bash -c 'IFS=x; for i in $@; do echo =$i=; done' blah "$@"; } $ func one "" two =one= == =two= $ func one