Unexpected delay in using arguments.

2018-08-12 Thread Bize Ma
Try this script: #!/bin/bash TIMEFORMAT='%R' n=1000 m=2 f1 () { :; } f2 () { i=0; time while [ "$((i+=1))" -lt "$n" ]; do :; done i=0; time while [ "$((i+=1))" -lt "$n" ]; do f1; done } test1() { set -- $(seq $m)

Re: Rational Range Interpretation for bash-5.0?

2018-08-13 Thread Bize Ma
On 08/06/2018 03:07 PM, Chet Ramey wrote: Hi. I am considering making bash glob expansion implement rational range interpretation starting with bash-5.0 -- basically making globasciiranges the default. It looks like glibc is going to do this for version 2.28 (at least for a-z, A-Z, and 0-9), and o

Re: Unexpected delay in using arguments.

2018-08-13 Thread Bize Ma
Yes Greg, Please read the expanded source question, bash 5 with (and without) bash-malloc has been tested. https://unix.stackexchange.com/q/462084/265604 The problem with arguments is still present. 2018-08-13 9:37 GMT-04:00 Greg Wooledge : > On Sun, Aug 12, 2018 at 03:16:34AM -0400, B

Assignment of $* to a var removes spaces on unset IFS.

2018-08-13 Thread Bize Ma
Executing this code: set -- " foo "" bar baz " " quux " unset IFS a=$* b="$*" printf '[%s]' "$a" "$b"; echo Leads to this results in several shells: ash : [ foo bar baz quux ][ foo bar baz quux ] dash: [ foo bar baz

Re: Assignment of $* to a var removes spaces on unset IFS.

2018-08-13 Thread Bize Ma
2018-08-13 21:16 GMT-04:00 Eduardo Bustamante : > On Mon, Aug 13, 2018 at 5:25 PM Robert Elz wrote: > [...] > > What's more, reporting bugs in bash 4.3 is just a waste of everyone's > time. > > Upgrade to (at least) the current released version, and use that instead. > > Adding to this point: > >

Re: Assignment of $* to a var removes spaces on unset IFS.

2018-08-13 Thread Bize Ma
2018-08-13 22:09 GMT-04:00 Eduardo A. Bustamante López : > On Mon, Aug 13, 2018 at 09:36:23PM -0400, Bize Ma wrote: > (...) > > Please, do not waste our time in incorrect claims. > > > > Do your homework and test ! > (...) > > > dualbus@ubuntu:~/src/g

Re: Assignment of $* to a var removes spaces on unset IFS.

2018-08-14 Thread Bize Ma
2018-08-13 23:17 GMT-04:00 Eduardo A. Bustamante López : > On Mon, Aug 13, 2018 at 10:52:20PM -0400, Bize Ma wrote: > (...) My point is that, in the context of bug reports, it's > important that you always test against the *unreleased* version of the > code, > Not if the ve

Re: Unexpected delay in using arguments.

2018-08-14 Thread Bize Ma
2018-08-14 11:25 GMT-04:00 Chet Ramey : > On 8/12/18 3:16 AM, Bize Ma wrote: > > Try this script: > (...) > Which is a thousand times slower. > > If you build a profiling version of bash, you'll find that about 75% of > that time is spent copying the list of argume

Re: Unexpected delay in using arguments.

2018-08-14 Thread Bize Ma
> Of course I assume this is only a proxy simpler reproducer > for the actual problem program Of course this is a "reproducer" of the issue. > but just the same it is almost always possible > to refactor a program into a different algorithm that avoids the need > to enumerate so many arguments in

Re: Unexpected delay in using arguments.

2018-08-15 Thread Bize Ma
2018-08-15 3:36 GMT-04:00 Bob Proulx : > Bize Ma wrote: > > I still believe that to be true. You are entitled to have an opinion, even if incorrect. > Since you haven't shared what the > actual task is there is no way for us to propose any counter example > improveme

Re: Assignment of $* to a var removes spaces on unset IFS.

2018-08-15 Thread Bize Ma
2018-08-15 8:44 GMT-04:00 Greg Wooledge : > This reply was sent to me without Cc-ing the list. I have added the Cc. > > On Tue, Aug 14, 2018 at 11:39:20PM -0400, Bize Ma wrote: > > On Tue, 14 Aug 2018 12:34:31, Greg Wooledge said: > > > > > I will also repeat,

Bash removes unrequested characters in bracket expressions (not a range).

2018-11-23 Thread Bize Ma
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: Linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE

Re: Bash removes unrequested characters in bracket expressions (not a range).

2018-11-24 Thread Bize Ma
Chet Ramey () wrote: > On 11/23/18 6:09 PM, Bize Ma wrote: > > > Bash Version: 4.4 > > Patch Level: 12 > > Release Status: release > > > Description: > > > > Bash is removing characters not explicitly listed in a bracket > > expression (ch

Re: Bash removes unrequested characters in bracket expressions (not a range).

2018-12-01 Thread Bize Ma
Chet Ramey () wrote: > I am going to forward the rest of our exchange to bug-bash; Great! > you left the mailing list off your replies for some reason. > > Chet > Since it was *you* who directed the answer only to me, I assumed (now seemingly incorrectly) that that was what you wanted to do.

Re: Bash removes unrequested characters in bracket expressions (not a range).

2018-12-03 Thread Bize Ma
Chet Ramey () wrote: > On 11/24/18 4:32 PM, Bize Ma wrote: [...] > > I have been made aware that there is a > > cstart = cend = FOLD (cstart); > > inside the `sm_loop.c` file that will convert into a range many > > individual character. If that understan

Re: Bash removes unrequested characters in bracket expressions (not a range).

2018-12-03 Thread Bize Ma
Chet Ramey () wrote: > On 11/24/18 2:32 PM, Chet Ramey wrote: > > >> But IMO locale collation should not be used for an explicit list. > > > > Collation order is used for each individual character in a bracket > > expression when compared against the string, as posix specifies. > Yes, values resu

Re: Bash removes unrequested characters in bracket expressions (not a range).

2018-12-03 Thread Bize Ma
Chet Ramey () wrote: > I can't reproduce this: > If you could take a look at https://unix.stackexchange.com/a/483835/265604 you will see that it has been confirmed on "Ubuntu 17.10 (glibc 2.26) and on Ubuntu 18.04 (glibc 2.27), but it seems to be fixed on Ubuntu 18.10 (glibc 2.28)" It is intere

Re: write() not retried after EINTR in printf and echo

2018-12-18 Thread Bize Ma
In here: https://lists.gnu.org/archive/html/bug-bash/2018-01/msg00032.html You promised: The next version of bash will install its SIGWINCH handler with SA_RESTART. Yet: Still a bug in bash version 5

Re: write() not retried after EINTR in printf and echo

2018-12-19 Thread Bize Ma
Chet Ramey () wrote: > And yet, when you look at the source, the signal handlers are installed > with SA_RESTART. For example, > > # if defined (SIGWINCH) > act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0; > # else > act.sa_flags = 0; > # endif /* SIGWINCH */ > > in lib/readline/signals

Error on arithmetic evaluation of `~0`.

2018-12-19 Thread Bize Ma
This is the third time I am reporting this issue. This fails: var=(hello); echo "${var[~0]}" syntax error: operand expected ... While this works: var=(hello); echo "${var[ ~0]}" hello It is also interesting that this fails: var=hello; echo "${var[ ~0]}" bash: var: bad array subscript Isn't `

Terminating background bash kills the parent?

2018-12-19 Thread Bize Ma
Open a new terminal like xterm, change prompt to something like: PS1=' $SHLVL $ ' Start a couple of bash subshells: 1 $ bash 2 $ bash 3 $ echo $$ 9371 Suspend the last one: 3 $ suspend [1]+ Stopped bash 2 $ echo $$ 9313 2 $ Make the susp

readline fails to understand options.

2018-12-20 Thread Bize Ma
This works: $ bind 'set enable-bracketed-paste on'; bind -v | grep 'bracketed' set enable-bracketed-paste on However, almost any variation of the parameter "on" is not understood by readline: $ bind 'set enable-bracketed-paste on .'; bind -v | grep 'bracketed' set enable-brac

Re: Error on arithmetic evaluation of `~0`.

2018-12-23 Thread Bize Ma
Chet Ramey () wrote: > > > > While this works: > > > > var=(hello); echo "${var[ ~0]}" > > hello > > Because negative array subscripts count backwards from the end of the > array. > Doh!, yes. And, because of that: "${var[-1]}" should give the *last* element of array "var", shouldn't it? Consequ

Re: Unexpected delay in using arguments.

2018-12-23 Thread Bize Ma
Chet Ramey () wrote: > On 8/15/18 3:36 AM, Bob Proulx wrote: > > > It does look like bash can be more efficient with argument handling. > > Since, for example, dash does it. > > Yes, it just needs new primitives to do it. The existing code for managing > the saved positional parameters has been in

Re: write() not retried after EINTR in printf and echo

2018-12-25 Thread Bize Ma
Chet Ramey () wrote: > On 12/19/18 10:15 PM, Bize Ma wrote: > > Ah, now we're moving the goalposts. No, that is not the intent. I merely failed to correctly convey the perception that others have of your code: https://unix.stackexchange.com/a/487260/265604 And, having faile

Re: readline fails to understand options.

2018-12-28 Thread Bize Ma
> > Sure, it's a candidate for inclusion in a future version. I wouldn't object > if someone wanted to do a sample implementation, since it changes how the > variable value is parsed. > I only wish I knew enough C to make any (even small) positive recommendation.

Re: write() not retried after EINTR in printf and echo

2018-12-28 Thread Bize Ma
Eduardo Bustamante () wrote: > > (...) > What if instead of > complaining you do something about it, like, fixing the problem (send > a patch)? > You are assuming that if I take a look at the c code I will be able to read it, then understand it, and then make meaningful, or even reasonable cha

Re: Unexpected delay in using arguments.

2018-12-28 Thread Bize Ma
Chet Ramey () wrote: > On 12/23/18 12:07 PM, Bize Ma wrote: {...} > > Have you been able to "take a look" ? > > Yes, as a matter of fact. Look at the changelog for the day or two around > the date of the referenced messages. > I am pretty sure that I will not

Re: Error on arithmetic evaluation of `~0`.

2018-12-28 Thread Bize Ma
Chet Ramey () wrote: > On 12/23/18 12:01 PM, Bize Ma wrote: > {…} > > Both command line above should have printed "hello". > > No. 0 is the only valid subscript for a non-array variable. The difference > between bash and other shells that implement this fea

Re: Unexpected delay in using arguments.

2019-01-01 Thread Bize Ma
Chet Ramey () wrote: > It's in CWRU/CWRU.chlog in the development distributions > I am sorry but I have been unable to find either the source code or the change log, either at the university site or by looking with google. However, I have made some tests. Yes, the deeper internal delay with argu

Re: "return" should not continue script execution, even if used inappropriately

2019-01-21 Thread Bize Ma
-- *From*: Greg Wooledge *Subject*: Re: "return" should not continue script execution, even if used inappropriately *Date*: Mon, 21 Jan 2019 09:01:33 -0500 -- On Sun, Jan 20, 2019 at 05:43:04PM -0800, don fong wrote: >* i don't see how this h

Re: ${p+\"$p\"}

2019-01-21 Thread Bize Ma
*From*: Dan Jacobson *Subject*: ${p+\"$p\"} *Date*: Mon, 21 Jan 2019 21:14:26 +0800 -- So how am I to get "A" with bash? How about: #!/bin/bash p=A q='"' cat <<_EOF_ ${p+$q$p$q} _EOF_ Works on all shells I tested it.

Re: ${p+\"$p\"}

2019-01-21 Thread Bize Ma
-- *From*: Robert Elz *Subject*: Re: ${p+\"$p\"} *Date*: Mon, 21 Jan 2019 23:38:22 +0700 -- (...) > With the quotes, most other shells produce the output reported > from dash (that includes ksh93, yash, ...) zsh just says it iis > a parse e

Re: Unexpected delay in using arguments.

2019-01-31 Thread Bize Ma
Just to confirm that the delays were removed on the release version. Thanks Chet Ramey () wrote: In the development distributions, always available at > > http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-devel.tar.gz > > Or you could just clone the git tree. > Many thanks, found and

read -t 0 fails to detect input.

2019-12-18 Thread Bize Ma
It seems that read -t 0 should detect if there is input from a pipe (and others). >From man bash: >> If timeout is 0, read returns immediately, without trying to read any data. >> The exit status is 0 if input is available on the specified file descriptor, non-zero otherwise. So, it seems that

Fwd: read -t 0 fails to detect input.

2019-12-19 Thread Bize Ma
To: Chester Ramey On thu., dec. 19 of 2019 at 12:40, Chet Ramey () wrote: > On 12/18/19 6:40 PM, Bize Ma wrote: > > >>> The exit status is 0 if input is available on the specified file > > descriptor, non-zero otherwise. > > Bash-5.0 uses select/FIONREAD to det

Re: Fwd: read -t 0 fails to detect input.

2019-12-20 Thread Bize Ma
On Fri., 20 dec. 2019 at 3:57, Martin Schulte () wrote: > Hello! > > > Could you please comment about this assertions: > > > > 1.- bash will either do a select() or an ioctl(FIONREAD), or neither > > of them, but not both, as it should for it to work. read -t0 is broken. > > 2.- Conclusion: re

Not operator (~) fail on arithmetic expansion.

2016-11-27 Thread Bize Ma
Configuration Information: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR uname output: Linux zeus 4.8.0-1-amd64 #1 SMP Debian 4.8.5-1 (2016-10-28) x86_64 GNU/Li