mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-02 01:40:49 +02:00
minor updates to several tests
This commit is contained in:
@@ -860,6 +860,7 @@ examples/functions/notify.bash f
|
||||
#examples/functions/repeat3 f
|
||||
examples/functions/seq f
|
||||
examples/functions/seq2 f
|
||||
examples/functions/setalrm f
|
||||
examples/functions/shcat f
|
||||
examples/functions/shcat2 f
|
||||
examples/functions/sort-pos-params f
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
# setalrm - set a timer to fire in N seconds and send SIGALRM to the shell
|
||||
#
|
||||
# usage: setalrm [-c] N
|
||||
#
|
||||
# -c means to reset the trap on ALRM if the timer is canceled
|
||||
#
|
||||
# If N = 0, we cancel any pending alarm by killing the background timeout
|
||||
# process. Any value greater than 0 sets a timeout for N seconds. Values
|
||||
# of N less than zero are errors.
|
||||
|
||||
declare -i alrmpid=
|
||||
|
||||
setalrm()
|
||||
{
|
||||
local untrap=
|
||||
local setalrm_usage="setalrm: usage: setalrm [-c] N"
|
||||
|
||||
while getopts c opt; do
|
||||
case $opt in
|
||||
c) untrap=1 ;;
|
||||
*) echo "$setalrm_usage" >&2 ; return 2;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "$setalrm_usage" >&2
|
||||
return 2
|
||||
fi
|
||||
|
||||
if (( $1 < 0 )); then
|
||||
echo "setalrm: timeout must be greater than zero" >& 2
|
||||
return 2
|
||||
fi
|
||||
|
||||
if [[ $1 -eq 0 ]] && [[ -n "$alrmpid" ]]; then
|
||||
kill -TERM $alrmpid ; es=$?
|
||||
alrmpid=
|
||||
if [ -n "$untrap" ]; then
|
||||
trap - ALRM # caller saves if desired
|
||||
fi
|
||||
return $es
|
||||
fi
|
||||
|
||||
# setting alarm
|
||||
{ trap - ALRM ; sleep $1; kill -ALRM $$; } &
|
||||
alrmpid=$!
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ do
|
||||
esac
|
||||
|
||||
# save to the history list
|
||||
history -s "$EQN"
|
||||
history -s -- "$EQN"
|
||||
|
||||
# run it through bc
|
||||
calc "$EQN"
|
||||
|
||||
@@ -378,8 +378,8 @@ static WORD_LIST *expand_declaration_argument (WORD_LIST *, WORD_LIST *);
|
||||
static WORD_LIST *shell_expand_word_list (WORD_LIST *, int);
|
||||
static WORD_LIST *expand_word_list_internal (WORD_LIST *, int);
|
||||
|
||||
static void posix_variable_assignment_error (int);
|
||||
static void bash_variable_assignment_error (int);
|
||||
static inline void posix_variable_assignment_error (int);
|
||||
static inline void bash_variable_assignment_error (int);
|
||||
|
||||
static int do_assignment_statements (WORD_LIST *, char *, int);
|
||||
|
||||
@@ -11147,6 +11147,34 @@ expand_array_subscript (const char *string, size_t *sindex, int quoted, int flag
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Handle a variable assignment error in default mode. */
|
||||
static inline void
|
||||
bash_variable_assignment_error (int force_exit)
|
||||
{
|
||||
if (interactive_shell == 0 && force_exit)
|
||||
exp_jump_to_top_level (FORCE_EOF);
|
||||
else if (interactive_shell == 0)
|
||||
exp_jump_to_top_level (DISCARD); /* XXX - maybe change later */
|
||||
else
|
||||
exp_jump_to_top_level (DISCARD);
|
||||
}
|
||||
|
||||
/* Handle a variable assignment error in posix mode. */
|
||||
static inline void
|
||||
posix_variable_assignment_error (int force_exit)
|
||||
{
|
||||
#if defined (STRICT_POSIX)
|
||||
if (posixly_correct && interactive_shell == 0)
|
||||
#else
|
||||
if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0)
|
||||
#endif
|
||||
exp_jump_to_top_level (FORCE_EOF);
|
||||
else if (force_exit)
|
||||
exp_jump_to_top_level (FORCE_EOF);
|
||||
else
|
||||
exp_jump_to_top_level (DISCARD);
|
||||
}
|
||||
|
||||
void
|
||||
invalidate_cached_quoted_dollar_at (void)
|
||||
{
|
||||
@@ -13083,34 +13111,6 @@ shell_expand_word_list (WORD_LIST *tlist, int eflags)
|
||||
return (new_list);
|
||||
}
|
||||
|
||||
/* Handle a variable assignment error in default mode. */
|
||||
static inline void
|
||||
bash_variable_assignment_error (int force_exit)
|
||||
{
|
||||
if (interactive_shell == 0 && force_exit)
|
||||
exp_jump_to_top_level (FORCE_EOF);
|
||||
else if (interactive_shell == 0)
|
||||
exp_jump_to_top_level (DISCARD); /* XXX - maybe change later */
|
||||
else
|
||||
exp_jump_to_top_level (DISCARD);
|
||||
}
|
||||
|
||||
/* Handle a variable assignment error in posix mode. */
|
||||
static inline void
|
||||
posix_variable_assignment_error (int force_exit)
|
||||
{
|
||||
#if defined (STRICT_POSIX)
|
||||
if (posixly_correct && interactive_shell == 0)
|
||||
#else
|
||||
if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0)
|
||||
#endif
|
||||
exp_jump_to_top_level (FORCE_EOF);
|
||||
else if (force_exit)
|
||||
exp_jump_to_top_level (FORCE_EOF);
|
||||
else
|
||||
exp_jump_to_top_level (DISCARD);
|
||||
}
|
||||
|
||||
/* Perform assignment statements optionally preceding a command name COMMAND.
|
||||
If COMMAND == NULL, is_nullcmd usually == 1. Follow the POSIX rules for
|
||||
variable assignment errors. */
|
||||
|
||||
+24
-24
@@ -368,38 +368,38 @@ hello --
|
||||
0000000 340 262 207 040 040 040 055 055 055 012
|
||||
000000a
|
||||
[][]
|
||||
./printf7.sub: line 19: printf: 21474836470: Result too large
|
||||
[]
|
||||
./printf7.sub: line 20: printf: 21474836470: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 22: printf: 21474836470: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 25: printf: 21474836470: Result too large
|
||||
VAR=[X]
|
||||
./printf7.sub: line 31: printf: 9223372036854775825: Result too large
|
||||
[]
|
||||
./printf7.sub: line 21: printf: 21474836470: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 23: printf: 21474836470: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 26: printf: 21474836470: Result too large
|
||||
VAR=[X]
|
||||
./printf7.sub: line 32: printf: 9223372036854775825: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 34: printf: 9223372036854775825: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 37: printf: 9223372036854775825: Result too large
|
||||
VAR=[X]
|
||||
./printf7.sub: line 43: printf: 21474836470: Result too large
|
||||
[]
|
||||
./printf7.sub: line 33: printf: 9223372036854775825: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 35: printf: 9223372036854775825: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 38: printf: 9223372036854775825: Result too large
|
||||
VAR=[X]
|
||||
./printf7.sub: line 44: printf: 21474836470: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 46: printf: 21474836470: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 49: printf: 21474836470: Result too large
|
||||
VAR=[X]
|
||||
./printf7.sub: line 55: printf: 9223372036854775825: Result too large
|
||||
[]
|
||||
./printf7.sub: line 56: printf: 9223372036854775825: Result too large
|
||||
./printf7.sub: line 45: printf: 21474836470: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 58: printf: 9223372036854775825: Result too large
|
||||
./printf7.sub: line 47: printf: 21474836470: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 61: printf: 9223372036854775825: Result too large
|
||||
./printf7.sub: line 50: printf: 21474836470: Result too large
|
||||
VAR=[X]
|
||||
./printf7.sub: line 56: printf: 9223372036854775825: Result too large
|
||||
[]
|
||||
./printf7.sub: line 57: printf: 9223372036854775825: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 59: printf: 9223372036854775825: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 62: printf: 9223372036854775825: Result too large
|
||||
VAR=[X]
|
||||
XY
|
||||
./printf7.sub: line 71: printf: 9223372036854775825: Result too large
|
||||
./printf7.sub: line 72: printf: 9223372036854775825: Result too large
|
||||
XY
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@
|
||||
#
|
||||
|
||||
# tests of integer overflow for field width and precision arguments
|
||||
INT_MAX=$(getconf INT_MAX)
|
||||
INT_MAX=$(getconf INT_MAX 2>/dev/null)
|
||||
[ -z "$INT_MAX" ] && INT_MAX=2147483647 # assume 32 bits
|
||||
TOOBIG=$(( $INT_MAX * 10 ))
|
||||
|
||||
printf '[%*s]\n' "${TOOBIG}"
|
||||
|
||||
+16
-5
@@ -19,6 +19,12 @@ unset LC_ALL
|
||||
ErrorCnt=0
|
||||
TestCnt=0
|
||||
|
||||
localewarn()
|
||||
{
|
||||
echo "unicode1.sub: warning: you do not have the $1 locale installed;" >&2
|
||||
echo "unicode1.sub: that will cause some of these tests to be skipped." >&2
|
||||
}
|
||||
|
||||
function TestCodePage {
|
||||
local TargetCharset="${1:?Missing Test charset}"
|
||||
local EChar RChar Uval x
|
||||
@@ -95,8 +101,8 @@ fr_FR_ISO_8859_1=(
|
||||
if locale -a | grep -i '^fr_FR\.ISO8859.*1$' >/dev/null ; then
|
||||
TestCodePage fr_FR.ISO8859-1 fr_FR_ISO_8859_1
|
||||
else
|
||||
echo "unicode1.sub: warning: you do not have the fr_FR.ISO8859-1 locale installed;" >&2
|
||||
echo "unicode1.sub: that will cause some of these tests to be skipped." >&2
|
||||
localewarn fr_FR.ISO8859-1
|
||||
|
||||
fi
|
||||
|
||||
zh_TW_BIG5=(
|
||||
@@ -110,7 +116,13 @@ zh_TW_BIG5=(
|
||||
# can't use these any more; macos 14 (sonoma) broke libiconv
|
||||
# [0x00fb]='\u00FB' [0x00fc]='\u00FC' [0x00fd]='\u00FD' [0x00fe]='\u00FE'
|
||||
)
|
||||
TestCodePage zh_TW.BIG5 zh_TW_BIG5
|
||||
|
||||
# this locale causes problems all over the place
|
||||
if locale -a | grep -i '^zh_TW\.big5' >/dev/null ; then
|
||||
TestCodePage zh_TW.BIG5 zh_TW_BIG5
|
||||
else
|
||||
localewarn zh_TW.BIG5
|
||||
fi
|
||||
|
||||
jp_JP_SHIFT_JIS=(
|
||||
[0x0001]=$'\x01' # START OF HEADING
|
||||
@@ -309,8 +321,7 @@ jp_JP_SHIFT_JIS=(
|
||||
if locale -a | grep -i '^ja_JP.SJIS' >/dev/null ; then
|
||||
TestCodePage ja_JP.SJIS jp_JP_SHIFT_JIS
|
||||
else
|
||||
echo "unicode1.sub: warning: you do not have the ja_JP.SJIS locale installed;" >&2
|
||||
echo "unicode1.sub: that will cause some of these tests to be skipped." >&2
|
||||
localewarn ja_JP.SJIS
|
||||
fi
|
||||
|
||||
#for ((x=1;x<1000;x++)); do printf -v u '\\U%08x' "$x"; printf ' [0x%04x]=%-11q' "$x" "${u@E}"; [ $(($x%5)) = 0 ] && echo; done
|
||||
|
||||
Reference in New Issue
Block a user