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

Re: xtrace output sets ERRNO to 9 (EBADF)



2022-12-10 11:38:13 +0000, Daniel Shahaf:
> Bart Schaefer wrote on Fri, Dec 09, 2022 at 18:57:37 -0800:
> > diff --git a/Src/exec.c b/Src/exec.c
> > index 1810fca5e..a1059af5e 100644
> > --- a/Src/exec.c
> > +++ b/Src/exec.c
> > @@ -4336,10 +4336,13 @@ execcmd_exec(Estate state, Execcmd_params eparams,
> >      }
> >      }
> >      if (newxtrerr) {
> > +    int eno = errno;
> >      fil = fileno(newxtrerr);
> >      fclose(newxtrerr);
> >      xtrerr = oxtrerr;
> > +    /* Call zclose() to clean up internal tables, ignore EBADF */
> >      zclose(fil);
> > +    errno = eno;
> 
> This ignores any errors from the fileno() and fclose() calls as well, though?
[...]

Yes, though it's probably just  as well. Users use $ERRNO to
detect errors while doing operations they asked for.

In my case, I was doing:

ERRNO=0
files=(**/someglob(N))
if (( ERRNO )) ...

To check for errors during the glob expansion (wanting to make
sure that it doesn't missing anythin).

And finding that that glob expansion seemingly failed with EBADF
when run under zsh -x.

-- 
Stephane




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