Re: [sr #111211] `pipefail` leak/disablement

2025-03-24 Thread Emanuele Torre
On Mon, Mar 24, 2025 at 03:47:20AM -0400, anonymous wrote: > # Check if pipefail is set using 'shopt' > if (set -o | grep -q 'pipefail *on'); then > pipefail_on=1 > fi To check if an option is set you use [[ -o pipefail ]], not that thing. Also if you run local - in a fun

foo=bar baz=${|...;} cmd segfauls after running ...

2025-03-23 Thread Emanuele Torre
If you run a simple command that runs something (not just assignments) and contains an assignment word with ${|;} that is preceeded by at least one other assignment word, bash segfaults. Reproducible with a= b=${|:;} : $ gdb --args ./bash -c 'a= b=${|:;} :' Reading symbols from ./bash... (gdb)

[PATCH] Fix serialisation of read-write redirections

2025-02-14 Thread Emanuele Torre
The function serialisation code thinks that 1 is the default file descriptor for <> redirections, when it is actually 0. BEFORE $ a () { <> f ;}; declare -f a a () { 0<> f } $ a () { 1<> f ;}; declare -f a a () { <> f } AFTER $ a () { <> f ;}; d

Re: errno not restore before printing error in exec_builtin

2024-10-27 Thread Emanuele Torre
On Mon, Oct 28, 2024 at 12:47:53AM +0100, Emanuele Torre wrote: > } >else > -file_error (command); > +{ > + errno = opt; > + file_error (command); > +} > I just thought that perhaps this branch was supposed to print errors for the executa

errno not restore before printing error in exec_builtin

2024-10-27 Thread Emanuele Torre
In a branch of exec_builtin(), errno is not restored before printing an error message, and that causes "Success" to be printed. Example: $ # bash 5.2.37 $ cd /tmp $ echo "export env='\''$(echo {1..100500})'\''" > src $ . ./src $ exec -- "$BASH" bash: /bin/bash: Argument li

Re: Bash test builtin fails on: test -n '>' -a 1 -eq 1

