help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: any plans for command substitution that preserves trailing newlines?


From: Alex fxmbsw7 Ratchev
Subject: Re: any plans for command substitution that preserves trailing newlines?
Date: Wed, 26 Jan 2022 18:52:01 +0100

On Wed, Jan 26, 2022, 18:49 Christoph Anton Mitterer <calestyo@scientia.org>
wrote:

> On Wed, 2022-01-26 at 09:29 -0500, Chet Ramey wrote:
> > That's the reason you should be careful -- setting LC_ALL may have
> > other
> > unwanted side effects, such as behavior controlled by LC_MESSAGES or
> > LC_NUMERIC. You always need to understand the context.
> >
> > As long as you set LC_ALL only for the scope of the assignment that
> > strips
> > the trailing byte, you should be able to avoid those side effects.
>
> Sure that's anyway clear,... either restoring the old value afterwards,
> or restoring it being unset (if it was so before).
>
>
> > But to
> > do that you have to make sure you save and restore all the locale
> > variables (or use a function and local variables and let bash do it
> > for
> > you), especially if LC_ALL was previously unset.
>
> That's however what I don't understand...
>
> Why all the others, if I never touch them?
>
>
>
> $ LANG="en_UK.UTF-8"
> $ LC_TIME="en_US.UTF-8"
> $ set | grep -E '(^LC_|^LANG)'
> LANG=en_UK.UTF-8
> LC_TIME=en_US.UTF-8
>
> # that's the "old" state, then I set LC_ALL
>
> $ LC_ALL=C
> $ set | grep -E '(^LC_|^LANG)'
> LANG=en_UK.UTF-8
> LC_ALL=C
> LC_TIME=en_US.UTF-8
>
> # intermediate state, then I unset it again:
>
> $ unset LC_ALL
> $ set | grep -E '(^LC_|^LANG)'
> LANG=en_UK.UTF-8
> LC_TIME=en_US.UTF-8
> $
>
> Back to old state,... none of the other vars were changed.
>
> So if I just touch LC_ALL, why do I "have to make sure you save and
> restore **all** the locale variables"?
>

if u set the vars singularly to different, setting ALL will reset them , ..

>
> Thanks,
> Chris.
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]