Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [Bug] Exiting shell from function called by trap handler always produces status 0
- X-seq: zsh-workers 43662
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: [Bug] Exiting shell from function called by trap handler always produces status 0
- Date: Tue, 09 Oct 2018 13:39:11 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:references:date :in-reply-to:subject; s=fm1; bh=6hqYweGFwpEfziR9/T+PgZiTzLXGVLwu MT2ZPVBfdtQ=; b=HX98fHX/e4X9BwI7kAHp+fN9kyh0ojwE+hm6F6Aq1qgCsWwD EEMemL8naynCr2Ubscy4goQvzcIOFrjQyQe/l6xXY6M7U7/MLeErhXeIVn3wd9dJ ZRph2La5eC4TKmiF2jTXj8xhWVcmcEbBDC3SJiYOb2DzZzQMoe+GXav/4c+8KL9h PEffPKSxn9DGnw9CcukLFCCoa6AJJUQ7/lTStypleh6VOmO/Q1YOut0npPeUukvD Tmy4rVXiPz3BUL9XgZZLQAaR/S6M01DrVPDGuYWdh9sZmWN8BL4ADiXgNheCbwJJ 9JbRL2ubuKyJGIgdhhNCHr0vqzrpoe97iN/98w==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=6hqYweGFwpEfziR9/T+PgZiTzLXGVLwuMT2ZPVBfd tQ=; b=mkQTm144HYwIWGncX7Gzigr5oSQq1m+04PmllVNgm9WbPwi0Khg2Zo4bE I8MJHAWBjoLTqMQQphKuvDVo8bkTmpRiIdUu5hb94t+Gp5K601KMEG3rymhG+Xy6 N/ppWOK8OW/K7V+ngVqdBI2UuZuE7h0ZTA+If+NbxEF/GJYkvejMOsFP256va1N5 4AOyObMTwgOC6iyvqWEkb9o20NSmpglu6kQ2jbNdP5/xJoOiVfY1BCddq4KTHPQu CYi9v0wn1gFJZSxHrsMb1D5zIFhusVxzfXOZoLtxB2YgnYbkCx/BNmtBJ44bodnq LOQXqdagSdo3/VYOSna7O8nWkqYEQ==
- In-reply-to: <20181009131646eucas1p2eb07d8fa34e97de25db60d6a56c584a4~b8x2n0O1S2407324073eucas1p2z@eucas1p2.samsung.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20181009012624epcas1p44f2ae223f663713a980af4be735e5a3f@epcas1p4.samsung.com> <a5934536-7982-c434-d98d-2c07d66b0739@inlv.org> <20181009084918eucas1p27dedda10d51beb773ba9175967912d2c~b5IUtvcVK3037630376eucas1p2R@eucas1p2.samsung.com> <205ea5e4-4dc9-2ebf-9437-0822195e1a9a@inlv.org> <20181009131646eucas1p2eb07d8fa34e97de25db60d6a56c584a4~b8x2n0O1S2407324073eucas1p2z@eucas1p2.samsung.com>
Peter Stephenson wrote on Tue, 09 Oct 2018 14:16 +0100:
> +++ b/Src/builtin.c
> @@ -5698,6 +5699,42 @@ checkjobs(void)
> +/*
> + * Exit status if explicitly set by an exit command.
> + * This is complicated by the fact the exit command may be within
> + * a function whose state we need to unwind (exit_pending set
> + * and the exit will happen up the stack), or we may need to execute
> + * additional code such as a trap after we are committed to exiting
> + * (shell_exiting and the exit will happen down the stack).
> + *
> + * It's lucky this is all so obvious there is no possibility of any
> + * bugs. (C.f. the entire rest of the shell.)
> + */
> +/**/
> +int exit_val;
Shouldn't this variable be initialized?
A function-local 'static' (below) is implicitly initialized to 0, but
a non-static global is not implicitly initialized.
> +
> +/*
> + * Actually exit the shell, working out the status locally.
> + * This is exit_val if "exit" has explicitly been called in the shell,
> + * else lastval.
> + */
> +
> @@ -5709,7 +5746,6 @@ int shell_exiting;
> mod_export void
> zexit(int val, int from_where)
> {
> - static int exit_val;
> /*
> * Don't do anything recursively: see below.
> * Do, however, update exit status --- there's no nesting,
Messages sorted by:
Reverse Date,
Date,
Thread,
Author