wait on procsub in EXIT trap

2023-03-19 Thread Grisha Levit
If an EXIT trap is executed after receipt of a terminating signal, waiting on a process substitution within the trap can fail: $ (trap 'wait $!; echo $?' EXIT; : <(:); kill 0) -bash: wait: pid 83694 is not a child of this shell 127 Interestingly, if an external command or a subshell is executed a

[PATCH] Save more readline state when running compgen

2023-03-19 Thread Grisha Levit
Completion state is not fully restored after invoking `compgen' within a competition function. Normally, if a compspec does not specifically include one of the options that triggers filename completion, the generated completions are not treated as filenames: $ complete -W '/tmp /var' cmd $ cmd /[

parsing command substitution inside parameter expansion in interactive shell

2023-03-19 Thread Grisha Levit
If a command substitution inside a parameter expansion has a command followed by a newline, bash prints an error message (though the command is parsed and saved in the history list correctly): bash --norc -in <<<$'${_+$(:\n)}\n!!' $ ${_+$(: bash: command substitution: line 3: unexpected EOF while

history file missing timestamp when HISTFILESIZE reached

2023-03-19 Thread Grisha Levit
When HISTTIMEFORMAT is set and history file truncation is performed, the first line of the history file (i.e. the timestamp of the first entry) seems to always be missing > /tmp/hist HISTTIMEFORMAT= HISTFILESIZE=3 HISTFILE=/tmp/hist bash --norc -in <<<$'1\n2\n3' $ cat /tmp/hist 1 #1679274410 2 #1

compgen respecting dotglob changes

2023-03-19 Thread Grisha Levit
compgen's glob matching does not respect dotglob being turned on or off unless some other globbing takes place between the setting being changed and compgen being called: $ cd "$(mktemp -d)" $ > .x $ bash -c 'shopt -s dotglob; compgen -G \*' $ bash -c 'shopt -s dotglob; : *; compgen -G \*' .x