mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +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:
parent
8c5f64cc2f
commit
b0561d28b5
2 changed files with 180 additions and 3 deletions
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue