Re: Bug in mksh when counting line length
Hi Thorsten, Hope this clears it up. Massively. Thank you! Best regards, John
Re: Bug in mksh when counting line length
Hi John, >> no, you’ve discovered you did not read the manpage ☺ > > I did read it, but I didn't understand it...! Adding the \r and surrounding > all escape sequences with \1 solves my problem, but I don't understand why > (?). Ah okay. Basically, the first \1\r says: make the \1 into a marker. After that, \1 switches between “counted / visible” and “not counted / invisible”. So, in an example: $'\1\r\1\033[1m\1$PWD\1\033[0m\1 % ' \1\r - define marker \1\033[1m\1 - invisible part $PWD - visible part \1\033[0m\1 - invisible part % - visible part Hope this clears it up. By the way, use just $? instead of $(echo $?) ☺ or look how dot.mkshrc handles that (it shows $?| if $?≠0). bye, //mirabilos -- 11:56⎜«liwakura:#!/bin/mksh» also, i wanted to add mksh to my own distro │ i was disappointed that there is no makefile │ but somehow the Build.sh is the least painful built system i've ever seen │ honours CC, {CPP,C,LD}FLAGS properly │ looks cleary like done by someone who knows what they are doing
Re: Bug in mksh when counting line length
Hi Thorsten, and thanks for your solution! no, you’ve discovered you did not read the manpage ☺ I did read it, but I didn't understand it...! Adding the \r and surrounding all escape sequences with \1 solves my problem, but I don't understand why (?). Best regards, John
Re: Bug in mksh when counting line length
Hi John, > I think I've discovered a bug in mksh. According to the man page: no, you’ve discovered you did not read the manpage ☺ PS1 The primary prompt for interactive shells. Parameter, com- […] Since backslashes and other special characters may be inter- preted by the shell, to set PS1 either escape the backslash itself or use double quotes. The latter is more practical. This is a more complex example, avoiding to directly enter special characters (for example with ^V in the emacs editing mode), which embeds the current working directory, in re- verse video (colour would work, too), in the prompt string: x=$(print \\001) # otherwise unused char PS1="$x$(print \\r)$x$(tput so)$x\$PWD$x$(tput se)$x> " Due to a strong suggestion from David G. Korn, mksh now also supports the following form: PS1=$'\1\r\1\e[7m\1$PWD\1\e[0m\1> ' > It turns out that the invisible ANSI escape sequences count towards > the length of the line! This means that mksh "breaks" the line much > earlier than necessary, making it difficult to use colors in the > prompt. Yes, of course. It does not “know” that those are ANSI escapes, after all (not all terminals use them, you know). That is the reason for the above mechanism, from ksh88, to exist. See also: http://www.mirbsd.org/mksh-faq.htm#ps1conv bye, //mirabilos -- “The final straw, to be honest, was probably my amazement at the volume of petty, peevish whingeing certain of your peers are prone to dish out on d-devel, telling each other how to talk more like a pretty princess, as though they were performing some kind of public service.” (someone to me, privately)
Bug in mksh when counting line length
Hello, I think I've discovered a bug in mksh. According to the man page: In these editing modes, if a line is longer than the screen width (see the COLUMNS parameter), a ‘>’, ‘+’ or ‘<’ character is displayed in the last column indicating that there are more characters after, before and after, or before the current position, respectively. The line is scrolled horizontally as necessary. Now, my prompt looks something like this: PS1=$'\e[38;5;250m[$(echo $?)] \e[38;5;244m$(pwd)\e[0;0m $' It turns out that the invisible ANSI escape sequences count towards the length of the line! This means that mksh "breaks" the line much earlier than necessary, making it difficult to use colors in the prompt. Is there any way to disable this behavior or to customize it? Happy new year, John