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

Re: Feature request: ZSH_XTRACEFD variable



Peter Stephenson wrote on Sun, 03 May 2020 20:54 +0100:
> On Sun, 2020-05-03 at 06:43 +0200, Roman Perepelitsa wrote:
> > On Sun, May 3, 2020 at 2:07 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:  
> > > 
> > > I would have expected the unsetfn to be called for any special parameter.  
> > 
> > I've bumped into a similar issue with LC_* parameters. Here are a
> > couple of test cases:
> > 
> > 1.
> > 
> >   (
> >     unset -m 'LC_*|LANG'
> >     export LC_CTYPE='en_US.UTF-8'  # set this to any UTF-8 locale you have
> >     echo '\u276F'  # this works
> >     () {
> >       local LC_ALL=C  
> >     }  
> >     echo '\u276F'  # this doesn't work
> >   )
> > 
> > 2.
> > 
> >   (
> >     unset -m 'LC_*|LANG'
> >     LC_COLLATE=en_US.UTF-8
> >     x=(-a --b)
> >     print -r -- ${(on)x}  # this prints "-a --b"
> >     () {
> >       local LC_ALL= LC_COLLATE=C
> >       print -r -- ${(on)x}  
> >     }  
> >     print -r -- ${(on)x}  # this prints "--b -a"
> >   )  
> 
> Something like the attached?  Slightly but not extensively tested, so I could easily
> have missed something.

Confirmed it fixes Roman's case (1).

When LC_ALL is unset, the patch calls setlocale() for all known locale
categories (LC_*), not only for the ones that changed, like langsetfn()
and lcsetfn() do.  Is this a problem?  (I guess there was a reason
langsetfn() and lcsetfn() weren't implemented to begin with via the
if/else/for combination you just wrote.)

I had in mind a different approach: I thought of having scanendscope()
call unsetfn for (some subset of?) special parameters and having LANG
and LC_* use a custom unsetfn rather than the default one.  Even if
this is sensible, we can leave it for future work, though; I wouldn't
want to make the perfect the enemy of the good.

Cheers,

Daniel



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