mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2025-12-06 15:30:40 +01:00
fix(cli): fix edge cases in omz plugin disable command (#12401)
Also introduces tests, which will be refactored into the proper place when a test system is finally designed. Fixes #12400
This commit is contained in:
14
lib/cli.zsh
14
lib/cli.zsh
@@ -241,10 +241,18 @@ function _omz::plugin::disable {
|
||||
|
||||
# Remove plugins substitution awk script
|
||||
local awk_subst_plugins="\
|
||||
gsub(/[ \t]+(${(j:|:)dis_plugins})/, \"\") # with spaces before
|
||||
gsub(/(${(j:|:)dis_plugins})[ \t]+/, \"\") # with spaces after
|
||||
gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin)
|
||||
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
||||
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
||||
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})\)/, \")\") # 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
|
||||
"
|
||||
|
||||
# Disable plugins awk script
|
||||
local awk_script="
|
||||
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
|
||||
|
||||
Reference in New Issue
Block a user