mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-13 23:20:49 +02:00
small change to brace expansion to inhibit some error messages; changes to printf builtin for precision and field widths
This commit is contained in:
@@ -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/>.
|
||||
#
|
||||
|
||||
# tests of integer overflow for field width and precision arguments
|
||||
INT_MAX=$(getconf INT_MAX)
|
||||
TOOBIG=$(( $INT_MAX * 10 ))
|
||||
|
||||
printf '[%*s]\n' "${TOOBIG}"
|
||||
printf '[%*s]\n' "${TOOBIG}" X
|
||||
|
||||
printf -v VAR '[%*s]' "${TOOBIG}"
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
printf -v VAR '[%*s]' "${TOOBIG}" X
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
|
||||
TOOBIG=9223372036854775825
|
||||
|
||||
printf '[%*s]\n' "${TOOBIG}"
|
||||
printf '[%*s]\n' "${TOOBIG}" X
|
||||
|
||||
printf -v VAR '[%*s]' "${TOOBIG}"
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
printf -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 -v VAR '[%.*s]' "${TOOBIG}"
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
printf -v VAR '[%.*s]' "${TOOBIG}" X
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
|
||||
TOOBIG=9223372036854775825
|
||||
|
||||
printf '[%.*s]\n' "${TOOBIG}"
|
||||
printf '[%.*s]\n' "${TOOBIG}" X
|
||||
|
||||
printf -v VAR '[%.*s]' "${TOOBIG}"
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
printf -v VAR '[%.*s]' "${TOOBIG}" X
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
|
||||
# out of range inline precisions
|
||||
|
||||
printf "%.${TOOBIG}s\n" XY
|
||||
printf "%.${TOOBIG}Q\n" XY
|
||||
Reference in New Issue
Block a user