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

Re: $var not expanded in ${x?$var}



2024-02-21 11:52:51 -0800, Bart Schaefer:
> On Wed, Feb 21, 2024 at 11:45 AM Stephane Chazelas
> <stephane@xxxxxxxxxxxx> wrote:
> >
> > 2024-02-20 20:44:47 -0800, Bart Schaefer:
> > [...]
> > > +         case 'S':
> > > +             str = va_arg(ap, const char *);
> > > +             fprintf(file, "%s", str);
> > > +             break;
> > [...]
> >
> > I suspect there's something wrong with that as it could not
> > possibly work for ${var?$'\0'}.
> 
> What would you expect it to do?  You can't have it both raw and not
> raw.

I would expect it to write the NUL character ('\0') to stderr,
which fprintf couldn't do as it takes a NUL-delimited string.

With the patch applied, I get:

$ (: ${1?$'a\0b'}) |& sed -n l
zsh: 1: a\203 b$

Maybe needs some unmetafy + fwrite.

-- 
Stephane




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