Re: Tilde expansion in PATH in POSIX-Mode

2025-05-30 Thread Martin Schulte
Hello Lawrence! Am Fri, 30 May 2025 04:53:06 -0400 schrieb Lawrence Velázquez : > Your example commands demonstrate something else. The command > > PATH=~/foo:~/bar > > has always assigned a value like '/myhome/foo:/myhome/bar', POSIX > mode or not. This is broken in bash 5.1 POSIX mode

Tilde expansion in PATH in POSIX-Mode

2025-05-30 Thread Martin Schulte
Hello, https://www.gnu.org/software/bash/manual/bash.html#Bash-POSIX-Mode says: 19. Literal tildes that appear as the first character in elements of the PATH variable are not expanded as described above under Tilde Expansion. Is this no longer true from version 5.2 on? $ bash--posix -c

Re: ;exit in bash history causes bash to exit

2025-03-25 Thread Martin Schulte
Hello Ethan, I can't reproduce the problem: > Repeat-By: > Open a terminal with bash as the shell > Type `;exit` This results in bash: syntax error near unexpected token `;' but not in closing the shell. > Re-open the terminal, it will immediately close Is there maybe

Manual entry for !!:$

2025-01-17 Thread Martin Schulte
Hello, in 9.3.2 of https://www.gnu.org/software/bash/manual/bash.html we find: !!:$ designates the last argument of the preceding command. This may be shortened to !$. Shouldn't this be "the last word" instead of the "the last argument": $ echo hello > /dev/null $ echo !!:$ echo /dev/null /dev

Re: No filename expansion in shell-expand-line

2024-01-12 Thread Martin Schulte
Sorry, I falied to copy and paste R*, the last line is replaced by ls --color=auto echo {a..c} ~root xterm-256color 2024-01-12 42 /dev/fd/63 hello R* > Hello, > > from the documentation I understand that shell-expand-line (ESC CTRL-E) > should do alias expansion, history expansion, brace expan

No filename expansion in shell-expand-line

2024-01-12 Thread Martin Schulte
Hello, from the documentation I understand that shell-expand-line (ESC CTRL-E) should do alias expansion, history expansion, brace expansion, tilde expansion, shell parameter expansion, command substitution, arithmetic expansion, process substitution (if supported by the operation system), word

Re: inconsistent handling of closing brace inside no-fork command substitution

2024-01-03 Thread Martin Schulte
Hello Oğuz! > See: > > $ ${ case } in }) echo uname; esac } > Linux > $ ${ case }x in }x) echo uname; esac } > bash: command substitution: line 25: syntax error near unexpected token > `x' > bash: command substitution: line 25: `}x)' > $ ${ case }x in \}x) echo uname;

Some minor notes on manual chapter 4 "Shell Builtin Commands"

2023-10-08 Thread Martin Schulte
Hello, I took a closer look on the online manual chapter 4 "Shell Builtin Commands" and found some inconsistencies: - true and false seem to be missing (in 4.1 Bourne Shell Builtins). The following has been tested with bash 5.2.15: - 3.7.5 Exit Status says: "All builtins return an exit status

Possible problem with ${var%%[...]*}

2023-04-02 Thread Martin Schulte
Hello, in the following lines I consider dash's behaviour as correct an bash's as wrong: $ uname -a Linux martnix4 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux $ bash--version | head -n 1 GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu) $ bash-5.2.15 --

Re: Bash Reference Manual Type

2023-03-31 Thread Martin Schulte
Hi Chet! > >> Thanks for the report. The synopsis should read > >> > >> cd [-L|[-P [-e]]] [-@] [dir] > > ^ ^ > > But aren't these two brackets just superfluous? > > -L and -P are mutually exclusive, and -e is valid only when -P is > supplied. Yes, my feeling was just that | has s

Re: Bash Reference Manual Type

2023-03-31 Thread Martin Schulte
Hi Chet! > Thanks for the report. The synopsis should read > > cd [-L|[-P [-e]]] [-@] [dir] ^ ^ But aren't these two brackets just superfluous? Best regards, Martin

Re: bash login shell detection broken using default compile options

2023-03-16 Thread Martin Schulte
Hello Tycho! > the login shell detection (leading dash: -bash) is apparently broken - at > least, ~/.bashrc is not sourced. As far as I understand the manual ~/.bashrc is not sourced from a login-shell, see https://www.gnu.org/software/bash/manual/bash.html#Bash-Startup-Files At least in Debia

Re: Logical expressions and job control

2023-02-10 Thread Martin Schulte
Hi Godmar! > For instance: > > gback@lat2022:~$ sleep 10 && echo yes > ^Z > [1]+ Stopped sleep 10 > gback@lat2022:~$ fg > sleep 10 > gback@lat2022:~$ > > ... > > What's the rationale for bash's behavior in this case and is this something > that should be changed? I assume this

