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: Christoph Anton Mitterer
Subject: Re: any plans for command substitution that preserves trailing newlines?
Date: Wed, 26 Jan 2022 00:31:45 +0100
User-agent: Evolution 3.42.2-1

On Wed, 2021-06-02 at 11:04 -0400, Chet Ramey wrote:
> I would save the locale's variable values, use LC_CTYPE instead of
> LC_ALL,
> put the assignment to LC_CTYPE as its own command (though that's not
> strictly necessary), and make sure to restore the locale afterward.

I'd understand it as follows:

LC_CTYPE is the actual setting which would control how the encoding is
interpreted, when I strip the sentinel value.

Thus in principle, setting LC_CTYPE should be enough.


However:...

> Since you can't be sure what locale variables, if any, exist in the
> current
> shell's execution environment, it's simpler to save and restore them
> all.
> If you want, you can just check whether or not LC_CTYPE (or LC_ALL,
> depending on your preference) is set and save the original value.
> You already know which variables you've set in the script.

... LC_ALL might be set already, and override my own setting of
LC_CTYPE.

Thus it's best to set LC_ALL, which overrides all.

But I don't understand why I should need to check any other of the LC_*
vars?

They shouldn't matter with stripping of the character and when I re-set
LC_ALL to it's original state (including unset, if it was unset),...
then all others should be back in state as they were before?



Thanks again,
Chris.



reply via email to

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