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

Re: [PATCH] test-lib.sh: work around ksh's trap shortcomings

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Aug 19, 2008, 14:59 UTC
Message-ID
<nRhBKqCwHxZZH8zh17SOnUKHFp0V5HZj8_Lcmybj49DM7L4TYYoZbQ@cipher.nrlssc.navy.mil>
In-Reply-To
<7v3al1h2rk.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
> Yeah, I think I got the subtle distinction between [PATCH FYI], [PATCH]
> and ones with and without sign-offs.

Heh, so subtle as to be unintentional. I think I mucked up that posting. I should have labeled them all FYI and numbered them. I did hope there would be some discussion that would result in a followup patch for submission.

> I've read "trap" section of 1003.1 2004 three times but I do not see the
> exact definition of "EXIT" condition mentioned.  Is the behaviour to
> consider "function return" the EXIT condition considered a "shortcoming"
> (aka bug)?
No, I think it is the defined behavior for the Korn shell.
The SunOS 5.7 man page states:
     If sig  is  0 or EXIT and the trap  statement is exe-
     cuted inside the body of a function, then the com-
     mand arg is executed after the function completes.
     If sig is 0 or EXIT for a trap   set  outside  any
     function, the command arg is executed on exit from
     the shell.
The IRIX 6.5 man page has the exact same wording.
On linux, the man page for the public domain Korn shell states
    Functions  defined with the function reserved word are treated differ-
    ently in the following ways from functions defined with the  ()  nota-
    tion:
        ...
      - The EXIT trap, if set in a function, will be executed after the
        function returns.
But then later in the trap section:
    The original Korn shell’s DEBUG trap and the  handling  of  ERR
    and EXIT traps in functions are not yet implemented.

If Korn shell is to be supported, it seems that trap on EXIT must be avoided within functions. I think the only one is in git-bisect.

-brandon
Previous: Junio C HamanoNext: Brandon Casey
Message 13 of 28 in “[FYI] How I compile on IRIX 6.5 with the MIPSpro compiler and ksh”
  1. Brandon CaseyAug 18, 2008
  2. Makefile: add section for SGI IRIXBrandon Casey, Aug 18, 2008
  3. git-compat-util.h: adjust for SGI IRIX 6.5Brandon Casey, Aug 18, 2008
  4. unpack-trees.c: work around run-time array initialization flaw on IRIX 6.5Brandon Casey, Aug 18, 2008
  5. templates/Makefile: work around SGI install which assumes / if ROOT not definedBrandon Casey, Aug 18, 2008
  6. Junio C HamanoAug 18, 2008
  7. Brandon CaseyAug 19, 2008
  8. templates/Makefile: install is unnecessary, just use mkdir -pBrandon Casey, Aug 22, 2008
  9. test-lib.sh: work around ksh's trap shortcomingsBrandon Casey, Aug 18, 2008
  10. Junio C HamanoAug 18, 2008
  11. Brandon CaseyAug 19, 2008
  12. Junio C HamanoAug 19, 2008
  13. Brandon CaseyAug 19, 2008
  14. Brandon CaseyAug 19, 2008
  15. Brandon CaseyAug 20, 2008
  16. Mike RalphsonAug 20, 2008
  17. t1002-read-tree-m-u-2way.sh: use 'git diff -U0' rather than 'diff -U0'Brandon Casey, Aug 18, 2008
  18. t9301-fast-export.sh: don't unset config variable while we're skipping test 4Brandon Casey, Aug 18, 2008
  19. Junio C HamanoAug 19, 2008
  20. Brandon CaseyAug 19, 2008
  21. t9301-fast-export: move unset of config variable into its own test functionBrandon Casey, Aug 22, 2008
  22. Junio C HamanoAug 22, 2008
  23. Junio C HamanoAug 22, 2008
  24. Johannes SixtAug 22, 2008
  25. Junio C HamanoAug 22, 2008
  26. Brandon CaseyAug 18, 2008
  27. Boyd Lynn GerberAug 19, 2008
  28. Brandon CaseyAug 19, 2008

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.