Skip to content

Commit

Permalink
Improve stability in older ksh93
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed May 21, 2024
1 parent 9b2d596 commit 6f930df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/general.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#shellcheck shell=sh disable=SC2004,SC2016

# Workaround for ksh 2020
if [ "${KSH_VERSION:-}" ]; then
# Workaround for ksh 2020: Heisenbug
case "${KSH_VERSION:-}" in (*2020*)
( exec 3>/dev/null 4>&3 5>&3 6>&3 7>&3 8>&3 9>&3
eval "dummy() { $(printf %8192s :); }"
) 3>&- 4>&- 5>&- 6>&- 7>&- 8>&- 9>&-
fi
esac

: "${SHELLSPEC_SHELL_TYPE:=}" "${SHELLSPEC_SHELL_VERSION:=}"
SHELLSPEC_SH_VERSION=$(eval 'echo "${.sh.version}"' 2>/dev/null) ||:
Expand Down
7 changes: 7 additions & 0 deletions libexec/shellspec-translate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ use escape_quote

delimiter="DELIMITER-$SHELLSPEC_UNIXTIME-$$"

disable_virtual_subshell() {
[ "$SHELLSPEC_SHELL_TYPE" = ksh ] || return 0
putsn 'ulimit -t $(ulimit -t)'
}

trans() {
# shellcheck disable=SC2145
"trans_$@"
}

trans_block_example_group() {
putsn "("
disable_virtual_subshell
[ "$skipped" ] && trans_skip ""
putsn "shellspec_group_id $block_id $block_no"
putsn "SHELLSPEC_LINENO_BEGIN=$lineno_begin"
Expand All @@ -28,6 +34,7 @@ trans_block_example_group() {

trans_block_example() {
putsn "("
disable_virtual_subshell
[ "$skipped" ] && trans_skip ""
putsn "shellspec_example_id $block_id $example_no $block_no"
putsn "SHELLSPEC_LINENO_BEGIN=$lineno_begin"
Expand Down

0 comments on commit 6f930df

Please sign in to comment.