2024-10-22 Thread Emanuele Torre
On Tue, Oct 22, 2024 at 03:34:43PM +0800, cirrus.mazurka...@icloud.com wrote: > The following produces a `bash: test: too many arguments` exception in > `test`, with exit status 2: > > ``` bash > v='>' > test -n "$v" -a yes '!=' no # bash: test: too many arguments > echo $? # 2 > > test -n '>' -

Re: Feature request: process title with exec -a "" for oneself

2024-09-05 Thread Emanuele Torre
On Fri, Sep 06, 2024 at 08:37:54AM +0800, Lockywolf wrote: > >I think this is appropriate for a loadable builtin. This one is Linux- > >specific. > > I am not experienced enough to have an opinion on whether a loadable > built-in is better than a feature of "exec". A loadable builtin is a builtin

Re: Feature request: process title with exec -a "" for oneself

2024-09-04 Thread Emanuele Torre
I think your idea of using exec -a '' with no positional arguments to set it is pretty cool, since exec -a changes the argv[0] of the invoked process and exec with redirections an no arguments applies redirections to the current shell permanently! Not super relevant, but I have a bash loadable

Re: Question on differences on quoted $* (Was: Re: Question on $@ vs $@$@)

2024-08-23 Thread Emanuele Torre
On Sat, Aug 24, 2024 at 02:15:48AM +0200, Steffen Nurpmeso wrote: > Sorry but i really have to come again, i do not understand what is > going on, and *i* think shell is at fault. No. It is working correctly. > > This: > > a() { > echo $#,1=$1,2=$2,"$*",$*, This $1 is unquoted, it will b

Re: [@]@A weird behaviour when IFS does not contain space

2024-07-10 Thread Emanuele Torre
On Wed, Jul 10, 2024 at 09:24:03AM -0400, Chet Ramey wrote: > On 7/4/24 2:51 AM, Emanuele Torre wrote: > > Hello. > > > > Normally, ${foo[@]@A} expands to multiple values, that are the arguments > > to run a declare command that sets foo to the current value/attributes

Re: 5.2.15(1)-release: RETURN trap not executed in cmd subst if last statement of fct is not builtin

2024-07-06 Thread Emanuele Torre
On Sat, Jul 06, 2024 at 01:41:01PM +0200, Jens Schmidt wrote: > Today I came across this one: > > [copy-on-select-2]$ echo $BASH_VERSION > 5.2.15(1)-release > [copy-on-select-2]$ foo() { trap 'echo foo' RETURN; /bin/echo bar; } > [copy-on-select-2]$ foo > bar > foo > [copy-on-select-

Re: Comments on bash 5.2's undocumented <((

2024-07-05 Thread Emanuele Torre
On Fri, Jul 05, 2024 at 10:38:59PM +0200, Emanuele Torre wrote: > Yes, clearly that is influencing this new behaviour, but this is new: > <(((

Re: Comments on bash 5.2's undocumented <((

2024-07-05 Thread Emanuele Torre
On Fri, Jul 05, 2024 at 04:10:55PM -0400, Dale R. Worley wrote: > Emanuele Torre writes: > > Bash 5.2 apparently added <(< file) that expand to the path to a fifo > > (openable only for read on BSD) to which the contents of file are > > written to, without document

Comments on bash 5.2's undocumented <((

2024-07-05 Thread Emanuele Torre
Bash 5.2 apparently added <(< file) that expand to the path to a fifo (openable only for read on BSD) to which the contents of file are written to, without documenting it. It also added >(< file) which is rather weird and fun; it expands to the path to a fifo (openable only for write on BSD),

Re: [@]@A weird behaviour when IFS does not contain space

2024-07-05 Thread Emanuele Torre
On Thu, Jul 04, 2024 at 09:08:21PM -0400, Dale R. Worley wrote: > Emanuele Torre writes: > > [...] > > Today, I have noticed that if IFS is set to a value that does not > > include space, [@]@A will expand to a single value > > [...] > > As an aside, [*]@A alwa

[@]@A weird behaviour when IFS does not contain space

2024-07-03 Thread Emanuele Torre
Hello. Normally, ${foo[@]@A} expands to multiple values, that are the arguments to run a declare command that sets foo to the current value/attributes. bash-5.2$ a=( abc xyz 123 ); declare -pa result=("${a[@]@A}") declare -a result=([0]="declare" [1]="-a" [2]="a=([0]=\"abc\" [1]=\"xyz\"

Incorrect documentation for compat43

2024-07-02 Thread Emanuele Torre
>From the bash man page: compat43 • the shell does not print a warning message if an attempt is made to use a quoted compound assignment as an argument to declare (e.g., declare -a foo='(1 2)'). Later versions warn that this usage is depreca

Re: function names starting with %

2024-06-25 Thread Emanuele Torre
On Mon, Jun 24, 2024 at 09:37:42PM +0300, Oğuz wrote: > 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:

Re: [bug #65651] argument reference inconsistency

2024-04-28 Thread Emanuele Torre
I don't know why this savannah ticket has been crossposted to @bug-bash, but its replies have not been crossposted here: it is very confusing. Anyway, they already got a response on savannah. o/ emanuele6

%lc/%ls print nothing in C locale if argument has bytes >7f

2024-03-08 Thread Emanuele Torre
Hello. I have noticed that, in C locale, %lc prints nothing if the first byte of the argument is non-ASCII (0x80-0xff). This is the only way %...c can ever output 0 bytes in bash, so it is probably unintenional. $ LC_ALL=C; { printf %lc%n è x; declare -p x >&2;} | od -An -to1 declare --

Re: declare -f does not output esac pattern correctly

2024-02-27 Thread Emanuele Torre
On Tue, Feb 27, 2024 at 12:23:41PM +0100, Emanuele Torre wrote: > On Tue, Feb 27, 2024 at 04:10:06PM +0700, Robert Elz wrote: > > Date:Tue, 27 Feb 2024 00:50:46 +0100 > > From: Emanuele Torre > > Message-ID: > > > > | To use esac

Re: declare -f does not output esac pattern correctly

2024-02-27 Thread Emanuele Torre
On Tue, Feb 27, 2024 at 04:10:06PM +0700, Robert Elz wrote: > Date:Tue, 27 Feb 2024 00:50:46 +0100 > From: Emanuele Torre > Message-ID: > > | To use esac as a pattern you need to use the (esac) syntax, > > Or quote it > > 'es

declare -f does not output esac pattern correctly

2024-02-26 Thread Emanuele Torre
Hello. I have noticed that declare -f does not output valid code when a pattern is `esac'. To use esac as a pattern you need to use the (esac) syntax, but declare -f does not use it, and ends up generating invalid code. a () { case $1 in hi) echo hi ;; (esac) echo esac ;;

Re: exec redirection is undone if fd (>9) has O_CLOEXEC

2024-02-23 Thread Emanuele Torre
On Sat, Feb 24, 2024 at 02:11:25PM +0900, Koichi Murase wrote: > I have a question. Maybe it's not technically a bug as fd > 9 is > involved, but the resulting behavior appears to be strange. I > received some reports from users in my project and tried to find out > what is happening. This is a

It is possible to remove the readonly attribute from {BASH, SHELL}OPTS

2024-01-24 Thread Emanuele Torre
I recently discovered that it is possible to set attributes on readonly variables $ declare -p PPID declare -ir PPID="759437" $ declare -l PPID $ declare -p PPID declare -irl PPID="759437" I noticed SHELLOPTS and BASHOPTS among the default readonly variables set by bash. They are modifi

nameref, varnames, evalstring can unload loadables while they are being run

