options.sh revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
# and is licensed under the #
# Common Public License, Version 1.0 #
# by AT&T Knowledge Ventures #
# #
# A copy of the License is available at #
# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# David Korn <dgk@research.att.com> #
# #
########################################################################
function err_exit
{
print -u2 -n "\t"
let Errors+=1
}
alias err_exit='err_exit $LINENO'
integer Errors=0
print $1
!
) != hello ]]
then err_exit "${SHELL-ksh} -s not working"
fi
x=$(
set -e
false && print bad
print good
)
if [[ $x != good ]]
then err_exit 'sh -e not workuing'
fi
print $'function env_hit\n{\n\tprint OK\n}' > $rc
if [[ -o privileged ]]
then
err_exit 'privileged nointeractive shell reads $ENV file'
err_exit 'privileged -E reads $ENV file'
err_exit 'privileged +E reads $ENV file'
err_exit 'privileged --rc reads $ENV file'
err_exit 'privileged --norc reads $ENV file'
else
err_exit 'nointeractive shell reads $ENV file'
err_exit '-E ignores $ENV file'
err_exit '+E reads $ENV file'
err_exit '--rc ignores $ENV file'
err_exit '--norc reads $ENV file'
fi
export ENV=
if [[ -o privileged ]]
then
err_exit 'privileged nointeractive shell reads $HOME/.kshrc file'
err_exit 'privileged -E ignores empty $ENV'
err_exit 'privileged +E reads $HOME/.kshrc file'
err_exit 'privileged --rc ignores empty $ENV'
err_exit 'privileged --norc reads $HOME/.kshrc file'
else
err_exit 'nointeractive shell reads $HOME/.kshrc file'
err_exit '-E ignores empty $ENV'
err_exit '+E reads $HOME/.kshrc file'
err_exit '--rc ignores empty $ENV'
err_exit '--norc reads $HOME/.kshrc file'
fi
unset ENV
if [[ -o privileged ]]
then
err_exit 'privileged nointeractive shell reads $HOME/.kshrc file'
err_exit 'privileged -E reads $HOME/.kshrc file'
err_exit 'privileged +E reads $HOME/.kshrc file'
err_exit 'privileged --rc reads $HOME/.kshrc file'
err_exit 'privileged --norc reads $HOME/.kshrc file'
else
err_exit 'nointeractive shell reads $HOME/.kshrc file'
err_exit '-E ignores $HOME/.kshrc file'
err_exit '+E reads $HOME/.kshrc file'
err_exit '--rc ignores $HOME/.kshrc file'
err_exit '--norc reads $HOME/.kshrc file'
fi
set -- **.c
[[ $* == $expected ]] ||
set -- **
[[ $* == $expected ]] ||
set -- **/*.c
[[ $* == $expected ]] ||
set -- **/bam.c
[[ $* == $expected ]] ||
cd ~-
fi
t="<$$>.profile.<$$>"
echo "echo '$t'" > .profile
if [[ -o privileged ]]
then
err_exit 'privileged -l reads .profile'
err_exit 'privileged --login reads .profile'
err_exit 'privileged --login-shell reads .profile'
err_exit 'privileged --login_shell reads .profile'
err_exit 'privileged exec -a -ksh ksh reads .profile'
err_exit 'privileged ./-ksh reads .profile'
err_exit 'privileged ./-ksh -p reads .profile'
else
err_exit '-l ignores .profile'
err_exit '--login ignores .profile'
err_exit '--login-shell ignores .profile'
err_exit '--login_shell ignores .profile'
err_exit 'exec -a -ksh ksh ignores .profile'
err_exit './-ksh ignores .profile'
err_exit './-ksh -p does not ignore .profile'
fi
cd ~-
# { exec interactive login_shell restricted xtrace } in the following test
glob \
gmacs \
if [[ ! -o $opt ]]
fi
set --$old
done
do [[ -o $opt ]]
y=$?
n=$?
case $y$n in
10|01) ;;
esac
done
do if [[ -o ?$opt ]]
fi
fi
done
false | true | true || err_exit 'pipe not exiting exit value of last element'
true | true | false && err_exit 'pipe not exiting false'
set -o pipefail
false | true | true && err_exit 'pipe with first not failing with pipefail'
true | false | true && err_exit 'pipe middle not failing with pipefail'
true | true | false && err_exit 'pipe last not failing with pipefail'