bash completion mangles file names with newlines
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-a6qmCk/bash-5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security uname output: Linux ubuntu20-04 5.13.0-30-generic #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 5.0 Patch Level: 17 Release Status: release Description: BASH completion cannot correctly handle file names containing newline characters. Repeat-By: # First, get a shell with no completion loaded and show it working: $ bash --norc bash-5.0$ ls -b one\ntwo\nthree\nfour\nfive\nsix bash-5.0$ xxx 'one two three four five six' bash-5.0$ touch foo bash-5.0$ xxx foo one^Jtwo^Jthree^Jfour^Jfive^Jsix bash-5.0$ xxx 'one two three four five six' # Now, load the completion scripts and watch it break: bash-5.0$ source /usr/share/bash-completion/bash_completion bash-5.0$ ls -b foo one\ntwo\nthree\nfour\nfive\nsix bash-5.0$ xxx five foofour onesixthree two bash-5.0$ xxx o five four onesixthree two # The last two completions are garbage. # The file name is being split on newlines. -- | Ian! D. Allen, BA-Psych, MMath-CompSci idal...@idallen.ca Ottawa CANADA | Home: www.idallen.com Contact Improvisation Dance: www.contactimprov.ca | Former college professor of Free/Libre GNU+Linux @ teaching.idallen.com | Improve democracy www.fairvote.ca and defend digital freedom www.eff.org
Re: bash completion mangles file names with newlines
On Wed, Feb 23, 2022 at 03:37:12PM -0500, Chet Ramey wrote: > As others have noted, bash-completion is a separate package. > But we might be able to figure out where it's not being appropriately > quoted if you enable `set -x' before attempting the completion. At > least that would give you a backtrace to send with your bug report. Aye, I put the same bug report into the bash-completion GitHub and the backtrace is there: https://github.com/scop/bash-completion/issues/704 -- | Ian! D. Allen, BA-Psych, MMath-CompSci idal...@idallen.ca Ottawa CANADA | Home: www.idallen.com Contact Improvisation Dance: www.contactimprov.ca | Former college professor of Free/Libre GNU+Linux @ teaching.idallen.com | Improve democracy www.fairvote.ca and defend digital freedom www.eff.org
Re: set -o notify spurious CR when jobs redirected to file
On Fri, Nov 14, 2014 at 10:30:12AM -0500, Chet Ramey wrote: > Yes, it's intended. Piotr identified the code that does this. If the > shell is currently interactive, it can't be sure under what circumstances > it's printing a job notification. If the shell is printing the job notification because a user has typed "jobs" at the command line, there is no uncertainty on the part of the user that the resulting output does not need the extra CR. Perhaps the shell code isn't written to recognize that the request comes from a "jobs" command, but there is no uncertainty from the perspective of the user typing "jobs". Output generated directly as a result of typing "jobs" does not need the extra CR. Now, I can imagine implementations of "jobs" that might make it hard to communicate this case to the job notify code, but that would be a shortcoming in the recognition of the circumstances, not a lack of clarity in what the circumstances are. In short, it's still a bug. One might mitigate the bug by refusing to add the CR if output is not a TTY. That would refrain from creating what look like DOS-format files. -- | Ian! D. Allen - idal...@idallen.ca - Ottawa, Ontario, Canada | Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/ | College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/ | Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/