mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-02 00:13:40 +02:00
changes to quoting for some globbing characters; regularize error behavior of builtins that take numeric arguments and complain about too many arguments
This commit is contained in:
@@ -467,7 +467,7 @@ unlimited
|
||||
./builtins11.sub: line 27: ulimit: +1999: invalid number
|
||||
0
|
||||
0
|
||||
./builtins11.sub: line 37: ulimit: -q: invalid option
|
||||
./builtins11.sub: line 37: ulimit: -g: invalid option
|
||||
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPRT] [limit]
|
||||
./builtins11.sub: line 39: ulimit: max user processes: cannot modify limit: Operation not permitted
|
||||
/tmp /bin
|
||||
@@ -490,3 +490,4 @@ popd: usage: popd [-n] [+N | -N]
|
||||
/tmp /
|
||||
/
|
||||
./builtins.tests: line 322: exit: status: numeric argument required
|
||||
after non-numeric arg to exit: 2
|
||||
|
||||
@@ -318,7 +318,6 @@ shift 0 # succeeds silently
|
||||
options=$(set -o -B 2>&1 | wc -l)
|
||||
[[ $options -gt 3 ]] || echo 'set: bad -o option name parsing'
|
||||
|
||||
# this must be last -- it is a fatal error
|
||||
# this no longer must be last -- it is no longer a fatal error
|
||||
exit status
|
||||
|
||||
echo after bad exit
|
||||
echo after non-numeric arg to exit: $?
|
||||
|
||||
@@ -34,7 +34,7 @@ ulimit -c
|
||||
ulimit -a >/dev/null # just make sure we have no errors
|
||||
|
||||
# these are errors
|
||||
ulimit -q
|
||||
ulimit -g
|
||||
# have to see about this one
|
||||
ulimit -u $(( 2**31 - 1 ))
|
||||
|
||||
|
||||
+40
-1
@@ -269,6 +269,45 @@ DEBUG
|
||||
./errors9.sub: line 8: ((: -- : arithmetic syntax error: operand expected (error token is "- ")
|
||||
DEBUG
|
||||
./errors9.sub: line 10: ((: -- : arithmetic syntax error: operand expected (error token is "- ")
|
||||
invalid numeric argument
|
||||
bash: line 1: exit: abcde: numeric argument required
|
||||
after exit: 2
|
||||
bash: line 1: break: abcde: numeric argument required
|
||||
bash: line 1: continue: abcde: numeric argument required
|
||||
bash: line 1: shift: abcde: numeric argument required
|
||||
after shift: 2
|
||||
bash: line 1: return: abcde: numeric argument required
|
||||
after return: 2
|
||||
bash: line 1: exit: abcde: numeric argument required
|
||||
bash: line 1: break: abcde: numeric argument required
|
||||
bash: line 1: continue: abcde: numeric argument required
|
||||
bash: line 1: shift: abcde: numeric argument required
|
||||
bash: line 1: return: abcde: numeric argument required
|
||||
./errors10.sub: line 38: history: abcde: numeric argument required
|
||||
after history: 2
|
||||
./errors10.sub: line 40: history: too many arguments
|
||||
after history: 2
|
||||
too many arguments
|
||||
errors: line 3: exit: too many arguments
|
||||
after exit: 2
|
||||
errors: line 3: return: too many arguments
|
||||
after return: 2
|
||||
errors: line 3: shift: too many arguments
|
||||
after shift: 2
|
||||
errors: line 3: break: too many arguments
|
||||
after break: 2
|
||||
errors: line 3: continue: too many arguments
|
||||
after continue: 2
|
||||
errors: line 3: exit: too many arguments
|
||||
after exit: 2
|
||||
errors: line 3: return: too many arguments
|
||||
after return: 2
|
||||
errors: line 3: shift: too many arguments
|
||||
after shift: 2
|
||||
errors: line 3: break: too many arguments
|
||||
after break: 2
|
||||
errors: line 3: continue: too many arguments
|
||||
after continue: 2
|
||||
bash: line 1: return: can only `return' from a function or sourced script
|
||||
after return
|
||||
bash: line 1: return: can only `return' from a function or sourced script
|
||||
@@ -277,4 +316,4 @@ sh: line 1: unset: `a-b': not a valid identifier
|
||||
sh: line 1: /nosuchfile: No such file or directory
|
||||
sh: line 1: trap: SIGNOSIG: invalid signal specification
|
||||
after trap
|
||||
./errors.tests: line 395: `!!': not a valid identifier
|
||||
./errors.tests: line 398: `!!': not a valid identifier
|
||||
|
||||
@@ -373,6 +373,9 @@ ${THIS_SH} -o posix ./errors7.sub
|
||||
${THIS_SH} ./errors8.sub
|
||||
${THIS_SH} ./errors9.sub
|
||||
|
||||
# invalid numeric arguments and too many arguments
|
||||
${THIS_SH} ./errors10.sub
|
||||
|
||||
${THIS_SH} -c 'return ; echo after return' bash
|
||||
${THIS_SH} -o posix -c 'return ; echo after return' bash
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
# 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/>.
|
||||
#
|
||||
: ${THIS_SH:=$PWD/bash} ${TMPDIR:=/tmp}
|
||||
POSIX_SH="${THIS_SH} -o posix"
|
||||
|
||||
# these are the posix special builtins that take a numeric argument
|
||||
|
||||
echo invalid numeric argument
|
||||
# default mode
|
||||
for b in exit break continue shift; do
|
||||
BUILTIN=$b ${THIS_SH} -c 'set -- a b c; (exit 45); for f in _; do $BUILTIN abcde; done; echo after $BUILTIN: $?' bash
|
||||
done
|
||||
${THIS_SH} -c 'func() { return abcde; echo in func: $?; }; func; echo after return: $?' bash
|
||||
|
||||
# posix mode
|
||||
for b in exit break continue shift; do
|
||||
BUILTIN=$b ${POSIX_SH} -c 'set -- a b c; (exit 45); for f in _; do $BUILTIN abcde; done; echo after $BUILTIN: $?' bash
|
||||
done
|
||||
${POSIX_SH} -c 'func() { return abcde; echo in func: $?; }; func; echo after return: $?' bash
|
||||
|
||||
# non-special builtins, no difference
|
||||
set -o history
|
||||
HISTFILE=/dev/null
|
||||
echo a >/dev/null
|
||||
echo b >/dev/null
|
||||
echo c >/dev/null
|
||||
history abcde
|
||||
echo after history: $?
|
||||
history 10 42
|
||||
echo after history: $?
|
||||
set +o history
|
||||
|
||||
# too many arguments
|
||||
|
||||
echo too many arguments
|
||||
|
||||
TDIR=$TMPDIR/errors-$$
|
||||
TFILE=errors
|
||||
mkdir $TDIR || exit 1
|
||||
cd $TDIR
|
||||
|
||||
cat <<\EOF >$TFILE
|
||||
set -- a b c
|
||||
(exit 45)
|
||||
for f in _; do $BUILTIN 42 abcde; done
|
||||
echo after $BUILTIN: $?
|
||||
EOF
|
||||
|
||||
# default mode
|
||||
for b in exit return shift break continue; do
|
||||
BUILTIN=$b ${THIS_SH} $TFILE # TFILE for consistent error messages
|
||||
done
|
||||
# posix mode
|
||||
for b in exit return shift break continue; do
|
||||
BUILTIN=$b ${POSIX_SH} $TFILE # TFILE for consistent error messages
|
||||
done
|
||||
|
||||
cd $OLDPWD
|
||||
rm -rf $TDIR
|
||||
@@ -96,6 +96,7 @@ do
|
||||
echo $(( 2**$i ));
|
||||
done
|
||||
|
||||
this is bash_logout
|
||||
a
|
||||
a
|
||||
bad-interp
|
||||
|
||||
@@ -41,13 +41,15 @@ ${THIS_SH} ./invocation2.sub
|
||||
# rudimentary pretty-print tests
|
||||
${THIS_SH} ./invocation3.sub
|
||||
|
||||
${THIS_SH} --login -c 'logout'
|
||||
|
||||
: ${TMPDIR:=/tmp}
|
||||
TDIR=$TMPDIR/invocation-$$
|
||||
mkdir $TDIR || exit 1
|
||||
SAVEPWD=$PWD
|
||||
|
||||
echo 'echo this is bash_logout' > $TDIR/.bash_logout
|
||||
HOME=$TDIR ${THIS_SH} --login -c 'logout'
|
||||
rm -f $TDIR/.bash_logout
|
||||
|
||||
# script that ends with a comment and no newline
|
||||
printf 'echo a # comment' > $TDIR/x23.in
|
||||
${THIS_SH} $TDIR/x23.in
|
||||
|
||||
Reference in New Issue
Block a user