Re: %q with truncating size loses safeness of %q

2020-04-20 Thread Sam Liddicott
On Sun, 19 Apr 2020 at 20:40, Chet Ramey wrote: > > On 4/17/20 6:37 PM, Robert Elz wrote: > > > This happens only because of the cheap way we (and I presume you) > > implement things - in any rational scheme, it would take the precision > > chars from the source string, and then quote them. That,

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread Koichi Murase
2020-04-20 10:00 George Jones : > Thank you. Patch applied and (performance) tested with come tests > I was working on > https://github.com/eludom/snippits/tree/master/bash/tests > bottom line: Thank you for the measurements. Also, I am sorry that I disturbed your plan for contributing to B

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread Koichi Murase
I'm sorry, there was a bug. This is the fixed patch (v3). -- Koichi 0001-hashlib-Implement-rehash.v3.patch Description: Binary data

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread Greg Wooledge
On Mon, Apr 20, 2020 at 06:48:44PM +0900, Koichi Murase wrote: > Also, I am sorry that I disturbed your plan for contributing to Bash. > I actually initially doubted that the insertion with the current > implementation is O(N), so I created the test first and then found > that it is an easy fix rat

Re: %q with truncating size loses safeness of %q

2020-04-20 Thread Chet Ramey
On 4/19/20 5:33 PM, Robert Elz wrote: > Date:Sun, 19 Apr 2020 15:40:39 -0400 > From:Chet Ramey > Message-ID: <8c5bdd2c-bc61-a885-6a05-690ef7f51...@case.edu> > > | Nobody, including POSIX, is rational, then. > > There is no %q in POSIX printf currently, so the issue

Re: %q with truncating size loses safeness of %q

2020-04-20 Thread Robert Elz
Date:Mon, 20 Apr 2020 09:03:39 -0400 From:Chet Ramey Message-ID: <51b585da-b594-740d-1772-3c3a25a89...@case.edu> | I'm referring to the specification of %b that I quoted in another message, I didn't see that (and I certainly didn't comment on it wrt rationality).

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread Chet Ramey
On 4/20/20 8:49 AM, Greg Wooledge wrote: > On Mon, Apr 20, 2020 at 06:48:44PM +0900, Koichi Murase wrote: >> Also, I am sorry that I disturbed your plan for contributing to Bash. >> I actually initially doubted that the insertion with the current >> implementation is O(N), so I created the test fir

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread Koichi Murase
2020-04-20 23:05 Chet Ramey : > On 4/20/20 8:49 AM, Greg Wooledge wrote: > > On Mon, Apr 20, 2020 at 06:48:44PM +0900, Koichi Murase wrote: > >> Also, I am sorry that I disturbed your plan for contributing to Bash. > >> I actually initially doubted that the insertion with the current > >> implement

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread George Jones
No problem. Glad you fixed it. It's been a LONG time since I've actually written C, so probably best if someone current did it. On the parameters, I suggest you consider exposing the at user level as a switch or env var. My use case was pathologically large (and would have been better on, e.

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread Chet Ramey
On 4/19/20 3:51 PM, Koichi Murase wrote: > > The associative arrays in `hashlib.c' are implemented by hash tables > as is clear from its name. The main lookup of hash table algorithm is > done by the following line > > bucket = HASH_BUCKET (string, table, hv); > > but not by the subsequent l

Bug in manual

2020-04-20 Thread Péter Kozics
In this one https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion one can read "Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1 by default. If offset is 0, and the positional parameters are

Expansions based on variable existence (e.g. ${var+exists}) yield inconsistent results.

2020-04-20 Thread andrej--- via Bug reports for the GNU Bourne Again SHell
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin' -DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/ba

Re: Expansions based on variable existence (e.g. ${var+exists}) yield inconsistent results.

2020-04-20 Thread Chet Ramey
On 4/20/20 11:55 AM, andrej--- via Bug reports for the GNU Bourne Again SHell wrote: > Bash Version: 5.0 > Patch Level: 16 > Release Status: release > > Description: > Variable existence testing doesn't match variables that are (only) declared. > Unless the declared variables are redeclared a

Re: Bug in manual

2020-04-20 Thread Chet Ramey
On 4/20/20 10:39 AM, Péter Kozics wrote: > In this one > https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion > > > > one can read > "Substring indexing is zero-based unless the positional parameters are > used, in which case the indexing starts at 1 by de

bash-20200417 snapshot breaks examples/loadables/push.c

2020-04-20 Thread Eli Schwartz
In the latest devel push: $ make -C examples/loadables/ make: Entering directory '/home/eschwartz/git/bash/examples/loadables' gcc -fPIC -DHAVE_CONFIG_H -DSHELL -g -O2 -Wno-parentheses -Wno-format-security -I. -I.. -I../.. -I../../lib -I../../builtins -I. -I../../include -I/home/eschwartz/git/ba

Re: bash-20200417 snapshot breaks examples/loadables/push.c

2020-04-20 Thread Chet Ramey
On 4/20/20 4:02 PM, Eli Schwartz wrote: > In the latest devel push: > > $ make -C examples/loadables/ > make: Entering directory '/home/eschwartz/git/bash/examples/loadables' > gcc -fPIC -DHAVE_CONFIG_H -DSHELL -g -O2 -Wno-parentheses > -Wno-format-security -I. -I.. -I../.. -I../../lib -I../../b

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread Chet Ramey
On 4/20/20 11:16 AM, George Jones wrote: > No problem. Glad you fixed it. It's been a LONG time since I've > actually written C, so probably best if someone current did it. > > On the parameters, I suggest you consider exposing the at user level as a > switch or env var. My use case was path

Re: process substitution fd lifetime race condition

2020-04-20 Thread Chet Ramey
On 4/20/20 1:15 AM, Jason A. Donenfeld wrote: > Hi, > > I've uncovered a very unusual race condition when using process > substitution and developed as minimal a reproducer as I could create: What version of bash are you using? Chet -- ``The lyf so short, the craft so long to lerne.'' - Chauce

Re: process substitution fd lifetime race condition

2020-04-20 Thread Jason A. Donenfeld
On 4/20/20, Chet Ramey wrote: > On 4/20/20 1:15 AM, Jason A. Donenfeld wrote: >> Hi, >> >> I've uncovered a very unusual race condition when using process >> substitution and developed as minimal a reproducer as I could create: > > What version of bash are you using? > 5.0.016

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread George Jones
No real opinion on syntax. Using something existing: declare -A foo[SIZE] seems sensible, especially if there was no semantic meaning (I'm not a fan of syntax without semantics clutter). Big thing is that the new stuff for fringe new pathologic use cases (mine) should not have negative

Re: process substitution fd lifetime race condition

2020-04-20 Thread Jason A. Donenfeld
Here's a simpler reproducer: set -e a="my name is a" b="my name is b" pretty() { echo -e "\x1b[0m"; } doit() { pretty; "$@"; } while true; do doit cat <(echo "$a") <(echo "$b") done

Re: process substitution fd lifetime race condition

2020-04-20 Thread Jason A. Donenfeld
This one will reproduce immediately: #!/bin/bash set -e a="my name is a" b="my name is b" sleep() { read -t "$1" -N 1 || true; } doit() { sleep 0.1; "$@"; } while true; do doit cat <(echo "$a") <(echo "$b") done

Re: process substitution fd lifetime race condition

2020-04-20 Thread Chet Ramey
On 4/20/20 5:01 PM, Jason A. Donenfeld wrote: > On 4/20/20, Chet Ramey wrote: >> On 4/20/20 1:15 AM, Jason A. Donenfeld wrote: >>> Hi, >>> >>> I've uncovered a very unusual race condition when using process >>> substitution and developed as minimal a reproducer as I could create: >> >> What versio

Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?)

2020-04-20 Thread Greg Wooledge
On Mon, Apr 20, 2020 at 05:12:28PM -0400, George Jones wrote: > No real opinion on syntax. > > Using something existing: > > declare -A foo[SIZE] > > seems sensible, especially if there was no semantic meaning (I'm not a fan > of syntax without semantics clutter). That's pretty C-like,

Re: process substitution fd lifetime race condition

2020-04-20 Thread Jason A. Donenfeld
On Mon, Apr 20, 2020 at 3:49 PM Chet Ramey wrote: > > On 4/20/20 5:01 PM, Jason A. Donenfeld wrote: > > On 4/20/20, Chet Ramey wrote: > >> On 4/20/20 1:15 AM, Jason A. Donenfeld wrote: > >>> Hi, > >>> > >>> I've uncovered a very unusual race condition when using process > >>> substitution and dev

Re: process substitution fd lifetime race condition

2020-04-20 Thread Chet Ramey
On 4/20/20 5:56 PM, Jason A. Donenfeld wrote: > On Mon, Apr 20, 2020 at 3:49 PM Chet Ramey wrote: >> >> On 4/20/20 5:01 PM, Jason A. Donenfeld wrote: >>> On 4/20/20, Chet Ramey wrote: On 4/20/20 1:15 AM, Jason A. Donenfeld wrote: > Hi, > > I've uncovered a very unusual race condi

Re: process substitution fd lifetime race condition

2020-04-20 Thread Jason A. Donenfeld
On Mon, Apr 20, 2020 at 3:58 PM Chet Ramey wrote: > OK, good. It was either that or closing the fd after reaping the child > process -- I couldn't tell 100% from the system call trace. The latter is an interesting possibility. I assume SIGCHLD comes in through a signal handler, so it's asynchrono

Re: process substitution fd lifetime race condition

2020-04-20 Thread Chet Ramey
On 4/20/20 6:02 PM, Jason A. Donenfeld wrote: > It seems like process substitution fifo lifetime is really tricky. You > can't really reference track, since the path is just a string that > could be manipulated. So how do you know when it's safe to clean up > that fd and that nobody is using it?

pasting in bracketed-paste mode breaks reverse-i-search

2020-04-20 Thread gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -pipe -march=native -Wno-trigraphs -fno-schedule-insns2 -fno-delete-null-pointer-checks -mtune=native -fomit-frame-pointer -O2 -D_FORTIFY_SOURCE=2 -DQT_FORCE_ASSERTS

Suggestions for improving Bash

2020-04-20 Thread Dale R. Worley
Is this the proper place to make suggestions for improving Bash? Dale

Re: process substitution fd lifetime race condition

2020-04-20 Thread Jason A. Donenfeld
Were you planning on committing this to Savannah?