From 58a08ff88b151b226aa65f68328ef26a7f0c1abd Mon Sep 17 00:00:00 2001 From: MenkeTechnologies Date: Thu, 13 Jan 2022 13:51:14 -0500 Subject: [PATCH] extract start/stop quote regex --- zsh-expand.plugin.zsh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zsh-expand.plugin.zsh b/zsh-expand.plugin.zsh index 7ba24c6..74657da 100644 --- a/zsh-expand.plugin.zsh +++ b/zsh-expand.plugin.zsh @@ -56,18 +56,21 @@ if (( $#ZPWR_EXPAND_BLACKLIST )); then fi ZPWR_VARS[lvalueRegex]='[[:graph:]]+=' -ZPWR_VARS[rvalueRegex]='((\$\''|[\"\'']).*[\"\'']|[[:graph:]]*)' +ZPWR_VARS[startQuoteRegex]='(\$''|[\\"''])*' +ZPWR_VARS[endQuoteRegex]='["'']*' +ZPWR_VARS[rvalueRegex]='((\$''|["'']).*["'']|[[:graph:]]*)' ZPWR_VARS[assignRegex]="(${ZPWR_VARS[lvalueRegex]}${ZPWR_VARS[rvalueRegex]}[[:space:]]+)*" ZPWR_VARS[blacklistFirstPosRegex]='^(omz_history|grc|_z|zshz|cd|hub|_zsh_tmux_|_rails_|_rake_|mvn-or|gradle-or|noglob |rlwrap ).*$' ZPWR_VARS[blacklistSubcommandPositionRegex]='^(cargo|jenv|svn|git|ng|pod|docker|kubectl|rndc|yarn|npm|pip[0-9\.]*|bundle|rails|gem|nmcli|brew|apt|dnf|yum|zypper|pacman|service|proxychains[0-9\.]*|zpwr|zm|zd|zg|zinit)$' -ZPWR_VARS[continueFirstPositionRegexNoZpwr]="^([[:space:]]*)${ZPWR_VARS[assignRegex]}(([\\\"\']*builtin[\\\"\']*[[:space:]]+)*[\\\"\']*${ZPWR_VARS[builtinSkips]}[\\\"\']*)?([[:space:]]*)(([\\\"\']*sudo[\\\"\']*([[:space:]]+)((-[ABbEHnPSis]+[[:space:]]*|-[CghpTu][[:space:]=]+[[:graph:]]*[[:space:]]+|--)*)*)*${ZPWR_VARS[assignRegex]}([\\\"\']*env[\\\"\']*[[:space:]]+(-[iv]+[[:space:]]*|-[PSu][[:space:]=]+[[:graph:]]*[[:space:]]+|--)*)*${ZPWR_VARS[assignRegex]})*([[:space:]]*)(.*)$" - # the main regex to match x=1 \builtin* 'command'* '"sudo"' -* y=2 \env* -* z=3 cmd arg1 arg2 etc -ZPWR_VARS[continueFirstPositionRegex]="^([[:space:]]*)${ZPWR_VARS[assignRegex]}(([\\\"\']*builtin[\\\"\']*[[:space:]]+)*[\\\"\']*${ZPWR_VARS[builtinSkips]}[\\\"\']*)?([[:space:]]*)(([\\\"\']*zpwr[\\\"\']*([[:space:]]+)(-[[:graph:]]+)*)*([\\\"\']*sudo[\\\"\']*([[:space:]]+)((-[ABbEHnPSis]+[[:space:]]*|-[CghpTu][[:space:]=]+[[:graph:]]*[[:space:]]+|--)*)*)*${ZPWR_VARS[assignRegex]}([\\\"\']*env[\\\"\']*[[:space:]]+(-[iv]+[[:space:]]*|-[PSu][[:space:]=]+[[:graph:]]+[[:space:]]+|--)*)*${ZPWR_VARS[assignRegex]})*([[:space:]]*)([[:graph:]]+)$" +ZPWR_VARS[continueFirstPositionRegexNoZpwr]="^([[:space:]]*)${ZPWR_VARS[assignRegex]}((${ZPWR_VARS[startQuoteRegex]}builtin${ZPWR_VARS[endQuoteRegex]}[[:space:]]+)*${ZPWR_VARS[startQuoteRegex]}${ZPWR_VARS[builtinSkips]}${ZPWR_VARS[endQuoteRegex]})?([[:space:]]*)((${ZPWR_VARS[startQuoteRegex]}sudo${ZPWR_VARS[endQuoteRegex]}([[:space:]]+)((-[ABbEHnPSis]+[[:space:]]*|-[CghpTu][[:space:]=]+[[:graph:]]*[[:space:]]+|--)*)*)*${ZPWR_VARS[assignRegex]}(${ZPWR_VARS[startQuoteRegex]}env${ZPWR_VARS[endQuoteRegex]}[[:space:]]+(-[iv]+[[:space:]]*|-[PSu][[:space:]=]+[[:graph:]]*[[:space:]]+|--)*)*${ZPWR_VARS[assignRegex]})*([[:space:]]*)(.*)$" + + +#ZPWR_VARS[continueFirstPositionRegex]="^([[:space:]]*)${ZPWR_VARS[assignRegex]}(([\\\"\']*builtin[\\\"\']*[[:space:]]+)*[\\\"\']*${ZPWR_VARS[builtinSkips]}[\\\"\']*)?([[:space:]]*)(([\\\"\']*zpwr[\\\"\']*([[:space:]]+)(-[[:graph:]]+)*)*([\\\"\']*sudo[\\\"\']*([[:space:]]+)((-[ABbEHnPSis]+[[:space:]]*|-[CghpTu][[:space:]=]+[[:graph:]]*[[:space:]]+|--)*)*)*${ZPWR_VARS[assignRegex]}([\\\"\']*env[\\\"\']*[[:space:]]+(-[iv]+[[:space:]]*|-[PSu][[:space:]=]+[[:graph:]]+[[:space:]]+|--)*)*${ZPWR_VARS[assignRegex]})*([[:space:]]*)([[:graph:]]+)$" #}}}*********************************************************** declare -Ag ZPWR_EXPAND_CORRECT_WORDS