bug-bash
[Top][All Lists]
Advanced

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

compgen -W doesn't split wordlist containing single quotes


From: marcelpaulo
Subject: compgen -W doesn't split wordlist containing single quotes
Date: Fri, 16 Mar 2018 14:00:14 -0300

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -Wdate-time 
-D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-IrsGKQ/bash-4.4=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall -no-pie 
-Wno-parentheses -Wno-format-security
uname output: Linux monk 4.13.0-37-generic #42-Ubuntu SMP Wed Mar 7 14:13:23 
UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: release

Description:
compgen -W "wordlist" doesn't split wordlist on $IFS if wordlist contains
unquoted single quotes. For instance, this wordlist, "foo'bar aaa bbb", won't
be split using the default value of IFS: it will be treated as a single word.

Repeat-By:
Using "foo'bar foo bar" as the wordlist, this is the result of completing on f, 
a and b:

paulo@monk:~/tmp$ compgen -W "foo'bar aaa bbb" -- a
paulo@monk:~/tmp$ compgen -W "foo'bar aaa bbb" -- b
paulo@monk:~/tmp$ compgen -W "foo'bar aaa bbb" -- f
foobar aaa bbb

As you can see, compgen removed the unquoted single quote and treated
"foobar aaa bbb" as a single word.

It works correctly if the single quote is itself quoted. Our test wordlist
would then be: "foo\'bar aaa bbb"

paulo@monk:~/tmp$ compgen -W "foo\'bar aaa bbb" -- a
aaa
paulo@monk:~/tmp$ compgen -W "foo\'bar aaa bbb" -- b
bbb
paulo@monk:~/tmp$ compgen -W "foo\'bar aaa bbb" -- f
foo'bar



reply via email to

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