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

Re: problems with 4.3.4 and Tru64



On Friday, May 11, 2007, at 12:56PM, "Peter Stephenson" <pws@xxxxxxx> wrote:
>Jordan Breeding <jordan.breeding@xxxxxxx> wrote:
>> Sorry to reply to myself, but I just paid a little bit more attention
>> and I figured out something else interesting.  The extra characters
>> that appear in the Terminal itself just before the output from echo
>> are the multibyte characters only, which are missing from the ${1}
>> being inserted into the Terminal title.  This part seems to be OS X
>> (Terminal.app) specific, as if I use zsh through a remote Terminal
>> the behaviour will differ (putty will display
>> h<character><character>lp in the title which I am assuming are just
>> the bytes that it is seeing).  Anyway, I will probably just not use
>> preexec() anymore for now.  Is there are way to display multibyte
>> characters as the base singlebyte character for the preexec string?
>> Or possible just replace multibyte characters with "?" or something,
>> just so my preexec would at least partially work?
>
>I'm glad things are working better... I'd be happy to put any generic
>workarounds in the shell itself, but it's probably too difficult for
>a terminal-specific problem, if that's what this is.
>
>As for detecting multibyte characters:  presumably all characters with
>codes over 127 are going to be multibyte, so it is possible to detect
>such a string:
>
>% foo="ä"
>% print $(( #foo ))
>
>228
>
>However, this just tests the first character; you'd have to loop over the
>entire string to do it which is a bit of a nuisance:
>
>  local line=${(%):-'\e]2;%n@%m %0~ (%30>...>'${1}'%>>%)\a'} char
>  local -a arr
>  arr=(${(s..)line})
>  integer i
>  for (( i = 1; i <= ${#arr}; i++)); do
>    char=${arr[i]}
>    (( #char > 127 )) && arr[i]="?"
>  done
>  print -n ${(j..)arr}
>
>(I did test this.)  I wonder if the shell is misinterpreting codes within
>the ${1} in
>
>  print -Pn "\e]2;%n@%m %0~ (%30>...>${1}%>>%)\a"
>
>?  If you just do print -P "<string>" from the command line with
>what was in ${1} does everything look OK?  (This is rather a long shot;
>I don't see how the shell could misplace characters like that, but
>it might be getting the handling of characters sufficiently wrong
>that the terminal driver is getting confused.)
>

Hmm, while it is kind of annoying to have to loop over the whole string, it isn't horrible, and it fixes the problems in both of my common terminals.  Also, I did your other test, ${1} is intact, so it definitely isn't the shell, it is the terminal programs.  Thanks for the help!

Jordan



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