fix issue with failed history expansion changing the history list offset; fix some tests to avoid problems with error messages that differ between systems; fix issue with readline rl_abort not clearing any pending command to execute

This commit is contained in:
Chet Ramey
2024-12-30 10:45:14 -05:00
parent bb56d620e0
commit 5114e17172
18 changed files with 172 additions and 117 deletions
+37 -18
View File
@@ -12,54 +12,72 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
: ${TMPDIR:=/tmp}
TMPF=$TMPDIR/printf-oflow-$RANDOM
printf_overflow ()
{
local r;
line=$1 ; shift
rm -f "$TMPF"
printf "$@" 2>$TMPF
r=$?
if [ ! -s "$TMPF" ]; then
echo "printf7.sub: $line: expected overflow error output to stderr" >&2
fi
rm -f "$TMPF"
return $r
}
# tests of integer overflow for field width and precision arguments
INT_MAX=$(getconf INT_MAX 2>/dev/null)
[ -z "$INT_MAX" ] && INT_MAX=2147483647 # assume 32 bits
TOOBIG=$(( $INT_MAX * 10 ))
TOOBIG=${INT_MAX}0 # effectively multiply by 10
printf '[%*s]\n' "${TOOBIG}"
printf '[%*s]\n' "${TOOBIG}" X
printf_overflow $LINENO '[%*s]\n' "${TOOBIG}"
printf_overflow $LINENO '[%*s]\n' "${TOOBIG}" X
printf -v VAR '[%*s]' "${TOOBIG}"
printf_overflow $LINENO -v VAR '[%*s]' "${TOOBIG}"
echo VAR="$VAR"
unset -v VAR
printf -v VAR '[%*s]' "${TOOBIG}" X
printf_overflow $LINENO -v VAR '[%*s]' "${TOOBIG}" X
echo VAR="$VAR"
unset -v VAR
TOOBIG=9223372036854775825
printf '[%*s]\n' "${TOOBIG}"
printf '[%*s]\n' "${TOOBIG}" X
printf_overflow $LINENO '[%*s]\n' "${TOOBIG}"
printf_overflow $LINENO '[%*s]\n' "${TOOBIG}" X
printf -v VAR '[%*s]' "${TOOBIG}"
printf_overflow $LINENO -v VAR '[%*s]' "${TOOBIG}"
echo VAR="$VAR"
unset -v VAR
printf -v VAR '[%*s]' "${TOOBIG}" X
printf_overflow $LINENO -v VAR '[%*s]' "${TOOBIG}" X
echo VAR="$VAR"
unset -v VAR
TOOBIG=$(( $INT_MAX * 10 ))
printf '[%.*s]\n' "${TOOBIG}"
printf '[%.*s]\n' "${TOOBIG}" X
printf_overflow $LINENO '[%.*s]\n' "${TOOBIG}"
printf_overflow $LINENO '[%.*s]\n' "${TOOBIG}" X
printf -v VAR '[%.*s]' "${TOOBIG}"
printf_overflow $LINENO -v VAR '[%.*s]' "${TOOBIG}"
echo VAR="$VAR"
unset -v VAR
printf -v VAR '[%.*s]' "${TOOBIG}" X
printf_overflow $LINENO -v VAR '[%.*s]' "${TOOBIG}" X
echo VAR="$VAR"
unset -v VAR
TOOBIG=9223372036854775825
printf '[%.*s]\n' "${TOOBIG}"
printf '[%.*s]\n' "${TOOBIG}" X
printf_overflow $LINENO '[%.*s]\n' "${TOOBIG}"
printf_overflow $LINENO '[%.*s]\n' "${TOOBIG}" X
printf -v VAR '[%.*s]' "${TOOBIG}"
printf_overflow $LINENO -v VAR '[%.*s]' "${TOOBIG}"
echo VAR="$VAR"
unset -v VAR
printf -v VAR '[%.*s]' "${TOOBIG}" X
printf_overflow $LINENO -v VAR '[%.*s]' "${TOOBIG}" X
echo VAR="$VAR"
unset -v VAR
@@ -69,4 +87,5 @@ unset -v VAR
#printf "%.${TOOBIG}s\n" XY
printf -v VAR "%.${TOOBIG}s\n" XY
echo $VAR
printf "%.${TOOBIG}Q\n" XY
unset -v VAR
printf_overflow $LINENO "%.${TOOBIG}Q\n" XY