bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bash completion mangles file names with newlines


From: Ian! D. Allen
Subject: bash completion mangles file names with newlines
Date: Wed, 23 Feb 2022 11:34:52 -0500

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 <TAB>'one
        two
        three
        four
        five
        six'
        bash-5.0$ touch foo
        bash-5.0$ xxx <TAB>
        foo                               one^Jtwo^Jthree^Jfour^Jfive^Jsix
        bash-5.0$ xxx <TAB>'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 <TAB>
        five   foo    four   one    six    three  two
        bash-5.0$ xxx o<TAB>
        five   four   one    six    three  two

        # The last two completions are garbage.
        # The file name is being split on newlines.

-- 
| Ian! D. Allen, BA-Psych, MMath-CompSci  idallen@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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]