From efab5cde8ebdd65d60c44e0e0da43a63bebb87b1 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Sun, 28 Feb 2016 16:53:49 +0000 Subject: [PATCH] shell cycling --- urchin | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/urchin b/urchin index 9597678..de0b80b 100755 --- a/urchin +++ b/urchin @@ -145,19 +145,13 @@ recurse() { # Determine the environment variable to define for test scripts # that reflects the specified or implied shell to use for shell-code tests. while read the_test_shell; do - if test -n "$the_test_shell"; then - if has_sh_or_no_shebang_line "$potential_test"; then - the_exec=$the_test_shell - else - the_exec=exec - fi - else + if test -z "$the_test_shell"; then # Shell cycling is disabled with -n; use the present value of # TEST_SHELL or default to /bin/sh if [ -n "$TEST_SHELL" ]; then the_test_shell="$TEST_SHELL" else - the_test_shell='/bin/sh' + the_test_shell=/bin/sh fi fi ( @@ -166,8 +160,15 @@ recurse() { # Run the test start=$(date +%s) set +e - TEST_SHELL="$the_test_shell" "$the_exec" "$potential_test" >> \ - "$(stdout_file "$potential_test")" 2>&1 + { + if $cycle_shell && + has_sh_or_no_shebang_line "$potential_test"; then + TEST_SHELL="$the_test_shell" "$the_test_shell" \ + "$potential_test" + else + TEST_SHELL="$the_test_shell" "$potential_test" + fi + } > "$(stdout_file "$potential_test")" 2>&1 exit_code="$?" set -e finish=$(date +%s) @@ -462,13 +463,22 @@ do shift done +if $cycle_shell && test -f "$shell_list"; then + echo "The -n/--disable-cycling and -s/--shell options clash with each other." >&2 + urchin_exit 11 +fi + # If -s was not passed, use the available default shells. if ! test -f "$shell_list"; then - for shell in $DEFAULT_SHELLS; do - if which $shell > /dev/null; then - echo $shell >> "$shell_list" - fi - done + if $cycle_shell; then + for shell in $DEFAULT_SHELLS; do + if which $shell > /dev/null; then + echo $shell >> "$shell_list" + fi + done + else + echo > "$shell_list" + fi fi # Verify argument for main stuff