mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-21 12:57:58 +02:00
80 lines
2.0 KiB
Plaintext
80 lines
2.0 KiB
Plaintext
# 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/>.
|
|
#
|
|
. ./test-aux-functions
|
|
|
|
: ${THIS_SH:=./bash}
|
|
|
|
# invocation modes and errors
|
|
|
|
${THIS_SH} .
|
|
|
|
#${THIS_SH} --version -c 'exit 0' bash
|
|
#${THIS_SH} --help -c 'exit 0' bash
|
|
|
|
${THIS_SH} -c |& sed 's|^.*/bash|bash|'
|
|
|
|
${THIS_SH} --badopt |& sed 's|^.*/bash|bash|'
|
|
${THIS_SH} --initfile |& sed 's|^.*/bash|bash|'
|
|
${THIS_SH} -q |& sed 's|^.*/bash|bash|'
|
|
|
|
export BASH_ARGV0=this-bash
|
|
${THIS_SH} -c 'echo $0 $BASH_ARGV0'
|
|
unset BASH_ARGV0
|
|
|
|
{ ${THIS_SH} -c 'echo $-' bash | grep c >/dev/null; } && echo '$- for -c includes c'
|
|
|
|
# BASHOPTS
|
|
test_runsub ./invocation1.sub
|
|
# SHELLOPTS
|
|
test_runsub ./invocation2.sub
|
|
|
|
# rudimentary pretty-print tests
|
|
test_runsub ./invocation3.sub
|
|
|
|
: ${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
|
|
printf 'echo a' > $TDIR/x23.in
|
|
${THIS_SH} $TDIR/x23.in
|
|
rm -f $TDIR/x23.in
|
|
|
|
# script with invalid interpreter
|
|
cat > $TDIR/x23 <<EOF
|
|
#! nosuchfile
|
|
echo bad-interp
|
|
EOF
|
|
chmod +x $TDIR/x23
|
|
|
|
# this is fine
|
|
${THIS_SH} $TDIR/x23
|
|
command cd -L $TDIR
|
|
# but this results in a bad-interpreter error
|
|
./x23
|
|
|
|
# this should result in a cannot execute binary file error since ls is in $PATH
|
|
PATH=/bin:/usr/bin
|
|
${THIS_SH} ls |& sed 's|^.*: ||'
|
|
|
|
cd $SAVEPWD
|
|
rm -rf $TDIR
|