Skip to content

Commit

Permalink
shellspec-time.sh: Drop bourne shell support
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed Jun 7, 2024
1 parent cfb272b commit 225e0f0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions libexec/shellspec-time.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/sh
# shellcheck disable=SC2004
# Write it to work in a Bourne shell if possible.

if [ -z "$PPID" ]; then
echo 'Bourne Shell is not supported.' \
'Run in a specific POSIX shell as follows.' >&2
echo '$ ksh shellspec-time sleep 1' >&2
exit 1
fi

set -f

Expand Down Expand Up @@ -38,8 +44,7 @@ detect_time_type() {
fi

if [ ! "${KSH_VERSION:-}" ]; then
# shellcheck disable=SC2006
KSH_VERSION=`eval 'echo ${.sh.version}'`
KSH_VERSION=$(eval 'echo ${.sh.version}')
fi 2>/dev/null

if [ "${BASH_VERSION:-}" ]; then
Expand Down Expand Up @@ -79,7 +84,7 @@ detect_time_type
?) set -- -s LC_ALL "$LC_ALL" "$@" ;;
*) set -- -u LC_ALL "$@" ;;
esac
LC_ALL=C && export LC_ALL
export LC_ALL=C

# bash or ksh93
case ${TIMEFORMAT+x} in
Expand All @@ -100,7 +105,7 @@ detect_time_type
?) set -- -s TIME "$TIME" "$@" ;;
*) set -- -u TIME "$@" ;;
esac
TIME="real %e${LF}user %U${LF}sys %S" && export TIME
export TIME="real %e${LF}user %U${LF}sys %S"

# shellcheck disable=SC2016
set -- sh -c '
Expand Down Expand Up @@ -142,9 +147,8 @@ detect_time_type
"$SHELLSPEC_TRAP" '' INT

real='' user='' sys='' type=$SHELLSPEC_TIME_TYPE ex=''
# shellcheck disable=SC2162

while read name time; do
while read -r name time; do
# ksh88: 1m2.34s
case $time in *m*s)
type=ksh88-builtin
Expand Down

0 comments on commit 225e0f0

Please sign in to comment.