2023-11-27 Thread Emanuele Torre
I have notices that funsubs can be used to unload loadable builtins while they are being run e.g. bash-5.3$ enable -f {examples/loadables/,}mktemp bash-5.3$ declare -n foo='q[${| enable -d mktemp;}0]' bash-5.3$ mktemp -v foo /tmp/shtmp.jKcUE0 Segmentation fault (core dumped) T

Re: Many of the example loadable builtins don't work anymore

2023-11-25 Thread Emanuele Torre
On Sat, Nov 25, 2023 at 01:20:55PM -0500, Chet Ramey wrote: > On 11/24/23 9:40 PM, Emanuele Torre wrote: > > Many of the loadable builtins that set variables in the > > examples/loadables directory don't work anymore because they still want > > to call legal_identifier i

Re: Many of the example loadable builtins don't work anymore

2023-11-25 Thread Emanuele Torre
On Sat, Nov 25, 2023 at 08:53:48AM +0100, Emanuele Torre wrote: > Now I can see that compat.o is actually being used to create > lib/sh/libsh.a, and that libsh.a contains the legal_ symbols > > [...] > > But the bash executable still does not contain the legal_ symbols: &g

Re: Many of the example loadable builtins don't work anymore

2023-11-24 Thread Emanuele Torre
On Sat, Nov 25, 2023 at 04:32:36AM +0100, Emanuele Torre wrote: > I've noticed that a lib/sh/compat.c file was added that still provides > the declaration for the legacy legal_ functions. > > The bash executable I was getting from building the devel branch did not > have

Re: Many of the example loadable builtins don't work anymore

2023-11-24 Thread Emanuele Torre
I've noticed that a lib/sh/compat.c file was added that still provides the declaration for the legacy legal_ functions. The bash executable I was getting from building the devel branch did not have those symbols though. The reason was that lib/sh/Makefile was not getting regenerated, so the recip

Many of the example loadable builtins don't work anymore

