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
11
bin/ignore
11
bin/ignore
|
@ -20,18 +20,17 @@
|
||||||
# non-ksh script for the nmake ignore prefix
|
# non-ksh script for the nmake ignore prefix
|
||||||
# @(#)ignore (AT&T Research) 1992-08-11
|
# @(#)ignore (AT&T Research) 1992-08-11
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
|
modern_export=`v=; export v=ok 2>/dev/null; echo "$v"`
|
||||||
esac
|
|
||||||
|
|
||||||
while :
|
while :
|
||||||
do case $# in
|
do case $# in
|
||||||
0) exit 0 ;;
|
0) exit 0 ;;
|
||||||
esac
|
esac
|
||||||
case $1 in
|
case $1 in
|
||||||
*=*) case $RANDOM in
|
*=*) case $modern_export in
|
||||||
$RANDOM)`echo $1 | sed "s/\\([^=]*\\)=\\(.*\\)/eval \\1='\\2'; export \\1/"` ;;
|
ok) export "$1" ;;
|
||||||
*) export "$1" ;;
|
*) `echo $1 | sed "s/\\([^=]*\\)=\\(.*\\)/eval \\1='\\2'; export \\1/"` ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
# mamprobe - generate MAM cc probe info
|
# mamprobe - generate MAM cc probe info
|
||||||
# Glenn Fowler <gsf@research.att.com>
|
# Glenn Fowler <gsf@research.att.com>
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
command=mamprobe
|
command=mamprobe
|
||||||
|
|
||||||
|
|
69
bin/package
69
bin/package
|
@ -24,37 +24,33 @@ USAGE_LICENSE="[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyrigh
|
||||||
|
|
||||||
command=package
|
command=package
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
|
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
|
esac
|
||||||
|
|
||||||
# ksh checks -- ksh between 2007-11-05 and 2011-11-11 conflict with new -lcmd -- wea culpa
|
# shell checks
|
||||||
checksh()
|
checksh()
|
||||||
{
|
{
|
||||||
egrep 'Version.*(88|1993)' $1 >/dev/null 2>&1 ||
|
"$1" -ec '
|
||||||
PATH=/dev/null $1 -c '(( 2 + 2 ))' >/dev/null 2>&1 &&
|
# reject csh
|
||||||
$1 -c '(( .sh.version >= 20111111 ))' >/dev/null 2>&1
|
case 1 in
|
||||||
}
|
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
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
SHELL=/bin/sh
|
# reject special use of $path (to use zsh, use a "sh -> zsh" symlink, which disables this)
|
||||||
export SHELL
|
path=Bad
|
||||||
exec $SHELL "$0" "$@"
|
case $PATH in
|
||||||
fi
|
Bad*) exit 1 ;;
|
||||||
;;
|
esac
|
||||||
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
|
LC_ALL=C
|
||||||
export LC_ALL
|
export LC_ALL
|
||||||
|
@ -3103,26 +3099,7 @@ cat $INITROOT/$i.sh
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
*) checksh $SHELL || SHELL=/bin/sh
|
||||||
|
|
||||||
# $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
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
export SHELL
|
export SHELL
|
||||||
|
|
11
bin/silent
11
bin/silent
|
@ -20,18 +20,17 @@
|
||||||
# non-ksh stub for the nmake silent prefix
|
# non-ksh stub for the nmake silent prefix
|
||||||
# @(#)silent (AT&T Research) 1992-08-11
|
# @(#)silent (AT&T Research) 1992-08-11
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
*x*:[01234567899]*) : bash set -x is broken :; set +ex ;;
|
modern_export=`v=; export v=ok 2>/dev/null; echo "$v"`
|
||||||
esac
|
|
||||||
|
|
||||||
while :
|
while :
|
||||||
do case $# in
|
do case $# in
|
||||||
0) exit 0 ;;
|
0) exit 0 ;;
|
||||||
esac
|
esac
|
||||||
case $1 in
|
case $1 in
|
||||||
*=*) case $RANDOM in
|
*=*) case $modern_export in
|
||||||
$RANDOM)`echo $1 | sed "s/\\([^=]*\\)=\\(.*\\)/eval \\1='\\2'; export \\1/"` ;;
|
ok) export "$1" ;;
|
||||||
*) export "$1" ;;
|
*) `echo $1 | sed "s/\\([^=]*\\)=\\(.*\\)/eval \\1='\\2'; export \\1/"` ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
: cross compiler a.out execution
|
: cross compiler a.out execution
|
||||||
|
|
||||||
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
|
|
||||||
command=crossexec
|
command=crossexec
|
||||||
|
|
||||||
tmp=/tmp/cross$$
|
tmp=/tmp/cross$$
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
: wrapper for .exe challenged win32 systems/commands
|
: wrapper for .exe challenged win32 systems/commands
|
||||||
|
|
||||||
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
|
|
||||||
command=execrate
|
command=execrate
|
||||||
|
|
||||||
bins=`
|
bins=`
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
: convert command that operates on file args to pipeline filter
|
: convert command that operates on file args to pipeline filter
|
||||||
|
|
||||||
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
|
|
||||||
command=filter
|
command=filter
|
||||||
|
|
||||||
TMPDIR=${TMPDIR:-/tmp}
|
TMPDIR=${TMPDIR:-/tmp}
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
: copy http url data
|
: copy http url data
|
||||||
|
|
||||||
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
|
|
||||||
command=hurl
|
command=hurl
|
||||||
agent="$command/2009-01-20 (AT&T Research)"
|
agent="$command/2009-01-20 (AT&T Research)"
|
||||||
authorize=
|
authorize=
|
||||||
|
|
|
@ -25,9 +25,7 @@
|
||||||
#
|
#
|
||||||
# NOTE: .exe a.out suffix and [\\/] in path patterns for dos/nt
|
# NOTE: .exe a.out suffix and [\\/] in path patterns for dos/nt
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
command=iffe
|
command=iffe
|
||||||
version=2012-07-17 # update in USAGE too #
|
version=2012-07-17 # update in USAGE too #
|
||||||
|
|
|
@ -20,18 +20,17 @@
|
||||||
# non-ksh script for the nmake ignore prefix
|
# non-ksh script for the nmake ignore prefix
|
||||||
# @(#)ignore (AT&T Research) 1992-08-11
|
# @(#)ignore (AT&T Research) 1992-08-11
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
|
modern_export=`v=; export v=ok 2>/dev/null; echo "$v"`
|
||||||
esac
|
|
||||||
|
|
||||||
while :
|
while :
|
||||||
do case $# in
|
do case $# in
|
||||||
0) exit 0 ;;
|
0) exit 0 ;;
|
||||||
esac
|
esac
|
||||||
case $1 in
|
case $1 in
|
||||||
*=*) case $RANDOM in
|
*=*) case $modern_export in
|
||||||
$RANDOM)`echo $1 | sed "s/\\([^=]*\\)=\\(.*\\)/eval \\1='\\2'; export \\1/"` ;;
|
ok) export "$1" ;;
|
||||||
*) export "$1" ;;
|
*) `echo $1 | sed "s/\\([^=]*\\)=\\(.*\\)/eval \\1='\\2'; export \\1/"` ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
# mamprobe - generate MAM cc probe info
|
# mamprobe - generate MAM cc probe info
|
||||||
# Glenn Fowler <gsf@research.att.com>
|
# Glenn Fowler <gsf@research.att.com>
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
command=mamprobe
|
command=mamprobe
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
# #
|
# #
|
||||||
########################################################################
|
########################################################################
|
||||||
: mkdir for systems that do not support -p : 2002-09-01 :
|
: mkdir for systems that do not support -p : 2002-09-01 :
|
||||||
MKDIR=/bin/mkdir
|
|
||||||
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
|
|
||||||
|
MKDIR=mkdir
|
||||||
CHMOD=chmod
|
CHMOD=chmod
|
||||||
mode=
|
mode=
|
||||||
parents=
|
parents=
|
||||||
|
|
|
@ -23,37 +23,33 @@
|
||||||
|
|
||||||
command=package
|
command=package
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
|
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
|
esac
|
||||||
|
|
||||||
# ksh checks -- ksh between 2007-11-05 and 2011-11-11 conflict with new -lcmd -- wea culpa
|
# shell checks
|
||||||
checksh()
|
checksh()
|
||||||
{
|
{
|
||||||
egrep 'Version.*(88|1993)' $1 >/dev/null 2>&1 ||
|
"$1" -ec '
|
||||||
PATH=/dev/null $1 -c '(( 2 + 2 ))' >/dev/null 2>&1 &&
|
# reject csh
|
||||||
$1 -c '(( .sh.version >= 20111111 ))' >/dev/null 2>&1
|
case 1 in
|
||||||
}
|
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
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
SHELL=/bin/sh
|
# reject special use of $path (to use zsh, use a "sh -> zsh" symlink, which disables this)
|
||||||
export SHELL
|
path=Bad
|
||||||
exec $SHELL "$0" "$@"
|
case $PATH in
|
||||||
fi
|
Bad*) exit 1 ;;
|
||||||
;;
|
esac
|
||||||
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
|
LC_ALL=C
|
||||||
export LC_ALL
|
export LC_ALL
|
||||||
|
@ -3102,26 +3098,7 @@ cat $INITROOT/$i.sh
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
*) checksh $SHELL || SHELL=/bin/sh
|
||||||
|
|
||||||
# $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
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
export SHELL
|
export SHELL
|
||||||
|
|
|
@ -20,18 +20,17 @@
|
||||||
# non-ksh stub for the nmake silent prefix
|
# non-ksh stub for the nmake silent prefix
|
||||||
# @(#)silent (AT&T Research) 1992-08-11
|
# @(#)silent (AT&T Research) 1992-08-11
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
(set -o posix) 2>/dev/null && set -o posix
|
||||||
*x*:[01234567899]*) : bash set -x is broken :; set +ex ;;
|
modern_export=`v=; export v=ok 2>/dev/null; echo "$v"`
|
||||||
esac
|
|
||||||
|
|
||||||
while :
|
while :
|
||||||
do case $# in
|
do case $# in
|
||||||
0) exit 0 ;;
|
0) exit 0 ;;
|
||||||
esac
|
esac
|
||||||
case $1 in
|
case $1 in
|
||||||
*=*) case $RANDOM in
|
*=*) case $modern_export in
|
||||||
$RANDOM)`echo $1 | sed "s/\\([^=]*\\)=\\(.*\\)/eval \\1='\\2'; export \\1/"` ;;
|
ok) export "$1" ;;
|
||||||
*) export "$1" ;;
|
*) `echo $1 | sed "s/\\([^=]*\\)=\\(.*\\)/eval \\1='\\2'; export \\1/"` ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
|
|
||||||
# @(#)math.sh (AT&T Research) 2012-06-13
|
# @(#)math.sh (AT&T Research) 2012-06-13
|
||||||
|
|
||||||
|
case $ZSH_VERSION in
|
||||||
|
?*) emulate ksh ;;
|
||||||
|
*) (set -o posix) 2>/dev/null && set -o posix ;;
|
||||||
|
esac
|
||||||
|
|
||||||
command=$0
|
command=$0
|
||||||
iffeflags="-n -v"
|
iffeflags="-n -v"
|
||||||
iffehdrs="math.h"
|
iffehdrs="math.h"
|
||||||
|
|
|
@ -34,8 +34,9 @@
|
||||||
# but you shall be confused anyway
|
# but you shall be confused anyway
|
||||||
#
|
#
|
||||||
|
|
||||||
case $-:$BASH_VERSION in
|
case $ZSH_VERSION in
|
||||||
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
|
?*) emulate ksh ;;
|
||||||
|
*) (set -o posix) 2>/dev/null && set -o posix ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
|
|
|
@ -19,6 +19,12 @@
|
||||||
# Phong Vo <kpv@research.att.com> #
|
# Phong Vo <kpv@research.att.com> #
|
||||||
# #
|
# #
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
|
case $ZSH_VERSION in
|
||||||
|
?*) emulate ksh ;;
|
||||||
|
*) (set -o posix) 2>/dev/null && set -o posix ;;
|
||||||
|
esac
|
||||||
|
|
||||||
ok=0
|
ok=0
|
||||||
for i in \
|
for i in \
|
||||||
-x /lib/ld.so /lib/ld-*.so /usr/lib/ld.so /lib/rld \
|
-x /lib/ld.so /lib/ld-*.so /usr/lib/ld.so /lib/rld \
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
# #
|
# #
|
||||||
########################################################################
|
########################################################################
|
||||||
: generate "<sys/param.h> + <sys/types.h> + <sys/stat.h>" include sequence
|
: generate "<sys/param.h> + <sys/types.h> + <sys/stat.h>" include sequence
|
||||||
|
|
||||||
|
case $ZSH_VERSION in
|
||||||
|
?*) emulate ksh ;;
|
||||||
|
*) (set -o posix) 2>/dev/null && set -o posix ;;
|
||||||
|
esac
|
||||||
|
|
||||||
case $# in
|
case $# in
|
||||||
0) ;;
|
0) ;;
|
||||||
*) eval $1
|
*) eval $1
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
# #
|
# #
|
||||||
########################################################################
|
########################################################################
|
||||||
: generate preroot features
|
: generate preroot features
|
||||||
|
|
||||||
|
case $ZSH_VERSION in
|
||||||
|
?*) emulate ksh ;;
|
||||||
|
*) (set -o posix) 2>/dev/null && set -o posix ;;
|
||||||
|
esac
|
||||||
|
|
||||||
case $# in
|
case $# in
|
||||||
0) ;;
|
0) ;;
|
||||||
*) eval $1
|
*) eval $1
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
# #
|
# #
|
||||||
########################################################################
|
########################################################################
|
||||||
: generate sig features
|
: generate sig features
|
||||||
|
|
||||||
|
case $ZSH_VERSION in
|
||||||
|
?*) emulate ksh ;;
|
||||||
|
*) (set -o posix) 2>/dev/null && set -o posix ;;
|
||||||
|
esac
|
||||||
|
|
||||||
case $# in
|
case $# in
|
||||||
0) ;;
|
0) ;;
|
||||||
*) eval $1
|
*) eval $1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue