--rcfile and non existing files

2024-06-24 Thread Gioele Barabucci
Hi, the manpage states: When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. […] The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc an

Re: printf, binary data, leading single quote and non ASCII codesets

2024-06-24 Thread Chet Ramey
On 6/24/24 7:36 AM, Gioele Barabucci wrote: Hi, bash manpage says for printf contains the following statement: if the leading character is a single or double quote, the value is the ASCII value of the following character. Thanks for the report. The man page should have been updated when I ch

Re: 'declare -i var=var' for var initially declared in calling scope

2024-06-24 Thread Chet Ramey
On 6/17/24 10:38 PM, Zachary Santer wrote: Bash Version: 5.2 Patch Level: 26 Release Status: release Description: It just occurred to me that I could take advantage of arithmetic evaluation being performed when a variable with the -i integer attribute is assigned a value to create a visual dis

use-after-free in set -o vi mode

2024-06-24 Thread rtm
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall uname output: Linux blob 6.5.0-35-ge

function names starting with %

2024-06-24 Thread Oğuz
You can do these $ %f(){ :;} $ declare -f %f %f () { : } $ unset -f %f $ declare -f %f $ echo $? 1 but not call them $ %f bash: fg: %f: no such job $ '%f' bash: fg: %f: no such job $ \%f bash: fg: %f: no such job Why is that? Would it be a bad idea to let such functions take precedence over

Re: readarray leaves a NULL char embedded in each element

2024-06-24 Thread Greg Wooledge
On Mon, Jun 24, 2024 at 20:01:45 +0200, Davide Brini wrote: > $ ./printarg "${X[0]}A" > 65 32 65 0 83 > > That is, "A", a space, and "A" again (which is the result of the quoted > expansion), 0 for the string terminator, and a random 83 which is > whatever follows in memory (strangely, it seems to

Re: readarray leaves a NULL char embedded in each element

2024-06-24 Thread Davide Brini
On Mon, 24 Jun 2024 20:01:45 +0200, Davide Brini wrote: > On Mon, 24 Jun 2024 10:50:15 -0600, Rob Gardner > wrote: > > and a random 83 which is whatever follows in memory (strangely, it seems > to be 83 consistently though). Some more investigation shows that the "S" is the beginning of "SHELL=

Re: readarray leaves a NULL char embedded in each element

2024-06-24 Thread Greg Wooledge
On Mon, Jun 24, 2024 at 10:50:15 -0600, Rob Gardner wrote: > Description: > When using space or newline as a delimiter with readarray -d, > > elements in the array have the delimiter replaced with NULL, > > which is left embedded in each element of the array. This isn't p

Re: readarray leaves a NULL char embedded in each element

2024-06-24 Thread Davide Brini
On Mon, 24 Jun 2024 10:50:15 -0600, Rob Gardner wrote: [reformatted] > $ readarray -d ' ' X <<< "A B C" This does not remove the separator, so X[0] ends up containing "A ", X[1] contains "B ", and X[2] contains "C\n" (as there was no trailing space to terminate the string). See: $ declare -p X

readarray leaves a NULL char embedded in each element

2024-06-24 Thread Rob Gardner
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall uname output: Linux maggid 6.5.0-35-ge

Proposal for a New Bash Option: failfast for Immediate Pipeline Failure

2024-06-24 Thread ama bamo
Dear Bash Maintainers, I have encountered a challenge with the current implementation of pipelines in Bash, specifically regarding subshells and the pipefail option. As documented, each command in a pipeline is executed in its own subshell, and Bash waits for all commands in the pipeline to termin

Re: printf, binary data, leading single quote and non ASCII codesets

2024-06-24 Thread alex xmb sw ratchev
termux : printf "$b" | { while LC_ALL=C read -N1 c; do LC_ALL=C.UTF-8 printf "%d %q\n" "'$c" "$c"; done; } 255 ÿ 190 $'\276' On Mon, Jun 24, 2024, 1:37 PM Gioele Barabucci wrote: > Hi, > > bash manpage says for printf contains the following statement: > > > if the leading character is a si

Re: printf, binary data, leading single quote and non ASCII codesets

2024-06-24 Thread Oğuz
On Mon, Jun 24, 2024 at 2:37 PM Gioele Barabucci wrote: > $ printf -v b "\xc3\xbf\xbe" > > $ printf "$b" | { while LC_ALL=C read -N1 c; do \ > LC_ALL=C.UTF-8 printf "%d %q\n" "'$c" "$c"; done; } > 195 $'\303' > 255 $'\277' > 190 $'\276' Can't reproduce this on Ubuntu 22.04 with Bash 5.3-alph

printf, binary data, leading single quote and non ASCII codesets

2024-06-24 Thread Gioele Barabucci
Hi, bash manpage says for printf contains the following statement: if the leading character is a single or double quote, the value is the ASCII value of the following character. POSIX uses a different wording: If the leading character is a single-quote or double-quote, the value shall be th