From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HTML_MESSAGE,MAILING_LIST_MULTI,MIME_QP_LONG_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 27005 invoked from network); 12 Mar 2023 20:07:26 -0000 Received: from minnie.tuhs.org (50.116.15.146) by inbox.vuxu.org with ESMTPUTF8; 12 Mar 2023 20:07:26 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id CDA91415BC; Mon, 13 Mar 2023 06:07:20 +1000 (AEST) Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by minnie.tuhs.org (Postfix) with ESMTPS id 66D9B415B9 for ; Mon, 13 Mar 2023 06:07:08 +1000 (AEST) Received: by mail-qv1-xf29.google.com with SMTP id cz13so299455qvb.0 for ; Sun, 12 Mar 2023 13:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iitbombay-org.20210112.gappssmtp.com; s=20210112; t=1678651627; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=u7zh2HNdA6xRlQidEKuq3zCoM7RePKUwHESdYdhY3ME=; b=PWBIbIDt30j8m1zMG33pvlJOGTFSWJSQLe+xDtNVjEOkGzPcEUU8K2eN4dr7Au0bAF qCP5eM0BvaipaLg82CYcpG/Zs0VVIR6rQ29t8rHR0BdbsBXOtfluZd/Fa12Kj2I35Ywi 0VukqoDdKO+FPyXjpr0hp7MHKONaPXHItEpnvV1oiejH1yf6J2/Sq5eDOv6qJphR1pnl hVWWDQE11rCRdFtkgbuBKcPQ8Aye0ZTepMlr8dYp1y+BsClgsgSTBg8zSH8uAhKOgjbE MykCRVdjtJ4j2VPO2OWYkw1eEt0LJFYRYOV/Dtb/VdVADbwlC60rBlmuoTTMSJs2wyPU TatA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678651627; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u7zh2HNdA6xRlQidEKuq3zCoM7RePKUwHESdYdhY3ME=; b=qPuPa9BOyvNNLLLPAq5tGYvryuuW3aJ5DMuTnOFeTTo+abJSazJJCZEhk3sq7ovsoM KJtpPCC/2YWxk9q48s31ZuvPNhkKYornFJa5A7qdD976XKyPfm4liJObpHZQQ/t5fzS8 NaHd7gT+HTnlsUbhbz6/PxHAHKJQXSnNLteBH6jAKUm+7JI5toA1plLx+/ScC1Ahyw28 1gELS38PEfs4xYpe6g1tHZYCQlp2NBN3A4lTZ3+aD0ZFOYDd4NXcU94hazq9JoVXMNrp xrTmRuj2mHFKTmuGtvrTKAW5yCmYj0N+EBtL/sQznq6bawRnLR2Qe3jEObE/S3A5WVlF NzmQ== X-Gm-Message-State: AO0yUKUrZYTIR4SAq203rJA138TFZ8vVOL/zehkCknY4D+vAzmkBZpSc /HhJ0XNcAFRo6FlyV3MSFgmUCurvYFcVPY5LOf8= X-Google-Smtp-Source: AK7set+P3rjsj0k/NTSWx4+69oi+0J5BIlSV+jiB+JNo2KBRY6AeyJFNs357jgQPMjbktdTR8bx2xA== X-Received: by 2002:a05:6214:5019:b0:56b:f28a:ee2d with SMTP id jo25-20020a056214501900b0056bf28aee2dmr16142158qvb.5.1678651627276; Sun, 12 Mar 2023 13:07:07 -0700 (PDT) Received: from smtpclient.apple (107-215-223-229.lightspeed.sntcca.sbcglobal.net. [107.215.223.229]) by smtp.gmail.com with ESMTPSA id y26-20020a37f61a000000b007436d0c60ecsm3958092qkj.65.2023.03.12.13.07.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Mar 2023 13:07:06 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-D3180B36-1AE9-4AEA-865F-A50F91267A53 Content-Transfer-Encoding: 7bit From: Bakul Shah Mime-Version: 1.0 (1.0) Date: Sun, 12 Mar 2023 13:06:55 -0700 Message-Id: <8D38925D-428C-4346-876A-9689BD41F375@iitbombay.org> References: In-Reply-To: To: srb@acm.org X-Mailer: iPad Mail (20D67) Message-ID-Hash: 3JOTTPDOP4Q7HE2HUGH6JCHLJN25YYV4 X-Message-ID-Hash: 3JOTTPDOP4Q7HE2HUGH6JCHLJN25YYV4 X-MailFrom: bakul@iitbombay.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: tuhs@tuhs.org X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] Re: GOTO etc List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --Apple-Mail-D3180B36-1AE9-4AEA-865F-A50F91267A53 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Perhaps you=E2=80=99re talking about non-local GOTOs in Algol68, where you c= an jump from a nested procedure to a label in a lexically enclosing procedur= e. Pascal has this too. C has no nested procedures but its setjmp/longjmp is= much more powerful (& dangerous). Though both can be used to the top level o= f a REPL or to jump to a known place after an error. > On Mar 12, 2023, at 11:24 AM, Steve wrote: >=20 > =EF=BB=BF Dennis added setjmp() and longjmp() so the shell could handle er= rors in a reasonable way. > There are two places where setjmp was used in the original shell (7th edit= ion) code as I recall. Both at the top level > in main.c. >=20 > The idea came from Algol68 but I do not know where it was originally inven= ted. longjmp() was used in the "exitsh" > function that got called on the exit command, default trap routine and a f= ault with no trap set. >=20 > It was also used when executing a subshell to avoid a fork and exec. In t= his case the setjmp() was at top level > in the initial sh setup. >=20 > Hope this makes sense. But these were two different uses. One for error r= ecovery and one to reset the execution environment > back to initial state. >=20 > Steve --Apple-Mail-D3180B36-1AE9-4AEA-865F-A50F91267A53 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Per= haps you=E2=80=99re talking about non-local GOTOs in Algol68, where y= ou can jump from a nested procedure to a label in a lexically enclosi= ng procedure. Pascal has this too. C has no nested procedures but its setjmp= /longjmp is much more powerful (& dangerous). Though both can be used to= the top level of a REPL or to jump to a known place after an error.

On Mar 12, 2023, at 11:24 AM, S= teve <srb@unixsh.com> wrote:

=EF=BB=BF =20 =20 =20 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.  O= ne for error recovery and one to reset the execution environment
back to initial state.

Steve
=20
= --Apple-Mail-D3180B36-1AE9-4AEA-865F-A50F91267A53--