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:22 UTC
Message-ID
<7vzmrpm1q9.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7virydnh1o.fsf@assigned-by-dhcp.cox.net>

Sorry, sent it out without finishing. The worst is "return". With ksh, ash, and dash, the script itself exits with status code 1 (presumably you are trapping it with trap -- exit, though).

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$ ash k.sh exit foo prompt$ ash k.sh false foo status 1 prompt$ ash k.sh return foo prompt$ ksh k.sh exit foo prompt$ ksh k.sh false foo status 1 prompt$ ksh k.sh return foo

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 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.