From e3e37114832539fb915f0c44125eae492d7b1491 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sat, 25 Sep 1999 11:12:08 +0000 Subject: zsh-workers/8044 --- Completion/Base/_regex_arguments | 9 ++--- Completion/Debian/_apt | 73 ++++++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/Completion/Base/_regex_arguments b/Completion/Base/_regex_arguments index bbf8a2e5b..a89bb19b4 100644 --- a/Completion/Base/_regex_arguments +++ b/Completion/Base/_regex_arguments @@ -247,16 +247,17 @@ _ra_gen_func () { } _ra_gen_parse_state () { - local actions i + local actions i p test='if' for index in $=tbl[$state]; do if [[ "$pattern[$index]" != "[]" ]]; then + p="$pattern[$index]$lookahead[$index]*" if [[ -z "$guard[$index]" ]]; then print -lr - \ - "$test [[ \$_ra_right = $pattern[$index]$lookahead[$index]* ]]" + "$test [[ \$_ra_right = \${~:-${(qqqq)p}} ]]" else print -lr - \ - "$test [[ \$_ra_right = $pattern[$index]$lookahead[$index]* ]] && {" \ + "$test [[ \$_ra_right = \${~:-${(qqqq)p}} ]] && {" \ "$guard[$index]" \ "}" fi @@ -365,7 +366,7 @@ _regex_arguments () { if [[ -d "$cache_dir" && -w "$cache_dir" ]]; then print -lr - \ - 'if [[ $# -eq '$#' && "$*" = '"${*:q}"' ]]; then' \ + 'if [[ $# -eq '$#' && "$*" = '"${(qqqq)*}"' ]]; then' \ "$funcdef" \ 'true; else false; fi' > "${cache_file}.$HOST.$$" source "${cache_file}.$HOST.$$" "$@" diff --git a/Completion/Debian/_apt b/Completion/Debian/_apt index f4ed69a45..503d42a56 100644 --- a/Completion/Debian/_apt +++ b/Completion/Debian/_apt @@ -54,7 +54,7 @@ _apt_arguments () { case \$current_option in ${comp_hasarg}esac" - local short_seq false true bool bool_prefix intlevel word word1 nul + local short_seq false true bool bool_prefix intlevel word word1 nul qnul local comp_bool comp_intlevel comp_configfile comp_arbitem comp_long comp_opt local regex_short regex_long regex_all @@ -73,6 +73,7 @@ _apt_arguments () { word=$'[^\0]#\0' word1=$'[^\0]##\0' nul=$'\0' + qnul="\$'\\0'" comp_bool='compadd "$expl_bool[@]" '"$bool" comp_intlevel= #"_message 'intlevel'" @@ -119,7 +120,7 @@ _describe -o option tmp2 -- tmp3 -S=' ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)short_hasarg})$nul"/ - -'_apt_consume_short ${match[1][-2]}; current_option=${canonicalize[-${${match[1]%$nul}[-1]}]}' + -'_apt_consume_short ${match[1][-2]}; current_option=${canonicalize[-${${match[1]%'$qnul'}[-1]}]}' /"$word"/ :"$comp_hasarg" \| /"(${(j:|:)short_hasarg})="/ -'_apt_consume_short ${match[1][-2]}; current_option=${canonicalize[-${${match[1]%=}[-1]}]}' @@ -130,17 +131,17 @@ _describe -o option tmp2 -- tmp3 -S=' if (( $#short_bool )); then regex_short=("$regex_short[@]" /"$short_seq(${(j:|:)short_bool})($nul(${(j:|:)bool})|(${(j:|:)bool})|)$nul"/ - -"_apt_consume_short \${match[1]%%($nul(${(j:|:)bool})|(${(j:|:)bool})|)$nul}" \| + -'_apt_consume_short ${match[1]%%('$qnul'('${(j:|:)bool}')|('${(j:|:)bool}')|)'$qnul'}' \| /"$short_seq(${(j:|:)short_bool})="/ - -"_apt_consume_short \${match[1]%=}" + -'_apt_consume_short ${match[1]%=}' \( /"$word1"/ :"$comp_bool" \| /"$nul"/ /"$word"/ :"$comp_bool" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)short_bool})="/ - -"_apt_consume_short \${match[1][-2]}" + -'_apt_consume_short ${match[1][-2]}' \( /"$word1"/ :"$comp_bool" \| /"$nul"/ /"$word"/ :"$comp_bool" \) \| /"(${(j:|:)short_bool})$nul"/ - -"_apt_consume_short \${match[1][-2]}" + -'_apt_consume_short ${match[1][-2]}' /"((${(j:|:)bool})$nul|)"/ :"$comp_bool" \| ) fi @@ -148,17 +149,17 @@ _describe -o option tmp2 -- tmp3 -S=' if (( $#short_intlevel )); then regex_short=("$regex_short[@]" /"$short_seq(${(j:|:)short_intlevel})($nul$intlevel|$intlevel|)$nul"/ - -"_apt_consume_short \${match[1]%%($nul$intlevel|$intlevel|)$nul}" \| + -'_apt_consume_short ${match[1]%%'"($qnul$intlevel|$intlevel|)$qnul"'}' \| /"$short_seq(${(j:|:)short_intlevel})="/ - -"_apt_consume_short \${match[1]%=}" + -'_apt_consume_short ${match[1]%=}' \( /"$word1"/ :"$comp_intlevel" \| /"$nul"/ /"$word"/ :"$comp_intlevel" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)short_intlevel})="/ - -"_apt_consume_short \${match[1][-2]}" + -'_apt_consume_short ${match[1][-2]}' \( /"$word1"/ :"$comp_intlevel" \| /"$nul"/ /"$word"/ :"$comp_intlevel" \) \| /"(${(j:|:)short_intlevel})$nul"/ - -"_apt_consume_short \${match[1][-2]}" + -'_apt_consume_short ${match[1][-2]}' /"($intlevel$nul|)"/ :"$comp_intlevel" \| ) fi @@ -166,15 +167,15 @@ _describe -o option tmp2 -- tmp3 -S=' if (( $#short_configfile )); then regex_short=("$regex_short[@]" /"$short_seq(${(j:|:)short_configfile})(=|)"/ - -"_apt_consume_short \${match[1]%=}" + -'_apt_consume_short ${match[1]%=}' \( /"$word1"/ :"$comp_configfile" \| /"$nul"/ /"$word"/ :"$comp_configfile" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)short_configfile})$nul"/ - -"_apt_consume_short \${match[1][-2]}" + -'_apt_consume_short ${match[1][-2]}' /"$word"/ :"$comp_configfile" \| /"(${(j:|:)short_configfile})="/ - -"_apt_consume_short \${match[1][-2]}" + -'_apt_consume_short ${match[1][-2]}' \( /"$word1"/ :"$comp_configfile" \| /"$nul"/ /"$word"/ :"$comp_configfile" \) \| ) fi @@ -182,15 +183,15 @@ _describe -o option tmp2 -- tmp3 -S=' if (( $#short_arbitem )); then regex_short=("$regex_short[@]" /"$short_seq(${(j:|:)short_arbitem})(=|)"/ - -"_apt_consume_short \${match[1]%=}" + -'_apt_consume_short ${match[1]%=}' \( /"$word1"/ :"$comp_arbitem" \| /"$nul"/ /"$word"/ :"$comp_arbitem" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)short_arbitem})$nul"/ - -"_apt_consume_short \${match[1][-2]}" + -'_apt_consume_short ${match[1][-2]}' /"$word"/ :"$comp_arbitem" \| /"(${(j:|:)short_arbitem})="/ - -"_apt_consume_short \${match[1][-2]}" + -'_apt_consume_short ${match[1][-2]}' \( /"$word1"/ :"$comp_arbitem" \| /"$nul"/ /"$word"/ :"$comp_arbitem" \) \| ) fi @@ -198,18 +199,18 @@ _describe -o option tmp2 -- tmp3 -S=' if (( $#long_hasarg )); then regex_long=("$regex_long[@]" /"(${(j:|:)long_hasarg})$nul"/ - -"_apt_consume_long \${match[1]%$nul}; current_option=\${canonicalize[--\${match[1]%$nul}]}" + -'_apt_consume_long ${match[1]%'$qnul'}; current_option=${canonicalize[--${match[1]%'$qnul'}]}' /"$word"/ :"$comp_hasarg" \| /"(${(j:|:)long_hasarg})="/ - -"_apt_consume_long \${match[1]%=}; current_option=\${canonicalize[--\${match[1]%=}]}" + -'_apt_consume_long ${match[1]%=}; current_option=${canonicalize[--${match[1]%=}]}' \( /"$word1"/ :"$comp_hasarg" \| /"$nul"/ /"$word"/ :"$comp_hasarg" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)long_hasarg})$nul"/ - -"_apt_consume_long \${match[1]%$nul}; current_option=\${canonicalize[--\${match[1]%$nul}]}" + -'_apt_consume_long ${match[1]%'$qnul'}; current_option=${canonicalize[--${match[1]%'$qnul'}]}' /"$word"/ :"$comp_hasarg" \| /"(${(j:|:)long_hasarg})="/ - -"_apt_consume_long \${match[1]%=}; current_option=\${canonicalize[--\${match[1]%=}]}" + -'_apt_consume_long ${match[1]%=}; current_option=${canonicalize[--${match[1]%=}]}' \( /"$word1"/ :"$comp_hasarg" \| /"$nul"/ /"$word"/ :"$comp_hasarg" \) \| ) fi @@ -217,18 +218,18 @@ _describe -o option tmp2 -- tmp3 -S=' if (( $#long_bool )); then regex_long=("$regex_long[@]" /"(${(j:|:)long_bool})="/ - -"_apt_consume_long xxx \${match[1]%=}" + -'_apt_consume_long ${match[1]%=}' \( /"$word1"/ :"$comp_bool" \| /"$nul"/ /"$word"/ :"$comp_bool" \) \| /"(${(j:|:)long_bool})$nul"/ - -"_apt_consume_long \${match[1]%$nul}" + -'_apt_consume_long ${match[1]%'$qnul'}' /"((${(j:|:)bool})$nul|)"/ :"$comp_bool" \| ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)long_bool})="/ - -"_apt_consume_long \${match[1]%=}" + -'_apt_consume_long ${match[1]%=}' \( /"$word1"/ :"$comp_bool" \| /"$nul"/ /"$word"/ :"$comp_bool" \) \| /"(${(j:|:)long_bool})$nul"/ - -"_apt_consume_long \${match[1]%$nul}" + -'_apt_consume_long ${match[1]%'$qnul'}' /"((${(j:|:)bool})$nul|)"/ :"$comp_bool" \| ) fi @@ -236,18 +237,18 @@ _describe -o option tmp2 -- tmp3 -S=' if (( $#long_intlevel )); then regex_long=("$regex_long[@]" /"(${(j:|:)long_intlevel})="/ - -"_apt_consume_long \${match[1]%=}" + -'_apt_consume_long ${match[1]%=}' \( /"$word1"/ :"$comp_intlevel" \| /"$nul"/ /"$word"/ :"$comp_intlevel" \) \| /"(${(j:|:)long_intlevel})$nul"/ - -"_apt_consume_long \${match[1]%$nul}" + -'_apt_consume_long ${match[1]%'$qnul'}' /"($intlevel$nul|)"/ :"$comp_intlevel" \| ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)long_intlevel})="/ - -"_apt_consume_long \${match[1]%=}" + -'_apt_consume_long ${match[1]%=}' \( /"$word1"/ :"$comp_intlevel" \| /"$nul"/ /"$word"/ :"$comp_intlevel" \) \| /"(${(j:|:)long_intlevel})$nul"/ - -"_apt_consume_long \${match[1]%$nul}" + -'_apt_consume_long ${match[1]%'$qnul'}' /"($intlevel$nul|)"/ :"$comp_intlevel" \| ) fi @@ -255,18 +256,18 @@ _describe -o option tmp2 -- tmp3 -S=' if (( $#long_configfile )); then regex_long=("$regex_long[@]" /"(${(j:|:)long_configfile})$nul"/ - -"_apt_consume_long \${match[1]%$nul}" + -'_apt_consume_long ${match[1]%'$qnul'}' /"$word"/ :"$comp_configfile" \| /"(${(j:|:)long_configfile})="/ - -"_apt_consume_long \${match[1]%=}" + -'_apt_consume_long ${match[1]%=}' \( /"$word1"/ :"$comp_configfile" \| /"$nul"/ /"$word"/ :"$comp_configfile" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)long_configfile})$nul"/ - -"_apt_consume_long \${match[1]%$nul}" + -'_apt_consume_long ${match[1]%'$qnul'}' /"$word"/ :"$comp_configfile" \| /"(${(j:|:)long_configfile})="/ - -"_apt_consume_long \${match[1]%=}" + -'_apt_consume_long ${match[1]%=}' \( /"$word1"/ :"$comp_configfile" \| /"$nul"/ /"$word"/ :"$comp_configfile" \) \| ) fi @@ -274,18 +275,18 @@ _describe -o option tmp2 -- tmp3 -S=' if (( $#long_arbitem )); then regex_long=("$regex_long[@]" /"(${(j:|:)long_arbitem})$nul"/ - -"_apt_consume_long \${match[1]%$nul}" + -'_apt_consume_long ${match[1]%'$qnul'}' /"$word"/ :"$comp_arbitem" \| /"(${(j:|:)long_arbitem})="/ - -"_apt_consume_long \${match[1]%=}" + -'_apt_consume_long ${match[1]%=}' \( /"$word1"/ :"$comp_arbitem" \| /"$nul"/ /"$word"/ :"$comp_arbitem" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" /"(${(j:|:)long_arbitem})$nul"/ - -"_apt_consume_long \${match[1]%$nul}" + -'_apt_consume_long ${match[1]%'$qnul'}' /"$word"/ :"$comp_arbitem"/ \| /"(${(j:|:)long_arbitem})="/ - -"_apt_consume_long \${match[1]%=}" + -'_apt_consume_long ${match[1]%=}' \( /"$word1"/ :"$comp_arbitem" \| /"$nul"/ /"$word"/ :"$comp_arbitem" \) \| ) fi -- cgit 1.4.1