On 6/5/24 12:32 PM, Thomas Deutschmann wrote:
Hello!

I would like to report an issue with bash version >=5.2.

For years, I have had the following line in my ~/.bashrc:

export HISTTIMEFORMAT="[$(tput setaf 6)%F %T$(tput sgr0)]: " # colorful date

This worked perfectly up to and including bash version 5.1.0(16).

It still does.


However, since bash version 5.2.0(2), I have observed the following problem:

When I connect via SSH to a system with bash >=5.2.0 and execute "shorewall compile" directly (which generates a shell script in /var/lib/shorewall/firewall), the script becomes corrupted:

# /bin/sh /var/lib/shorewall/firewall help
/var/lib/shorewall/firewall: line 2239: syntax error near unexpected token `(' /var/lib/shorewall/firewall: line 2239: `    GCC_SPECS='export HISTTIMEFORMAT=$'[\E[36m%F %T\E(B\E[m]: '''

That really is a quoting error.

Recent versions of bash have modified the quoting style when displaying
variables in a form that can be reused as input. In previous versions,
a variable value that contained non-printable or other special characters
could have unwanted effects on the terminal just by being output by
`declare' or `export'.

Consider a simple example:

ZZZ=$'abc\rdef'
declare -p ZZZ

Running this on bash-5.1 and previous versions would output

def"are -- ZZZ="abc

Bash-5.2, on the other hand, outputs

declare -- ZZZ=$'abc\rdef'

If you extend this to terminal escape sequences that can do anything from
clear the screen and scrollback buffer to write to the terminal window
title bar, you see what prompted the change.

So your value of HISTTIMEFORMAT is displayed using different quoting in
bash-5.2.

I don't know what shorewall is doing internally, or why it chooses to
output a value for HISTTIMEFORMAT, but it seems pretty clear that it tries
to single-quote this variable value using a regular expression while
constructing a series of shell commands to run as part of the script and
fails. It probably just doesn't understand how to cope with the $'...'
quoting format.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to