Should the readline *-meta flags reset when $LANG changes?
One of our users complained that bash-5.1 on Solaris 11.4, when started with LANG=C does not allow Unicode input after changing LANG to a UTF-8 locale until bash is restarted. I've confirmed this is the default behavior, but can be overridden by manually changing the readline output-meta flag from off to on: % env LANG=C bash bash-5.1$ echo \360\237\220\233 π bash-5.1$ setenv LANG en_US.UTF-8 bash: setenv: command not found bash-5.1$ export LANG=en_US.UTF-8 bash-5.1$ echo \360\237\220\233 π bash-5.1$ bash bash-5.1$ echo π π bash-5.1$ exit exit bash-5.1$ echo \360\237\220\233 π bash-5.1$ bind 'set output-meta on' bash-5.1$ echo π π (In all cases, the bug character was pasted the same way in a GNOME terminal, bash just displayed it differently in the input command line. Our user was actually trying it with Chinese text, not emoji, but the results were the same.) The documentation specifies that for output-meta "The default is βoffβ, but Readline will set it to βonβ if the locale contains eight-bit characters." The convert-meta & input-meta options are similarly documented as locale dependent. But none of them say what is expected to happen when the locale changes after initialization - is the behavior we're seeing expected or are these variables supposed to be automatically updated when the locale changes? -- -Alan Coopersmith- alan.coopersm...@oracle.com Oracle Solaris Engineering - https://blogs.oracle.com/solaris
Re: Should the readline *-meta flags reset when $LANG changes?
On 8/8/22 5:48 PM, Alan Coopersmith wrote: > One of our users complained that bash-5.1 on Solaris 11.4, when started > with LANG=C does not allow Unicode input after changing LANG to a UTF-8 > locale until bash is restarted. Thanks for the report. The eight-bit settings are auto-set once, when readline is first called, but I'll see if it makes sense to change them on every call. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: Should the readline *-meta flags reset when $LANG changes?
On 8/9/22 10:45 AM, Chet Ramey wrote: > On 8/8/22 5:48 PM, Alan Coopersmith wrote: >> One of our users complained that bash-5.1 on Solaris 11.4, when started >> with LANG=C does not allow Unicode input after changing LANG to a UTF-8 >> locale until bash is restarted. > > Thanks for the report. The eight-bit settings are auto-set once, when > readline is first called, but I'll see if it makes sense to change them > on every call. It's fairly easy. I'll make the change for the next devel branch push and bash-5.2-rc3. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: Should the readline *-meta flags reset when $LANG changes?
On 8/9/22 08:15, Chet Ramey wrote: On 8/9/22 10:45 AM, Chet Ramey wrote: On 8/8/22 5:48 PM, Alan Coopersmith wrote: One of our users complained that bash-5.1 on Solaris 11.4, when started with LANG=C does not allow Unicode input after changing LANG to a UTF-8 locale until bash is restarted. Thanks for the report. The eight-bit settings are auto-set once, when readline is first called, but I'll see if it makes sense to change them on every call. It's fairly easy. I'll make the change for the next devel branch push and bash-5.2-rc3. Thanks for the quick investigation! -- -Alan Coopersmith- alan.coopersm...@oracle.com Oracle Solaris Engineering - https://blogs.oracle.com/solaris
Re: Should the readline *-meta flags reset when $LANG changes?
2022εΉ΄8ζ10ζ₯(ζ°΄) 2:07 Alan Coopersmith : > >> Thanks for the report. The eight-bit settings are auto-set once, when > >> readline is first called, but I'll see if it makes sense to change them > >> on every call. > > > > It's fairly easy. I'll make the change for the next devel branch push and > > bash-5.2-rc3. > > Thanks for the quick investigation! Does it mean custom values of these readline variables will be lost every time LANG or LC_{CTYPE,ALL} is changed even if a user or program intentionally sets them up? We often temporarily change LANG or LC_* to perform some binary operations [such as counting the number of bytes of data and safely removing trailing x from the result of $(command;printf x)]. If that becomes to affect the user settings of readline variables, do we need to save and restore these readline variables every time we touch LANG or LC_*? This would become a serious overhead because it would typically involve a subshell: save=$(bind -v). Also, if these readline variables would be cleared every time, it seems to me that these readline variables would be effectively unconfigurable and would lose the point of their existence, or we could not touch LANG or LC_* at all after the initial setup. Is it possible to make three states of the readline variables, `on/off/auto', and make `auto' the default, which determines the behavior depending on the current locale? In this case, the actual behavior on/off can be cached in another variable and can be updated on the change of LANG/LC_* when the readline variable has the value `auto'. -- Koichi