Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ERRNO is unset until set



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




Messages sorted by: Reverse Date, Date, Thread, Author