mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
build system: modernise shell compatibility checks
All changed files: - Put the shell in POSIX mode if it has an '-o posix' option. - Remove nonsense disabling 'set -x' on bash. It's not broken. bin/package, src/cmd/INIT/package.sh: - Add check blocking native zsh mode (e.g., "$path" conflicts). Using a 'sh -> zsh' symlink works, so recommend that. - Remove old ksh93 version check for a supposed conflict with libcmd. It was broken; it would revert to /bin/sh, but on illumos distributions, /bin/sh is a ksh93 of a version that is supposedly affected. It builds fine anyway. - Rewrite checksh() to incorporate the shell compatibility checks that were previously in two different places in 'package'. bin/ignore, src/cmd/INIT/ignore.sh, bin/silent, src/cmd/INIT/silent.sh: - Change bad check for a full POSIX 'export' command (no, $RANDOM has nothing to do with that) with a proper feature test.
This commit is contained in:
parent
42d1651108
commit
9b45f2ccbe
20 changed files with 113 additions and 128 deletions
69
bin/package
69
bin/package
|
@ -24,37 +24,33 @@ USAGE_LICENSE="[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyrigh
|
|||
|
||||
command=package
|
||||
|
||||
case $-:$BASH_VERSION in
|
||||
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
|
||||
(set -o posix) 2>/dev/null && set -o posix
|
||||
path=Bad
|
||||
case $PATH in
|
||||
Bad*) echo "Cannot be run by zsh in native mode; use a sh symlink to zsh" >&2
|
||||
exit 1 ;;
|
||||
esac
|
||||
|
||||
# ksh checks -- ksh between 2007-11-05 and 2011-11-11 conflict with new -lcmd -- wea culpa
|
||||
# shell checks
|
||||
checksh()
|
||||
{
|
||||
egrep 'Version.*(88|1993)' $1 >/dev/null 2>&1 ||
|
||||
PATH=/dev/null $1 -c '(( 2 + 2 ))' >/dev/null 2>&1 &&
|
||||
$1 -c '(( .sh.version >= 20111111 ))' >/dev/null 2>&1
|
||||
}
|
||||
|
||||
case $_AST_BIN_PACKAGE_:$SHELL:$0 in
|
||||
1:*:*|*:/bin/sh:*)
|
||||
;;
|
||||
*:*/*:*/*)
|
||||
_AST_BIN_PACKAGE_=1 # prevent non-interactive sh .rc referencing bin/package recursion #
|
||||
export _AST_BIN_PACKAGE_
|
||||
if checksh $SHELL
|
||||
then : no -lcmd conflict :
|
||||
else case " $* " in
|
||||
*" debug "*|*" DEBUG "*|*" show "*)
|
||||
echo $command: $SHELL: warning: possible -lcmd conflict -- falling back to /bin/sh >&2
|
||||
;;
|
||||
"$1" -ec '
|
||||
# reject csh
|
||||
case 1 in
|
||||
1) ;;
|
||||
esac
|
||||
SHELL=/bin/sh
|
||||
export SHELL
|
||||
exec $SHELL "$0" "$@"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# reject special use of $path (to use zsh, use a "sh -> zsh" symlink, which disables this)
|
||||
path=Bad
|
||||
case $PATH in
|
||||
Bad*) exit 1 ;;
|
||||
esac
|
||||
# catch (our own) pipe/socket configuration mismatches
|
||||
date | "$1" -c "read x" || exit 1
|
||||
# check Bourne/POSIX compatible trap exit status (should exit with status 0)
|
||||
trap "exit 0" 0
|
||||
exit 1
|
||||
' x "$1" 2>/dev/null || return 1
|
||||
}
|
||||
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
@ -3103,26 +3099,7 @@ cat $INITROOT/$i.sh
|
|||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
# $SHELL must be /bin/sh compatible
|
||||
|
||||
case $SHELL in
|
||||
/bin/sh);;
|
||||
'') SHELL=/bin/sh
|
||||
;;
|
||||
*) $SHELL -c 'trap "exit 0" 0; exit 1' 2>/dev/null
|
||||
case $? in
|
||||
1) SHELL=/bin/sh
|
||||
;;
|
||||
*) # catch (our own) pipe/socket configuration mismatches
|
||||
$SHELL -c "date | $SHELL -c 'read x'"
|
||||
case $? in
|
||||
0) ;;
|
||||
*) SHELL=/bin/sh ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
*) checksh $SHELL || SHELL=/bin/sh
|
||||
;;
|
||||
esac
|
||||
export SHELL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue