diff --git a/urchin b/urchin index d77bff5..c9ef9df 100755 --- a/urchin +++ b/urchin @@ -16,13 +16,6 @@ unset CDPATH # Urchin version number VERSION=0.0.6 -fullpath() { - ( - cd -- "$1" - pwd - ) -} - indent() { level="$1" if test "$level" -gt 0; then @@ -96,7 +89,8 @@ recurse() { then TEST_SHELL="$TEST_SHELL" "$shell_for_sh_tests" ./"$potential_test" > "$stdout_file" 2>&1 else - TEST_SHELL="$TEST_SHELL" ./"$potential_test" > "$stdout_file" 2>&1 + dotslash=$(echo "$potential_test" | grep '^/' > /dev/null || echo ./) + TEST_SHELL="$TEST_SHELL" $dotslash"$potential_test" > "$stdout_file" 2>&1 fi exit_code="$?" @@ -298,22 +292,19 @@ do shift done -# Verify argument for main stuff -if [ "$#" != '1' ] || [ ! -d "$1" ] - then - [ -n "$1" ] && [ ! -d "$1" ] && echo "Not a directory: '$1'" >&2 - echo "$USAGE" >&2 - exit 11 -fi - -# Constants -logfile=$(fullpath "$1")/.urchin.log -stdout_file=$(fullpath "$1")/.urchin_stdout - # Run or present the Molly guard. -if fullpath "$1" | grep -Fi 'test' > /dev/null || $force - then - urchin_go "$1" "$shell_for_sh_tests" +thetest=$(readlink -f "$1") +if echo "$thetest" | grep -Fi 'test' > /dev/null || $force; then + if test -d "$1"; then + logfile="$thetest/.urchin.log" + stdout_file="$thetest/.urchin_stdout" + else + d=$(echo "$thetest" | sed 's/\/[^\/]\{1,\}$//') + logfile="$d/.urchin.log" + stdout_file="$d/.urchin_stdout" + cd "$d" + fi + urchin_go "$thetest" "$shell_for_sh_tests" else urchin_molly_guard fi