Re: Segmentation Fault in bash --posix

2023-01-20 Thread Martin Schulte
Hello Nicolas! > bash-5.1$ echo () { echo test } > > echo test > > } > bash-5.1$ echo You have defined a function echo that - calls itself with the first argument 'test' and the second argument '}' (!!!) - calls itself with the first and only argument test Try type -a echo and

Re: UBSAN error in lib/sh/random.c:79

2023-01-07 Thread Martin Schulte
Hello! Am Sat, 07 Jan 2023 19:08:06 +0100 schrieb Andreas Schwab : > On Jan 07 2023, Greg Wooledge wrote: > ... > I think the original overflow can only happen if the argument of > intrand32 is bigger than INT_MAX. Question might be if an overflow does any harm - or maybe even is intended... B

Re: reporting a bug

2022-12-15 Thread Martin Schulte
Hello! > function sa { > for y in $(seq $1 $e2); do > echo "echo search $y " > done > } I assume you should write $2 instead of $e2 in line 2. Best regards, Martin

Re: Parameter expansion with extended pattern make system hang

2022-09-06 Thread Martin Schulte
Hi! > > Here's another: > > > > printf -- '%s ' $(gcc --help) | sed 's/ $/\n/' > > > > Let just do the shell most of the work ;-) > > That's not safe. The unquoted substitution will undergo word splitting, > which we want, and also globbing, which we do *not* want. > > You should at least dis

Re: Parameter expansion with extended pattern make system hang

2022-09-06 Thread Martin Schulte
Hi! > Running with this assumption, now that we know bash's extglob matching > will not perform suitably for this task, we can look at other approaches. Here's another: printf -- '%s ' $(gcc --help) | sed 's/ $/\n/' Let just do the shell most of the work ;-) Best regards, Martin

Re: Gettings LINES and COLUMNS from stderr instead of /dev/tty

2022-07-18 Thread Martin Schulte
Hello Chet, on 2022-07-18 10:26:05 -0400 you wrote: > On 7/16/22 11:18 AM, Martin Schulte wrote: > > Hello, > > > > I'm just wondering that bash (reproduced with 5.2-rc1 under Debian 11) > > seems to determine LINES and COLUMNS from stderr. > > ... >

Re: Gettings LINES and COLUMNS from stderr instead of /dev/tty

2022-07-17 Thread Martin Schulte
Hello Dale! > Martin Schulte writes: > > I'm just wondering that bash (reproduced with 5.2-rc1 under Debian 11) > > seems to determine LINES and COLUMNS from stderr. > > It's not clear to me that the manual page says where the LINES and > COLUMNS values are ob

Gettings LINES and COLUMNS from stderr instead of /dev/tty

2022-07-16 Thread Martin Schulte
Hello, I'm just wondering that bash (reproduced with 5.2-rc1 under Debian 11) seems to determine LINES and COLUMNS from stderr. For example, this will lead to strange results when starting the script #!/bin/bash shopt -s checkwinsize trap 'echo $LINES $COLUMNS' SIGWINCH while true; do sleep 0.

Re: Feature request

2022-07-06 Thread Martin Schulte
Hello Brad! > It would be fantastic if there was a nicer way to source files from the > same folder instead of copy-pasting complicated logic in every script. I'm not sure if I understand your questions correctly, but did you try source "${0%/*}/file.ext" ? >- my sourceables also need logi

Re: BASH recursion segfault, FUNCNEST doesn't help

2022-06-01 Thread Martin Schulte
Hi Gergely! > I stumbled upon a recursion overflow crash in BASH. There are many ways to exhaust memory (and other) recources, recursion is one them. In your case a variable like SRCNEST (and all the code with its performance impacts needed behind it) might help, but what exactly is the advant

bash seems confused about it's state after unclosed single quotes in nested command substitution

