git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Trapping exit in tests, using return for errors

From
Junio C Hamano <junkio@cox.net>
Date
Aug 11, 2005, 06:06 UTC
Message-ID
<7virydnh1o.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1123732581.18644.37.camel@dv>
Pavel Roskin <proski@gnu.org> writes:
> This patch does following:
>
> All instances of "exit", "exit 1" and "(exit 1)" in tests have been
> replaced with "return 1".  In fact, "(exit 1)" had no effect.
Are you sure about all of the above?

You are right about "... || exit" in the expect_success tests; they are broken. But '(exit 1)' or just saying 'false' at the end should have done the right thing. Worse yet, return does not seem to really work as expected, except if all you want to do was to tell the test driver "I failed", in which case "bloopl" would work just as well.

prompt$ cat k.sh
what="$1"
eval '
        echo foo
        case '$what' in
        false)
                (exit 1) ;;
        exit)
                exit 1 ;;
        return)
                return 1 ;;
        esac
'
echo "status $?"
prompt$ bash k.sh exit
foo
prompt$ bash k.sh false
foo
status 1
prompt$ bash k.sh return
foo
k.sh: line 20: return: can only `return' from a function or sourced script
status 1
prompt$ 
Previous: Pavel RoskinNext: Junio C Hamano
Message 2 of 5 in “Trapping exit in tests, using return for errors”
  1. Trapping exit in tests, using return for errorsPavel Roskin, Aug 11, 2005
  2. Junio C HamanoAug 11, 2005
  3. Junio C HamanoAug 11, 2005
  4. Junio C HamanoAug 11, 2005
  5. Pavel RoskinAug 11, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.