allow locale's decimal point as radix character when parsing fixed-point decimal into seconds and fractional seconds; handle case of shell script file descriptor being made non-blocking; fix smalkl memory leak in programmable completion of shell option names; fix for patsub_replacement behavior when BASH_COMPAT = 42 and the replacement string is quoted; fix for readine when changing show-mode-in-prompt variable

This commit is contained in:
Chet Ramey
2025-12-17 09:59:56 -05:00
parent f27bf94a79
commit 2cdb2f9b31
12 changed files with 241 additions and 38 deletions
+25
View File
@@ -823,4 +823,29 @@ two
&two
otwone
&twone
new-exp17.sub
unquoted word expansion with quoted pattern and replacement
4.2: 4.2, a < b
5.3: 4.2, a < b
5.3: 5.2, a < b
double-quoted word expansion with quoted pattern and replacement
4.2: 4.2, a '<' b
5.3: 4.2, a '<' b
5.3: 5.2, a < b
unquoted word expansion with unquoted pattern and replacement
4.2: 4.2, a < b
5.3: 4.2, a <lt; b
5.3: 5.2, a <lt; b
double-quoted word expansion with unquoted pattern and replacement
4.2: 4.2, a &lt; b
5.3: 4.2, a &lt; b
5.3: 5.2, a <lt; b
unquoted word expansion with backslash-quoted &
4.2: 4.2, a &lt; b
5.3: 4.2, a &lt; b
5.3: 5.2, a &lt; b
double-quoted word expansion with backslash-quoted &
4.2: 4.2, a \&lt; b
5.3: 4.2, a \&lt; b
5.3: 5.2, a &lt; b
./new-exp.tests: line 1: ABXD: parameter unset
+1
View File
@@ -668,6 +668,7 @@ test_runsub ./new-exp15.sub
# pattern substitution with `&' (quoted and unquoted) in the replacement string
test_runsub ./new-exp16.sub
test_runsub ./new-exp17.sub # test bash-4.2 compat
expect $0: 'ABXD: parameter unset'
${THIS_SH} -c 'recho ${ABXD:?"parameter unset"}' $0
+68
View File
@@ -0,0 +1,68 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# address issues with patsub_replacement, quoting `&', and BASH_COMPAT <= 42
# unquoted pattern substitutions with unquoted pattern and replacement strings
# will still perform matching and replacement even if BASH_COMPAT == 42
s="a < b"
echo unquoted word expansion with quoted pattern and replacement
echo '4.2: 4.2, a &lt; b'
for ver in 4.2 5.2; do
BASH_COMPAT=$ver # ignored for bash version less than 5.0
t=${s//'<'/'&lt;'}
echo "${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}: $BASH_COMPAT, $t"
done
echo double-quoted word expansion with quoted pattern and replacement
echo "4.2: 4.2, a '&lt;' b"
for ver in 4.2 5.2; do
BASH_COMPAT=$ver # ignored for bash version less than 5.0
t="${s//'<'/'&lt;'}"
echo "${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}: $BASH_COMPAT, $t"
done
echo unquoted word expansion with unquoted pattern and replacement
echo '4.2: 4.2, a &lt; b'
for ver in 4.2 5.2; do
BASH_COMPAT=$ver # ignored for bash version less than 5.0
t=${s//</&lt;}
echo "${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}: $BASH_COMPAT, $t"
done
# XXX - this is iffy but difficult to distinguish internally
echo double-quoted word expansion with unquoted pattern and replacement
echo '4.2: 4.2, a &lt; b'
for ver in 4.2 5.2; do
BASH_COMPAT=$ver # ignored for bash version less than 5.0
t="${s//</&lt;}"
echo "${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}: $BASH_COMPAT, $t"
done
echo unquoted word expansion with backslash-quoted '&'
echo '4.2: 4.2, a &lt; b'
for ver in 4.2 5.2; do
BASH_COMPAT=$ver # ignored for bash version less than 5.0
t=${s//</\&lt;}
echo "${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}: $BASH_COMPAT, $t"
done
echo double-quoted word expansion with backslash-quoted '&'
echo '4.2: 4.2, a \&lt; b'
for ver in 4.2 5.2; do
BASH_COMPAT=$ver # ignored for bash version less than 5.0
t="${s//</\&lt;}"
echo "${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}: $BASH_COMPAT, $t"
done