The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Steve <srb@unixsh.com>
To: tuhs@tuhs.org
Subject: [TUHS] GOTO etc
Date: Sun, 12 Mar 2023 14:23:51 -0400	[thread overview]
Message-ID: <eac9d81f-5350-3094-9141-51456ec2c645@unixsh.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

Dennis added setjmp() and longjmp() so the shell could handle errors in a reasonable way.
There are two places where setjmp was used in the original shell (7th edition) code as I recall.  
Both at the top level
in main.c.

The idea came from Algol68 but I do not know where it was originally invented.  longjmp() was used 
in the "exitsh"
function that got called on the exit command, default trap routine and a fault with no trap set.

It was also used when executing a subshell to avoid a fork and exec.  In this case the setjmp() was 
at top level
in the initial sh setup.

Hope this makes sense.  But these were two different uses.  One for error recovery and one to reset 
the execution environment
back to initial state.

Steve

[-- Attachment #2: Type: text/html, Size: 1116 bytes --]

             reply	other threads:[~2023-03-12 18:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12 18:23 Steve [this message]
2023-03-12 20:06 ` [TUHS] " Bakul Shah
2023-03-12 21:10   ` Paul Winalski
2023-03-16 20:35     ` Steve Bourne
2023-03-19 15:41 [TUHS] " Steve

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eac9d81f-5350-3094-9141-51456ec2c645@unixsh.com \
    --to=srb@unixsh.com \
    --cc=srb@acm.org \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).