2023-11-24 Thread Emanuele Torre
Many of the loadable builtins that set variables in the examples/loadables directory don't work anymore because they still want to call legal_identifier instead of valid_identifier. $ ./bash -c 'enable -f {examples/loadables/,}mktemp; mktemp' /tmp/shtmp.h2HpWZ $ ./bash -c 'enable -f {e

Re: nullglob is documented incorrectly

2023-11-06 Thread Emanuele Torre
On Mon, Nov 06, 2023 at 08:56:11AM -0500, Chet Ramey wrote: > If nullglob is set, the non-matching pattern expands to the null string, > which is removed by word splitting. Well, I guess that is one way to look at it, but this explanation does not make much sense in my opinion since the results of

[PATCH] fdflags: fix -s with multiple flags, and multiple fd arguments

2023-11-05 Thread Emanuele Torre
fdflags -s was re-parsing the setspec for each fd argument. This is problematic because it is using strtok() to parse it destructively. So, only the first part of the setspec will be set for all file descriptors; the other parts will only be set for the first file descriptor: $ enable fdflags

nullglob is documented incorrectly

2023-11-05 Thread Emanuele Torre
Today, a user in the #bash IRC channel of libera.chat, misunderstood how nullglob is supposed to work because is documented incorrectly in the man page: 'nullglob' If set, Bash allows filename patterns which match no files to expand to a null string, rather than themselves.

Re: bash tries to parse comsub in quoted PE pattern

2023-10-21 Thread Emanuele Torre
On Thu, Oct 19, 2023 at 04:12:16PM -0400, Chet Ramey wrote: > On 10/18/23 1:08 PM, Emanuele Torre wrote: > > While we are at it, when examining this issue now, I have also noticed > > that, regardless of whether brace expansion is enabled or not, the bash > > parser always r

Re: bash tries to parse comsub in quoted PE pattern

2023-10-18 Thread Emanuele Torre
On Wed, Oct 18, 2023 at 11:24:11AM -0400, Chet Ramey wrote: > On 10/18/23 10:50 AM, Chet Ramey wrote: > > > > Is it really ok to break that behaviour? > > > > That's why, if you want the first problem repaired, you have to specify > > which word expansions are ok to parse and which are not. Shoul

Re: bash tries to parse comsub in quoted PE pattern

2023-10-18 Thread Emanuele Torre
On Wed, Oct 18, 2023 at 09:50:00AM -0400, Chet Ramey wrote: > On 10/17/23 5:55 PM, Emanuele Torre wrote: > > > braces.c > > > - brace_gobbler: use extract_dollar_brace_string if we see ${ with > > > the appropriate value of QUOTING, so we don't have to t

Re: bash tries to parse comsub in quoted PE pattern

2023-10-17 Thread Emanuele Torre
> braces.c > - brace_gobbler: use extract_dollar_brace_string if we see ${ with > the appropriate value of QUOTING, so we don't have to teach brace > expansion more shell syntax. > Report from Emanuele Torre > - brace_gobbler: call the wo

bash tries to parse comsub in quoted PE pattern

2023-10-13 Thread Emanuele Torre
In a PE pattern, if the pattern has a single quoted part that contains $( and does not contain a closing parenthesis, and has \' at the end, bash will try to parse a command substitution and fail. $ echo "${HOME#'$('\'}" bash: command substitution: line 3: unexpected EOF while looking

Parse error in bash 5.2+ with CHLD trap and 2 or more $() in a command

2023-09-05 Thread Emanuele Torre
If you have a CHLD trap set, and you run any command that has more than one command substitution, or an array subscript with more than one command substituion in an arithmetic context, or also in a prompt string, you will get parse errors. $ ./bash -c 'trap : CHLD; let "x[\$(exit 20)0]"' $ ./

Re: bug#65659: RFC: changing printf(1) behavior on %b

2023-08-31 Thread Emanuele Torre
On Thu, Aug 31, 2023 at 03:02:22PM -0500, Eric Blake wrote: > On Thu, Aug 31, 2023 at 03:10:58PM -0400, Chet Ramey wrote: > > Why not standardize another character, like %B? I suppose I'll have to look > > at the etherpad for the discussion. I think that came up on the mailing > > list, but I can't

Re: !; is interpreted as an history expansion that can never match anything

2023-08-08 Thread Emanuele Torre
On Tue, Aug 08, 2023 at 03:35:10PM -0400, Chet Ramey wrote: > Anyway, there's a good reason to add ";&|" to the set of characters that > inhibit history expansion if they follow the history expansion character. Thank you! Please also "()<>" if possible. o/ emanuele6

Re: ! history expansion occurs within arithmetic substitutions

2023-08-08 Thread Emanuele Torre
On Tue, Aug 08, 2023 at 09:24:48AM -0400, Zachary Santer wrote: > Configuration Information: > Machine: x86_64 > OS: msys > Compiler: gcc > Compilation CFLAGS: -march=nocona -msahf -mtune=generic -O2 -pipe > -D_STATIC_BUILD > uname output: MSYS_NT-10.0-19045 Zack2021HPPavilion 3.4.7.x86_64 2023-07-

!; is interpreted as an history expansion that can never match anything

2023-08-07 Thread Emanuele Torre
! followed by a ; or another terminator is interpreted as an history expansion with no pattern that can never match anything. $ !; echo hi bash: !: event not found $ !&& echo hi bash: !: event not found It should not be intepreted as a history expansion that cannot possibly match anythin

Re: +=() can be used to set illegal indices

2023-07-03 Thread Emanuele Torre
On Mon, Jul 03, 2023 at 05:24:49PM -0400, Chet Ramey wrote: > It's really more like > > a=(); a[0]=1 a[1]=2 a[2]=3 > > and the += variant omits the initial array flush. Oh, yes. I knew it, but I forgot to mention it. > > I would have expected: > > > >$ a=([1]=hi [100]=foo [-1002]=bar boo [

Re: +=() can be used to set illegal indices

2023-06-30 Thread Emanuele Torre
On Fri, Jun 30, 2023 at 12:16:46PM -0400, Chet Ramey wrote: > > What I would have expected was something like this: > > > >$ x=([9223372036854775805]=foo) > >$ x+=( {1..5} ); echo "this won't run" > >bash: some "invalid assignment" error > >$ declare -p x # no value gets appended s

Re: [PATCH] sleep builtin signal handling

2023-06-30 Thread Emanuele Torre
On Fri, Jun 30, 2023 at 08:53:16AM +0200, Phi Debian wrote: > Well > > ┌─none:/home/phi > └─PW$ type sleep > sleep is hashed (/usr/bin/sleep) > > So sleep is not a builtin here. This patch is for the sleep loadable builtin example distributed with bash. You can activate it using enable -f "$(

Re: $((expr)) allows the hexadecimal constant "0x"

2023-06-29 Thread Emanuele Torre
On Fri, Jun 30, 2023 at 03:28:36AM +1000, Martin D Kealey wrote: > On Thu, 29 Jun 2023 at 19:45, Denys Vlasenko wrote: > > > IIRC bash used to allow numeric constants of the > > BASE#DIGITS form even if the DIGITS part was empty. > > IOW: not only "64#0", but "64#" too was accepted > > as a valid

Re: +=() can be used to set illegal indices

2023-06-29 Thread Emanuele Torre
The fix in the most recent push did not fix the issue: $ x=([9223372036854775805]=foo) $ x+=( {1..5} ) $ echo "${x[@]}" 3 4 5 foo 1 2 It behaves exactly the same way: no error is printed, some elements are prepended instead of appended, and there are invalid indices in the output of decl

+=() can be used to set illegal indices

2023-06-27 Thread Emanuele Torre
If an indexed array has no available slots after its last index, +=() will overflow the last index, and set into an illegal negative index, effectively prepending values instead of appending them. $ x=([9223372036854775807]=hello) $ x+=( and hi ) $ echo "${x[@]}" and hi hello $ x+=(

Re: inaccurate documentation for [[:ascii:]]

2023-05-30 Thread Emanuele Torre
On Tue, May 30, 2023 at 02:42:46PM +0200, alex xmb ratchev wrote: > does graph mean printable Sort of. [[:print:]] matches all the printable characters https://en.wikipedia.org/wiki/ASCII#Printable_characters [[:graph:]] matches all the characters that are printable, but not whitespace. In POS

inaccurate documentation for [[:ascii:]]

2023-05-30 Thread Emanuele Torre
The documentation for glob character classes is innacurate: > Within [ and ], character classes can be specified using the syntax > [:class:], where class is one of the following classes defined in the > POSIX standard: > alnum alpha ascii blank cntrl digit graph lower print punct space > upper

Re: Error message: cannot find _struct in shared object

2023-05-27 Thread Emanuele Torre
On Sat, May 27, 2023 at 09:39:18AM -0700, Wiley Young wrote: > Description: > > A syntax error on a variable assignment lead to $x being unset when `enable > -n "$x" was executed, which produced this error message: > ./test.sh: line 22: enable: cannot find _struct in shared object : > /usr/bin/b

enable builtin bugs in bash 5.2

2023-05-27 Thread Emanuele Torre
Since bash 5.2, enable mkdir is equivalent to enable -f mkdir mkdir. But, if you use the -n flag, and mkdir is not a loaded builtin, it will also be equivalent to enable -f mkdir mkdir (so the -n flag is ignored), and the newly loaded foo will be enabled instead of disabled: $ ./bash -c 'c

"environment:" instead of $0 in front of fatal errors from functions

2023-05-22 Thread Emanuele Torre
Error messages for fatal error e.g. ${x?foo} or rovar=foo or $x expanded with nounset, report an error message prefixed by the string "environment:" instead of "scriptname:" (or "$0:"). $ bash -c '${x?hi}' asd asd: line 1: x: hi $ bash -c 'a () { ${x?hi} ;}; a' asd environment: lin

Re: setarray[unsetkey] doesn't trigger nounset in arithmetic context

2023-05-21 Thread Emanuele Torre
On Mon, May 22, 2023 at 09:27:17AM +1000, Martin D Kealey wrote: > I just realised I expressed an opinion about associative arrays while the > original post was about indexed arrays. > I simply reported that, specifically in arithmetic contexts, when using a variable (not as the lhs of an = assig

setarray[unsetkey] doesn't trigger nounset in arithmetic context

2023-05-20 Thread Emanuele Torre
This was already reported 12 and a half years ago, but there have not been many replies: https://lists.gnu.org/archive/html/bug-bash/2010-12/msg00128.html The issue seems to be caused by expr_streval() only checking for unbound identifiers at this line: https://git.savannah.gnu.org/cgit/bash

Re: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-11 Thread Emanuele Torre
On Thu, May 11, 2023 at 10:54:36AM +, Baumann, Moritz wrote: > Sorry for bothering you again, but I might have misremembered: I looked > through the manual again and could not find any mention of this behavior > in any of the following sections: > > * Arrays > * Bash Conditional Expressions

Re: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Emanuele Torre
On Wed, May 10, 2023 at 05:44:54PM +, Baumann, Moritz wrote: > In the case that lead me to submit this report, the error even occurred > inside a check for the existence of an array key, which made the resulting > message even weirder: > > if [[ -v "mistyped_array[$1]" ]]; then > ... > fi ⚠

Re: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Emanuele Torre
On Wed, May 10, 2023 at 05:25:35PM +0200, Emanuele Torre wrote: > On Wed, May 10, 2023 at 02:07:46PM +, Baumann, Moritz wrote: > > Description: > > When the nounset option is set, and you try to access a key of an > > associative array that does not exi

Re: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Emanuele Torre
On Wed, May 10, 2023 at 02:07:46PM +, Baumann, Moritz wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-musl > Compiler: gcc > Compilation CFLAGS: -Os -Wformat -Werror=format-security > -Werror=int-conversion -DSYS_BASHRC='/etc/bash/bash

Re: eval '`' reports error but $? is still 0

2023-05-10 Thread Emanuele Torre
On Wed, May 10, 2023 at 09:05:20PM +0800, Clark Wang wrote: > See the following example (with 5.2.15): > > bash-5.2$ PS1='$? >> ' > 0 >> eval '`' > bash: unexpected EOF while looking for matching ``' > 0 >><-- press ENTER > 2 >><-- now $? is 2 > > > It looks like the failed eval

Re: Alpine: strscpy.c:25:1: error: unknown type name 'ssize_t'; did you mean 'size_t'?

2023-05-03 Thread Emanuele Torre
On Wed, May 03, 2023 at 04:56:16PM -0700, Tianon Gravi wrote: > I'm getting the following error when building the latest "devel" > (23935dbe8513437e69ca14d6b0890067dddceba3) on Alpine Linux 3.17: Techincally ssize_t is not part of standard C, and, according to POSIX, it should be defined in tha

[PATCH] add missing null check in duplicate_buffered_stream()

2023-05-03 Thread Emanuele Torre
This was causing crashes when non-interactive shells that read stdin, either source a file that dups stdin, or run an eval command that dups stdin: $ bash <<< 'echo hi 9<&0' hi $ printf %s\\n 'echo hi 9<&0' > file; bash <<< '. ./file' Segmentation fault (core dumped) $ bash <<< 'eval "ec

[PATCH] FIGNORE: ignore results that are exactly equal to a suffix

2023-04-16 Thread Emanuele Torre
FIGNORE makes bash only ignore filename completion results that end with one of the specified suffixes and are not exactly equal to the suffix. So, for example, FIGNORE=xyz will ignore `abcxyz', and `xyzxyz', but not `xyz'. >From the documentation it is not clear that FIGNORE should work this

"dt" doesn't work correctly in vi mode

2023-04-04 Thread Emanuele Torre
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 uname output: Linux t420 6.1.21-1-lts #1 SMP PREEMPT_DYNAMIC Wed, 22 Mar 2023 14:30:48 + x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version:

Re: Failed $(

2023-04-03 Thread Emanuele Torre
On Mon, Apr 03, 2023 at 10:30:29AM -0400, Chet Ramey wrote: > On 3/31/23 10:20 PM, Zev Weiss wrote: > > > Bash Version: 5.2 > > Patch Level: !PATCHLEVEL! > > Release Status: release > > > > Description: > > > > When 'set -e' is enabled, file-content substitutions of the form $(<...) > > cause an

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Emanuele Torre
On Thu, Mar 30, 2023 at 11:35:08AM -0600, Felipe Contreras wrote: > > How can you say that the current implementation that bash, dash, etc. > > use is not compliant to the POSIX specification? > > I have never said that. The title of this thread is "IFS field splitting doesn't conform with POSIX"

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Emanuele Torre
On Thu, Mar 30, 2023 at 07:51:59AM -0600, Felipe Contreras wrote: > But you can't replicate 'a,b' that way, because b does not have a > terminator. Obviously we'll want 'b' as a field, therefore one has to > assume either 1) the end of the string is considered an implicit > terminator, or 2) the te

[PATCH] add definition for count_all_jobs() in parse.y if --disable-job-control

2023-03-26 Thread Emanuele Torre
--- parse.y | 1 + 1 file changed, 1 insertion(+) diff --git a/parse.y b/parse.y index 639912b6..65c1d88a 100644 --- a/parse.y +++ b/parse.y @@ -73,6 +73,7 @@ # include "jobs.h" #else extern int cleanup_dead_jobs (void); +extern int count_all_jobs (void); #endif /* JOB_CONTROL */ #if defi

Re: [PATCH] asort: some bug fixes

2023-03-25 Thread Emanuele Torre
On Sun, Mar 26, 2023 at 08:19:25AM +0200, Emanuele Torre wrote: > -sa = xmalloc(n * sizeof(sort_element)); > +if (n) > + sa = xmalloc (n * sizeof(sort_element)); > i = 0; > for ( j = 0; j < hash->nbuckets; ++j ) { >

[PATCH] asort: some bug fixes

2023-03-25 Thread Emanuele Torre
- add some missing free() - avoid calling xmalloc(0) - fix f () { local b; asort -i b a ;} not updating b if b is declared but doesn't have a value using builtin_find_indexed_array() instead of find_or_make_array_variable(): bash-5.2$ typeset a=(z y x) b c=1; asort -i b a; asort -i c a

[PATCH] use bind_lastarg to restore $_ when executing variable

2023-02-07 Thread Emanuele Torre
Before this patch, if allexport was set, $_ gained the "x" attribute after PROMPT_COMMAND finished running, that would only get removed after the next simple command is executed. $ PROMPT_COMMAND=: $ : foo $ declare -p _ declare -- _="foo" $ set -a $ : bar $ declare -p _ declare -x

Re: [PATCH] local_builtin: do not overwrite previously saved options with local -

2023-02-06 Thread Emanuele Torre
On Mon, Feb 06, 2023 at 10:18:30AM -0500, Dale R. Worley wrote: > The behavior of bash appears to be is "future changes in shell options > using the 'set' builtin inside the current function invocation are > restored to their prior values when the function returns". Perhaps, the wording of the doc

[PATCH] local_builtin: do not overwrite previously saved options with local -

2023-02-06 Thread Emanuele Torre
Before this patch, running local - a second time in the same scope would overwrite the previously saved options: a () { local -; set -C; echo "2: $-"; local -; set -u; echo "3: $-" ;} echo "1: $-" # 1: himBHs a # 2: himBCHs # 3: himuBCHs echo "4: $-" # 4

Re: BASH_XTRACEFD=1 read variable stdout flushing?

2023-01-16 Thread Emanuele Torre
aph after moving the suggestion of using exec {BASH_XTRACEFD}<&1 to the bottom. emanuele6 On 16/01/2023, Emanuele Torre wrote: > On Mon, Jan 16, 2023 at 11:36:18AM -0600, dave.dram...@gmail.com wrote: >> Description: >> >> I have `set -x` and `BASH_XTRACEFD=1` set in

Re: BASH_XTRACEFD=1 read variable stdout flushing?

2023-01-16 Thread Emanuele Torre
On Mon, Jan 16, 2023 at 11:36:18AM -0600, dave.dram...@gmail.com wrote: > Description: > > I have `set -x` and `BASH_XTRACEFD=1` set in a simple script that I > have in > a cron job. I'd like to see the progress of the script when run > manually, > hence `set -x`, but I want th

Re: printf %n is not documented

2023-01-07 Thread Emanuele Torre
On Sat, Jan 07, 2023 at 03:00:58PM +0100, felix wrote: >strU8DiffLen0() { local _cLen=${#1} LC_ALL=C;return $((${#1}-_cLen));} Do not use `return' like that. `return' is used to make functions report an exit status: 0 for success, non-zero for various kinds of failure, just like executable pr

unset does not remove functions like a[b] unless -f is specified

2023-01-04 Thread Emanuele Torre
The unset builtin, when invoked without an option, should first try to unset the variable (or array element) specified by its arguments, and then fall back to trying to remove the function definition for the function that has the name specified by the argument if it exists. bash-5.1$ declare -

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Emanuele Torre
On Thu, Dec 29, 2022 at 05:35:48PM +, Alain D D Williams wrote: > On Thu, Dec 29, 2022 at 06:23:09PM +0100, Steffen Nurpmeso wrote: > > Hello. > > > > Name: bash > > Path: /usr/ports/core > > Version: 5.2.15 > > Release: 1 > > > > $ i=10 j=20;echo $(( i +=

Re: printf %n is not documented

2022-12-23 Thread Emanuele Torre
On Fri, Dec 23, 2022 at 06:53:08PM -0500, Chet Ramey wrote: > On 12/23/22 7:24 AM, Emanuele Torre wrote: > > About two months ago, I discovered, reading the bash source code for > > printf, the %n format specifier. > > > > What it does is assign to the variable spe

printf %n is not documented

2022-12-23 Thread Emanuele Torre
About two months ago, I discovered, reading the bash source code for printf, the %n format specifier. What it does is assign to the variable specified as its argument, the number of bytes that have been written so far (similarly to the C counterpart). This can be quite useful if you, for example,

documentation for ${@: -1} is unclear

2022-12-20 Thread Emanuele Torre
The bash manual says: If parameter is ‘@’ or ‘*’, the result is length positional parameters beginning at offset. A negative offset is taken relative to one greater than the greatest positional parameter, so an offset of -1 evaluates to the last positional parameter. It is an expansion error i

Re: Segfault with set -o emacs in -c

2022-12-18 Thread Emanuele Torre
On Sun, Dec 18, 2022 at 06:35:45AM +, Harald van Dijk wrote: > The assumption here, that if (interactive), input is coming from > stdin, does not hold when running bash -ic. > > Repeat-By: > bash -ic 'set -o emacs' Wow, this is a very old bug. I think this 2.04 bug report fr

Re: bash crashes if TERM is unset and the Delete key is pressed twice

2022-12-14 Thread Emanuele Torre
On Wed, Dec 14, 2022 at 02:30:04PM -0500, Chet Ramey wrote: > Try this. > > *** ../bash-20221202/lib/readline/readline.c 2022-12-06 09:48:50.0 > -0500 > --- lib/readline/readline.c 2022-12-14 14:20:32.0 -0500 > *** > *** 591,595 > (*rl_redisplay_function

Re: bash crashes if TERM is unset and the Delete key is pressed twice

2022-12-14 Thread Emanuele Torre
On Wed, Dec 14, 2022 at 12:31:39PM -0500, Chet Ramey wrote: > On 12/13/22 9:00 AM, Emanuele Torre wrote: > > This happens since 88d69b4fa224d93ef1d26b80229668397bb6496b . > > > > If bash is started with the TERM variable unset or empty, it will > > segfault and crash

bash crashes if TERM is unset and the Delete key is pressed twice

2022-12-13 Thread Emanuele Torre
This happens since 88d69b4fa224d93ef1d26b80229668397bb6496b . If bash is started with the TERM variable unset or empty, it will segfault and crash if you press the Delete key twice (it only happens for the first prompt, and if you don't press anything before the two Delete key presses). I was abl

Re: curiosity: 'typeset -xr' vs. 'export -r'

2022-12-13 Thread Emanuele Torre
On Tue, Dec 13, 2022 at 03:07:16AM -0500, Lawrence Velázquez wrote: > Of course not. I only meant to demonstrate that "export" always > creates global variables, so a function that utilizes "declare -gx" > actually behaves more like "export" then your alias does. This is a little inaccurate. `ex

`declare -f "a="' fails unnecessarily

2022-12-03 Thread Emanuele Torre
`declare -f "something="' fails with the following error: $ declare -f 'a=x' bash: declare: cannot use `-f' to make functions $ f=a=x $ decalre -f -- "$f" bash: declare: cannot use `-f' to make functions That error is not very useful. Bash makes `declare -f' fail with that err

`declare -f' does not output the "function" keyword when required

2022-12-03 Thread Emanuele Torre
In Bash, it is possible to define functions that look like assignment words using the function keyword: function a=2 { printf hi\\n ;} When `declare -f' is used to output all the function definitions, bash will not output that function definition with the "function" keyword, generating invali

Re: `time ( someCmd )` Doesn't Print Time Under 5.2

2022-11-21 Thread Emanuele Torre
On Mon, Nov 21, 2022 at 07:07:08PM -0500, d...@dabe.com wrote: > emanuele6 suspects it has to do with > https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00107.html No, actually later, I said that it has probably been introduced earlier since I tried running 'time (sleep 1)' in a versi

Re: local/typeset/declare -p - outputs invalid declare -- -

2022-11-16 Thread Emanuele Torre
On Wed, Nov 16, 2022 at 02:05:56PM -0500, Chet Ramey wrote: > It doesn't matter. `local -' is the only way to save and restore the > options; `declare -p -' and `typeset -p -' should have no special meaning. The `declare -p'/`typeset -p' commands and the `local -p' command are different commands.

Re: local/typeset/declare -p - outputs invalid declare -- -

2022-11-16 Thread Emanuele Torre
The 31f4d468b60eb27d768ef56d0a8b4982346465d9 commit on the devel branch, addressed this issue, but only partially: bash-5.1$ ./bash --version |& head -n 1 GNU bash, version 5.2.9(6)-maint (x86_64-pc-linux-gnu) bash-5.1$ ./bash -c 'a () { local -; local -p; declare -p -; typeset -p -;

local/typeset/declare -p - outputs invalid declare -- -

2022-10-31 Thread Emanuele Torre
Since bash 5.2, local/typeset/declare -p without argument no longer outputs "declare -- -" when local - is used. But local/typeset/declare -p - still outputs "declare -- -" instead of "local -". bash-5.1$ a () { local -; local -p; declare -p -; typeset -p -; local -p - ;} bash-5.1$

Re: wait inside subshell waits for sibling

2022-10-24 Thread Emanuele Torre
On 24/10/2022, Robert Elz wrote: > | The problem that was described is caused by that > | optimisation (not the version that is applied to simple commands that > | run external program, but to subshell compound command as mentioned). > > I understand that. > > | In case you did not underst

Re: wait inside subshell waits for sibling

2022-10-24 Thread Emanuele Torre
On 24/10/2022, Robert Elz wrote: > It need not make a difference. The wait command is not intended to > be just the wait(2) (or wait(3) whichever it is on the system in > question) system call (or wrapper around another system call). I don't see how this is relevant. > There's no reason that w

Re: wait inside subshell waits for sibling

2022-10-23 Thread Emanuele Torre
I don't think the process running `cat' is a sibling of the subshell. bash performs an optimisation that runs redirections applied to simple commands that run external programs, or subshell compound commands after the fork(). (to avoid having to restore file descriptors after running the command.)

Re: [PATCH] fix build with --disable-array-vars

2022-09-30 Thread Emanuele Torre
oops, sorry. ignore this email. On 30/09/2022, Emanuele Torre wrote: > --- > execute_cmd.c | 9 - > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/execute_cmd.c b/execute_cmd.c > index d0d1dd31..4d0fdcf7 100644 > --- a/execute_cmd.c > +++ b/ex

[PATCH] fix build with --disable-array-vars

2022-09-30 Thread Emanuele Torre
--- execute_cmd.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/execute_cmd.c b/execute_cmd.c index d0d1dd31..4d0fdcf7 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -3901,7 +3901,10 @@ execute_cond_node (cond) } else if (cond->type == COND_UNARY) { -

PEs in arithmetic context array subscript cause SEGFAULT (was: (( arr[${var@Q}] )) makes the shell crash in bash-5.2)

2022-09-30 Thread Emanuele Torre
On 30/09/2022, Emanuele Torre wrote: > In bash-5.2, using the ${parameter@Q} parameter expansion with an unset > parameter, in an array subscript, in an arithmetic context, causes a > segmentation fault. Actually, using any parameter expansion with an unset parameter in an array subscri

  1   2   >