Path: csiph.com!4.us.feeder.erje.net!feeder.erje.net!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: L A Walsh Newsgroups: gnu.bash.bug Subject: Re: Control characters in declare output Date: Tue, 13 Nov 2018 16:54:28 -0800 Lines: 44 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: usenet.stanford.edu 1542156880 24169 208.118.235.17 (14 Nov 2018 00:54:40 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: Rob Foehl Envelope-to: bug-bash@gnu.org User-Agent: Thunderbird In-Reply-To: X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id wAE0sSDU003851 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 173.164.175.65 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14816 On 10/31/2018 11:01 PM, Rob Foehl wrote: > Prompted (pun intended) by the recent thread on detecting missing newli= nes=20 > in command output, I'd had another look at my own version, and discover= ed=20 > a potential issue with control characters being written as-is in declar= e=20 > output. Minimal (harmless) reproducer: > > =E2=95=B6=E2=9E=A4 x () { echo $'\e[31m'"oops"$'\e[0m'; } > > =E2=95=B6=E2=9E=A4 declare -f x > x () > { > echo ''"oops"'' > } > > Emits the string in red in a terminal. Any instances with control=20 > sequences that do anything more invasive with the terminal cause more=20 > =20 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=3D"$_CBLD$_CRED" _prompt=3D"#" _prompt_close=3D"$_CRST" } ---- That way I can display the file on a screen without the control=20 characters actually changing the color of the terminal. (just in case you might be looking for a way around that behavior).