mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-12-05 14:48:55 +01:00
fix(cli): remove adjacent plugins in omz plugin disable (#14303)
This commit is contained in:
1 parent
507561c236
commit
113f9b2475
2 files changed
+57
-16
No files matched your search
+14
-8
@@ -295,17 +295,23 @@ function _omz::plugin::disable {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove plugins substitution awk script
|
# Remove plugins substitution awk script
|
||||||
|
# A match consumes the whitespace around the plugin, so adjacent plugins
|
||||||
|
# can't match in the same pass: repeat until the line stops changing.
|
||||||
local awk_subst_plugins="\
|
local awk_subst_plugins="\
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
do {
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
prev = \$0
|
||||||
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
|
|
||||||
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
|
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
|
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
||||||
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
|
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
|
||||||
|
|
||||||
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
|
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
|
||||||
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
|
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
|
||||||
|
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
|
||||||
|
|
||||||
|
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
|
||||||
|
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
|
||||||
|
} while (\$0 != prev)
|
||||||
"
|
"
|
||||||
|
|
||||||
# Disable plugins awk script
|
# Disable plugins awk script
|
||||||
|
|||||||
+43
-8
@@ -7,16 +7,20 @@ run_awk() {
|
|||||||
(( ! DEBUG )) || set -xv
|
(( ! DEBUG )) || set -xv
|
||||||
|
|
||||||
local awk_subst_plugins="\
|
local awk_subst_plugins="\
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
do {
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
prev = \$0
|
||||||
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
|
|
||||||
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
|
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
|
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
||||||
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
|
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
|
||||||
|
|
||||||
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
|
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
|
||||||
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
|
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
|
||||||
|
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
|
||||||
|
|
||||||
|
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
|
||||||
|
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
|
||||||
|
} while (\$0 != prev)
|
||||||
"
|
"
|
||||||
# Disable plugins awk script
|
# Disable plugins awk script
|
||||||
local awk_script="
|
local awk_script="
|
||||||
@@ -167,3 +171,34 @@ z)" \
|
|||||||
"plugins=(
|
"plugins=(
|
||||||
git
|
git
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete two adjacent plugins among others in oneline format" \
|
||||||
|
"docker kubectl" \
|
||||||
|
"plugins=(git docker kubectl npm)" \
|
||||||
|
"plugins=(git npm)"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete three adjacent plugins among others in oneline format" \
|
||||||
|
"docker kubectl aws" \
|
||||||
|
"plugins=(git docker kubectl aws npm)" \
|
||||||
|
"plugins=(git npm)"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete every plugin of a long oneline list" \
|
||||||
|
"git docker kubectl aws npm z" \
|
||||||
|
"plugins=(git docker kubectl aws npm z)" \
|
||||||
|
"plugins=()"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete adjacent plugins sharing a line in multiline format" \
|
||||||
|
"docker kubectl aws" \
|
||||||
|
"plugins=(
|
||||||
|
git
|
||||||
|
docker kubectl aws
|
||||||
|
npm
|
||||||
|
)" \
|
||||||
|
"plugins=(
|
||||||
|
git
|
||||||
|
npm
|
||||||
|
)"
|
||||||
Reference in new issue
Block a user