mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 19:52:20 +00:00
options feature test tweaks
src/cmd/ksh93/features/options: - SHOPT_TEST_L: Use 'env test' instead of '/bin/test' to run external 'test', as the direct path is unportable. Create a test symlink and verify the positive case as well as the negative. - SHOPT_SYSRC: Use if...then..fi instead of ... && ... for the last test to avoid a non-zero exit status of the script, which outputs a spurious 'no' result like this: iffe: test: cross{ ... }end ... no - Add comments for clarity and to make the SHOPT_* names greppable. Related: https://github.com/ksh93/ksh/issues/219
This commit is contained in:
parent
844e6b2410
commit
51df036f26
1 changed files with 13 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
# SHOPT_* option probe
|
||||
|
||||
tst cross{
|
||||
tst note{ SHOPT_* option probe }end cross{
|
||||
: check for shell magic #!
|
||||
cat > "$EXECROOT/file$$" <<!
|
||||
#! /usr/bin/env true
|
||||
|
@ -24,6 +24,8 @@ tst cross{
|
|||
esac
|
||||
}
|
||||
|
||||
# if /dev/fd/n exposes file descriptor n, make SHOPT_DEVFD use this for
|
||||
# process substitutions instead of FIFOs, which are not as secure
|
||||
ls /dev/fd/9 9<&0 >/dev/null 2>&1
|
||||
option DEVFD $?
|
||||
case `echo a | tr a '\012' | wc -l` in
|
||||
|
@ -34,10 +36,17 @@ tst cross{
|
|||
#test -x /bin/pfexec -o -x /usr/bin/pfexec
|
||||
#option PFSH $?
|
||||
|
||||
/bin/test ! -l . 2> /dev/null
|
||||
# if external 'test' supports lowercase -l as equivalent to -L, enable
|
||||
# SHOPT_TEST_L so ksh supports it for compatibility with local scripts
|
||||
ln -s /dev/null "$EXECROOT/link$$"
|
||||
env test -l "$EXECROOT/link$$" 2>/dev/null && env test ! -l . 2>/dev/null
|
||||
option TEST_L $?
|
||||
test -f /etc/ksh.kshrc -o -f /etc/bash.bashrc &&
|
||||
option SYSRC 0
|
||||
rm -f "$EXECROOT/link$$"
|
||||
|
||||
# if one of these exists, make SHOPT_SYSRC load /etc/ksh.kshrc by default
|
||||
if test -f /etc/ksh.kshrc || test -f /etc/bash.bashrc
|
||||
then option SYSRC 0
|
||||
fi
|
||||
}end
|
||||
|
||||
cat{
|
||||
|
|
Loading…
Reference in a new issue