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

Re: [^ax-y] doesn't work but [^x-ya] does



Hello,
a minimal test case to investigate 1c41f98 that bisect pointed to. Dash
"-" in character [range] is treated literally. The patch is:

-                   if (!in_brace_param)
-                       in_brace_param = bct;
+                   if (!in_brace_param) {
+                       if ((in_brace_param = bct))
+                           seen_brct = 0;
+                   }

The result of script is (first line – not matched, no ^G etc.
replacement):

    this module ^GON-THE-FLY^_, without list restart
    this module ONTHEFLY, without list restart

Script contains alternative [^x-ya] pattern that works (and [^ax-y] that
doesn't).

-- 
  Sebastian Gniazdowski
  psprint3@xxxxxxxxxxxx
#!/usr/local/bin/zsh-5.3.1

typeset -gAH ZUI
ZUI[PLUS]=$'\21'
ZUI[COLOR_END]=$'\037'

button1='this module ON-THE-FLY, without list restart'  # not working
button2='this module ONTHEFLY, without list restart'    # working

local -A colormap
colormap=( "" "" )

translate_color_marks() {
    # Working
    # disp_list=( "${disp_list[@]//(#b)([$'\03'-$'\010'$'\022'])(${ZUI[PLUS]}([$'\011'-$'\020'])|)([^$'\03'-$'\010'${ZUI[COLOR_END]}]#)${ZUI[COLOR_END]}/${colormap[${match[1]}]}${colormap[${match[3]}]}$match[4]$RESET}" )
    # Not working
    disp_list=( "${disp_list[@]//(#b)([$'\03'-$'\010'$'\022'])(${ZUI[PLUS]}([$'\011'-$'\020'])|)([^${ZUI[COLOR_END]}$'\03'-$'\010']#)${ZUI[COLOR_END]}/${colormap[${match[1]}]}${colormap[${match[3]}]}$match[4]$RESET}" )
}

disp_list=( "$button1" "$button2" )
translate_color_marks
print -rl -- "${disp_list[@]}" "---" >> ~/result.txt


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