Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14816 > unrolled thread
| Started by | L A Walsh <bash@tlinx.org> |
|---|---|
| First post | 2018-11-13 16:54 -0800 |
| Last post | 2018-11-13 16:54 -0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Control characters in declare output L A Walsh <bash@tlinx.org> - 2018-11-13 16:54 -0800
| From | L A Walsh <bash@tlinx.org> |
|---|---|
| Date | 2018-11-13 16:54 -0800 |
| Subject | Re: Control characters in declare output |
| Message-ID | <mailman.4008.1542156880.1284.bug-bash@gnu.org> |
On 10/31/2018 11:01 PM, Rob Foehl wrote:
> 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
>
BTW, to keep that red from turning your terminal red, I used:
read _CRST <<<"$(tput sgr0)" #Reset
read _CRED <<<"$(tput setaf 1)" #RED
read _CGREEN <<<"$(tput setaf 2)" #GREEN
read _CBLD <<<"$(tput bold)" #Bold
And in usage:
[[ $UID -eq 0 ]] && {
_prompt_open="$_CBLD$_CRED"
_prompt="#"
_prompt_close="$_CRST"
}
----
That way I can display the file on a screen without the control
characters
actually changing the color of the terminal.
(just in case you might be looking for a way around that behavior).
Back to top | Article view | gnu.bash.bug
csiph-web