Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14755
| From | Rob Foehl <rwf@loonybin.net> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Control characters in declare output |
| Date | 2018-11-01 02:01 -0400 |
| Message-ID | <mailman.3201.1541052090.1284.bug-bash@gnu.org> (permalink) |
Prompted (pun intended) by the recent thread on detecting missing newlines
in command output, I'd had another look at my own version, and discovered
a potential issue with control characters being written as-is in declare
output. Minimal (harmless) reproducer:
╶➤ x () { echo $'\e[31m'"oops"$'\e[0m'; }
╶➤ declare -f x
x ()
{
echo ''"oops"''
}
Emits the string in red in a terminal. Any instances with control
sequences that do anything more invasive with the terminal cause more
trouble.
Similarly:
╶➤ y=$'\e[31m'"oops"$'\e[0m'
╶➤ declare -p y
declare -- y="oops"
String again in red. Compare with:
╶➤ set |grep ^y=
y=$'\E[31moops\E[0m'
No issues with the set output. As they can both be usefully re-read by
the shell, is there any possibility for similarly escaped output from the
declare builtin, instead of raw control characters?
-Rob
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Control characters in declare output Rob Foehl <rwf@loonybin.net> - 2018-11-01 02:01 -0400
csiph-web