zsh-workers
 help / color / mirror / code / Atom feed
From: Matthew Martin <phy1729@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: ERRNO is unset until set
Date: Thu, 28 Apr 2022 09:07:07 -0500	[thread overview]
Message-ID: <Ymqfi9/+1EsEORnA@CptOrmolo.darkstar> (raw)
In-Reply-To: <CA+rB6G+8mEDS=iZztLCTbtK99MqmaG9chi_GWANOQ9HN_U1uMQ@mail.gmail.com>

On Thu, Apr 28, 2022 at 08:18:58AM -0500, Jim wrote:
> Hi,
> 
> Man page zshmodules(5.8) seems to be missing status information in module
> zsh/system for builtins sysopen and sysseek.  All the other builtins have
> some
> kind of statement for return status. I believe status 0 is success and 1
> would
> be an error of some kind for both. Don't know if there are other error
> numbers
> or if the parameter ERRNO is used.

While looking at copying the text under syswrite for sysopen and
sysseek, I ran a short test for ERRNO.
    > zmodload zsh/system; syswrite -o 3 test; print $? $ERRNO
    2
As Mikael pointed out on IRC, setting ERRNO once is sufficient for ERRNO
to reflect errno. The patch below lets ERRNO reflect errno without
setting ERRNO first.

diff --git a/Src/params.c b/Src/params.c
index 27ea82298..c144c25c3 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -297,7 +297,7 @@ static initparam special_params[] ={
 #define NULL_GSU BR((GsuScalar)(void *)NULL)
 #define IPDEF1(A,B,C) {{NULL,A,PM_INTEGER|PM_SPECIAL|C},BR(NULL),GSU(B),10,0,NULL,NULL,NULL,0}
 IPDEF1("#", pound_gsu, PM_READONLY_SPECIAL),
-IPDEF1("ERRNO", errno_gsu, PM_UNSET),
+IPDEF1("ERRNO", errno_gsu, 0),
 IPDEF1("GID", gid_gsu, PM_DONTIMPORT | PM_RESTRICTED),
 IPDEF1("EGID", egid_gsu, PM_DONTIMPORT | PM_RESTRICTED),
 IPDEF1("HISTSIZE", histsize_gsu, PM_RESTRICTED),


  parent reply	other threads:[~2022-04-28 14:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28 13:18 Possible missing status info for builtins sysopen and sysseek in zsh/system module Jim
2022-04-28 13:50 ` Jim
2022-04-29  9:47   ` Jim
2022-04-28 14:07 ` Matthew Martin [this message]
2022-04-28 14:16   ` ERRNO is unset until set Matthew Martin
2022-04-29  6:44     ` Bart Schaefer
2022-04-29 10:00       ` Mikael Magnusson
2022-04-29 17:02         ` Bart Schaefer
2022-04-29 17:08           ` Daniel Shahaf
2022-04-29 17:19             ` Bart Schaefer
2022-04-29 17:13           ` grepping the archives (was: Re: ERRNO is unset until set) Daniel Shahaf
2022-04-30  0:45             ` Daniel Shahaf

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=Ymqfi9/+1EsEORnA@CptOrmolo.darkstar \
    --to=phy1729@gmail.com \
    --cc=zsh-workers@zsh.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).