cdesktopenv/src/cmd/ksh93/features/options

70 lines
1.7 KiB
Plaintext

# SHOPT_* option probe
tst note{ SHOPT_* option probe }end cross{
: check for shell magic #!
cat > "$EXECROOT/file$$" <<!
#! /usr/bin/env true
exit 1
!
chmod 755 "$EXECROOT/file$$"
if "$EXECROOT/file$$" 2>/dev/null
then echo "#define SHELLMAGIC 1"
fi
rm -f "$EXECROOT/file$$"
option() # name value
{
case $2 in
0) echo "#ifndef SHOPT_$1"
echo "# define SHOPT_$1 1"
echo "#endif"
;;
*) echo "#undef SHOPT_$1"
;;
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 $?
# test for multibyte support
case `echo a | tr a '\012' | wc -l` in
*1*) option MULTIBYTE 0 ;;
esac
# 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
[ $? = 0 ] && option TEST_L 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{
#if !_PACKAGE_ast && ( (MB_LEN_MAX-1)<=0 || !defined(_lib_mbtowc) )
# undef SHOPT_MULTIBYTE
#endif
}end
tst note{ can we probe file system case insensitivity }end output{
#include <ast.h>
#include <error.h>
#include <stdio.h>
static char *o = "SHOPT_GLOBCASEDET";
int main(int argc,char *argv[])
{
int r;
r = pathicase("/");
r = (r > -1 || errno != ENOSYS);
printf("#ifndef %s\n# define %s\t%d\n#endif\n", o, o, r);
return !r;
}
}end