Files

114 lines
2.3 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
set +o posix
hash -r
unalias -a
# this should echo nothing
type
# this should be a usage error
type -r ${THIS_SH}
# these should behave identically, but POSIX says command -v is silent if the name is not found
type notthere
command -v notthere
# but this will produce an error message
command -V notthere
unset -f func 2>/dev/null
func() { echo this is func; }
type -t func
type -t while
type -t builtin
type -t /bin/sh
type -t ${THIS_SH}
type -t mv
type func
# the following two should produce identical output
type while
type -a while
type builtin
type /bin/sh
command -v func
command -V func
command -v while
command -V while
alias morealias=more
# the following two lines should produce the same output
# post-3.0 patch makes command -v silent, as posix specifies
# first test with alias expansion off (should all fail or produce no output)
type -t morealias
type morealias
command -v morealias
alias -p
alias morealias
# then test with alias expansion on
shopt -s expand_aliases
type morealias
type -t morealias
command -v morealias
alias -p
alias morealias
command -V morealias
shopt -u expand_aliases
command -v builtin
command -V builtin
command -v /bin/sh
command -V /bin/sh
unset -f func
type func
unalias morealias
type m
hash -r
hash -p /bin/sh sh
type -p sh
SHBASE=${THIS_SH##*/}
hash -p /tmp/$SHBASE $SHBASE
type -p $SHBASE
type $SHBASE
type -t $SHBASE
# make sure the hash table looks right
hash
# bug in versions of bash up to and including bash-3.2
f() {
v=$'\001'
}
type f | cat -v
test_runsub type1.sub
test_runsub type2.sub
test_runsub type3.sub
test_runsub type4.sub
test_runsub type5.sub