1
0
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:
Marc Cornellà
2024-05-08 22:20:42 +02:00
committed by GitHub
parent 8c5f64cc2f
commit b0561d28b5
2 changed files with 180 additions and 3 deletions

View File

@@ -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