2022-04-15 Thread Martin Schulte
Hello bash-bughunters, please consider the following interactive lines: $ echo $BASH_VERSION 5.1.4(1)-release $ uname -a Linux t1 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64 GNU/Linux $ echo $BASH_VERSION 5.1.4(1)-release $ sleep $(expr 60 - $(date +%s')) ; date bash: command su

Re: Bash regexp parsing would benefit from safe recursion limit

2022-03-30 Thread Martin Schulte
Hello Willi! > Fix: > Count the stack frames during recursive parsing and emit error before stack > resources are entirely consumed. What exactly should happen and what is the benefit of this solution? BTW: I tried trap 'echo "Ohohoh..."; exit 1;' SIGSEGV but the signal wasn't caught (which di

Re: forwarded weirdness report

2022-03-28 Thread Martin Schulte
Hello Greg, hello *! > And here's a workaround: > > unicorn:~$ bash --noprofile --norc -i -c $'alias x="echo hallo"; x' > bash: x: command not found > unicorn:~$ bash --noprofile --norc -i -c $'alias x="echo hallo"\nx' > hallo Really cool - thanks! > Put a literal newline in the -c argument, ra

Re: forwarded weirdness report

2022-03-28 Thread Martin Schulte
Hello, on Mon, 28 Mar 2022 20:34:40 +0200 Alex fxmbsw7 Ratchev wrote: > https://pastebin.com/raw/T7ZnFapt > > about inconsitency, about chets 'uh no bugs' > > ive experienced this and such x times already ( got better, this is not my > code ) Here's a somewhat stripped down version: $ bash -

Re: Interesting bug

2022-02-12 Thread Martin Schulte
Hi David! > A syntax error would be nice instead. I see - also from you second answer - that you have some fundamental misunderstandings about shell programming: - Your code will, in case the testCode fails, try execute a program called {echo. This is certainly not a good name for a program, b

Re: Interesting bug

2022-02-12 Thread Martin Schulte
Hello David! > I guess 99% of programmers would either expect "Finished" to be printed or > some syntax error. Well, 99% of shell programmers will (hopefully ;-) ) put a blank between "{" and "echo" in the line foo="$(testCode)" || {echo "foo";} Best regards Martin

Re: Option for read to handle incomplete last line

2021-10-24 Thread Martin Schulte
Hi Greg! > > Nevertheless, am I right that this solution relies on an undocumented > > feature? > > Which "undocumented" feature did you have in mind? Most things are > documented, somewhere. > > Are you thinking of -d '' signifying NUL as the delimiter? Chet told > us that he supports this "

Re: Option for read to handle incomplete last line

2021-10-24 Thread Martin Schulte
Hi Greg, hi *! > For bash scripts using this, I'd go a little bit fancier: > > read_line() { > if (($# == 0)) || [[ ${!#} = -* ]]; then > declare -n _rl_lastvar=REPLY > else > declare -n _rl_lastvar=${!#} > fi > read -r "$@" || test -n "$_rl_lastvar" > } Great, thanks - this solu

Option for read to handle incomplete last line

2021-10-24 Thread Martin Schulte
Hello, my apologies if there's a much easier solution for the following problem - in this case please let me know! >From time to time a run into troubles when reading a file with a while-read >loop where the last "line" is not terminated with a newline. I found an ugly looking solution (probab

Re: echo $'\0' >a does not write the nul byte

2021-01-17 Thread Martin Schulte
Hello Ilkka, hello *! > Bash's echo is a builtin, so using it doesn't involve an execve(). Sure – but while passing a string (however it will be encoded) containing a null byte to builtins would be possible in principle (as zsh shows) this would lead to a large bunch of problems, e.g. another i

Re: echo $'\0' >a does not write the nul byte

2021-01-17 Thread Martin Schulte
Hello Hans, hello Eduardo! > On Sun, Jan 17, 2021 at 12:05 PM wrote: > > (...) > > The nul byte is not echoed by $'\0'. > > This is expected. Bash uses NUL-byte terminated character sequences to > store strings, so it can't actually store NUL bytes themselves. To be exact, this is alrea

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Martin Schulte
Hello! Am Tue, 20 Oct 2020 00:58:36 -0700 schrieb L A Walsh : > There's got to be an easier way to do this, but not remembering or finding > it: > > First tried the obvious: > declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") > an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > T

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Martin Schulte
Hello! Am Tue, 20 Oct 2020 00:58:36 -0700 schrieb L A Walsh : > There's got to be an easier way to do this, but not remembering or finding > it: > > First tried the obvious: > declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") > an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > T

Re: Bad substitution breaks conditional statement

2020-10-13 Thread Martin Schulte
Hello Lawrence, hello *! > >> However, invalid parameter transformation operators are not considered > >> fatal errors, even in posix mode. Maybe they should be. > > > > Yes, please :-) > > > > Or no error at all. > > Why should invalid parameter transformation operators be treated > differentl

Re: Bad substitution breaks conditional statement

2020-10-13 Thread Martin Schulte
Hi Chet, hi all! > In general, variable expansion errors cause posix-mode shells to exit and > bash default mode shells to abort execution of the current command and > return to the top level, whether that is the command line or the next > command in the script. This aborts lists and other compoun

Bad substitution breaks conditional statement

2020-10-11 Thread Martin Schulte
Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-2bxm7h/bash-5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-sec$ uname output: Linux t1 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x

Re: echo builtin doesn't handle end-of-options flag

2020-08-16 Thread Martin Schulte
Hello Todd, Eric Cook wrote: > This is an intentional relic of the past, you really should use printf. See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html#tag_20_37_18 BTW/1: Because of this /bin/echo behaves the same way in most Linux distribution. BTW/2: echo -n -n$'

Re: Command substitution

2020-06-03 Thread Martin Schulte
Hello Felix! > Quoting is useless when assigning variable from ouptut of command or > another variable: Yes, I assume you are right. > Unfortunely, I don't retrieve this behaviour in man page. Me neither, maybe the manual should read If the substitution appears within double quotes *or as the

Re: Difference between EPOCHREALTIME and EPOCHSECONDS

2020-04-14 Thread Martin Schulte
Hello Chet, hello Felix, hello all! > > Bash Version: 5.0 > > Patch Level: 16 > > Release Status: release > > > > Description: > > Integer part of $EPOCHREALTIME could increase more than 8000 > > microseconds before $EPOCHSECONDS > > It's the difference between time() and gettimeofday().

First lines of examples/startup-files/bashrc

2020-04-08 Thread Martin Schulte
Hello bash developers, my apologies in advance if I'm overlooking something trivial but I'm really wondering about the first lines in examples/startup-files/bashrc (which are copied to Debian's skeleton ~/.bashrc): case $- in *i*);; *) return ;; esac Well, bash terminates sourcing the f

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

2019-12-19 Thread Martin Schulte
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: read -t0 is *broken* in bash. Don't use it. – No. It works as intended

Re: Two states of empty arrays

2019-12-12 Thread Martin Schulte
Hello Léa! Léa Gris wrote: > I was trying to play the the -v test to detect when an array or > associative array has been declared, not necessarily assigned entries > key, values, to not error when Bash runs with -o nounset Just for the curious: What is your attention here? I think that most us

Re: Backslash missing in brace expansion

2019-12-08 Thread Martin Schulte
Hello, thanks a lot for all the answers! I would like to suppose (Ilkka already argued in this direction) that in future versions of bash {x..C} should expand to x y z A B C. Best regards, Martin

Re: Backslash missing in brace expansion

2019-12-05 Thread Martin Schulte
Hi Chet, hi all! On Thu, 5 Dec 2019 12:01:31 -0800 Chet Ramey wrote: > On 12/5/19 11:11 AM, Martin Schulte wrote: > > Hello, > > > > please have a look: > > > > $ uname -a > > Linux martnix4 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u2 > > (2019-1

Backslash missing in brace expansion

2019-12-05 Thread Martin Schulte
Hello, please have a look: $ uname -a Linux martnix4 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u2 (2019-11-11) x86_64 GNU/Linux $ echo ${BASH_VERSINFO[@]} 4 4 12 1 release x86_64-pc-linux-gnu $ set -x $ echo {Z..a} + echo Z '[' '' ']' '^' _ '`' a Z [ ] ^ _ ` a It looks as if the backslash (bet

Output of jobs wrong

2019-09-21 Thread Martin Schulte
Hello, I'm not feeling well writing this mail because so far I've not been able to reproduce the behaviour I describe in the following... I was trying to understand the "[Patch] (tiny problem) bad short_doc for % command" thread when I entered more or less the following sequence of commands: $ h

Re: T/F var expansion?

2019-07-28 Thread Martin Schulte
Hello! > Is there a T/F var expansion that does: > > var=${tst:+$yes}${tst:-$no} > > but with yes/no in 1 expansion? At least if you are only working with numbers you can use ((var=(tst!=0?42:31))) But is this a question for bug-bash? Best regards, Martin

@Q breaks set -o nounset

2019-03-03 Thread Martin Schulte
Hello, with "GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)" I get the following behaviour: + bash -c 'set -o nounset; echo $x' bash: x: unbound variable + bash -c 'set -o nounset; echo ${x}' bash: x: unbound variable + bash -c 'set -o nounset; echo ${x@Q}' + bash -c 'set -o nounset;

Strange (wrong?) behaviour of "test ! -a file"

2018-10-21 Thread Martin Schulte
Hello, "help test" states that "-a file" and "-e file" do them same ("True if file exists.") This is not true when negating the result as you can see from the output below. The bash builtin even behaves different than the test from coreutils. It looks as if "! -a file" results in "( ! ) -a ( fil

Strange behaviour when sending SIGTERM to bash

2018-03-28 Thread Martin Schulte
Hello, I'm running bash under Debian Stretch: $ echo $BASH_VERSION 4.4.12(1)-release $ trap $ echo $$ 1100 $ kill 1100 $ => Looks fine for me Then I do a kill 1100 from another session and the bash above terminates. => Looks wrong for me Greetings, Martin