Ben Spencer <dangerous....@gmail.com> writes: > Hi, > > On Tue, Sep 14, 2010 at 01:24:04AM +0400, Anonymous wrote: >> >> While porting the script to FreeBSD I've made a few changes. >> >> Can someone test them on non-ancient Linux? > > This: > > # parse C-style backslash sequences by default > if [ "$(echo -e foo)" = foo ]; then > echo() { builtin echo -e "$@"; } > fi
Along with following sed(1) line it's intended to work around `echo' builtin from dash acting like printf(1). s/\\([[:digit:]]+)/\\0\1/g Rather than calling sed(1) for every `echo' I've descided to place it only where it's needed as an optimization, i.e. only when `string-to-bytes' maybe used. BTW, bash at least on FreeBSD treats only \0XXX (not \XXX) sequences as character codes. I wonder if a command like `windows' ever worked on it, e.g. with window titles in japanese, not displaying smth like > windows 0+\343\203\213\343\202\263\343\203\213\343\202\263\345\213\225\347\224\273(9) - Conkeror 1*xterm > > Seems to interact badly with the sed calls in wait_result (which I > believe are intended to deal with literal \ns). Nah, it turns out I've missed the case when there are *quoted* doublequotes at the end of line, e.g. \" > > For example: > > b...@arctor:~$ stumpish > Welcome to the STUMPwm Interactive SHell. > Type commands for a list of commands. >> echo "hello" > "hello\ Can you test below diff? %% @@ -57,12 +57,11 @@ wait_result () echo "$RESULT" | sed -E 's/[^"\\n]+"// - s/"[[:space:]]*$// + /^"[[:space:]]*$/d s/([^\\])\\n/\1\ /g s/\\(["\\n])/\1/g - s/\^([*[:digit:]]+|[Bbn])//g' | - sed '/^[[:space:]]*$/d' + s/\^([*[:digit:]]+|[Bbn])//g' } send_cmd () %% As for newlines, there is one more bug > echo \\n n > echo "\\n" " " that should be addressed by below diff %% @@ -58,7 +58,7 @@ wait_result () echo "$RESULT" | sed -E 's/[^"\\n]+"// /^"[[:space:]]*$/d - s/([^\\])\\n/\1\ + s/(^|[^\\])\\n/\1\ /g s/\\(["\\n])/\1/g s/\^([*[:digit:]]+|[Bbn])//g' %% _______________________________________________ Stumpwm-devel mailing list Stumpwm-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/stumpwm-devel