Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
708bbe12
Unverified
Commit
708bbe12
authored
Aug 17, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(cli): fix multiple errors in `plugin disable/enable`
parent
4455c13e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
21 deletions
+22
-21
cli.zsh
lib/cli.zsh
+22
-21
No files found.
lib/cli.zsh
View file @
708bbe12
...
@@ -230,9 +230,9 @@ function _omz::plugin::disable {
...
@@ -230,9 +230,9 @@ function _omz::plugin::disable {
local
awk_script
=
"
local
awk_script
=
"
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
/^
\s
*plugins=
\(
[^#]+
\)
.*
\$
/ {
/^
\s
*plugins=
\(
[^#]+
\)
.*
\$
/ {
sub(/
\s
+(
${
(j
:|:
)dis_plugins
}
)/,
\"\"
) # with spaces before
g
sub(/
\s
+(
${
(j
:|:
)dis_plugins
}
)/,
\"\"
) # with spaces before
sub(/(
${
(j
:|:
)dis_plugins
}
)
\s
+/,
\"\"
) # with spaces after
g
sub(/(
${
(j
:|:
)dis_plugins
}
)
\s
+/,
\"\"
) # with spaces after
sub(/
\(
(
${
(j
:|:
)dis_plugins
}
)
\)
/,
\"\"
) # without spaces (only plugin)
g
sub(/
\(
(
${
(j
:|:
)dis_plugins
}
)
\)
/,
\"\"
) # without spaces (only plugin)
print
\$
0
print
\$
0
next
next
}
}
...
@@ -240,9 +240,9 @@ function _omz::plugin::disable {
...
@@ -240,9 +240,9 @@ function _omz::plugin::disable {
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
/^
\s
*plugins=
\(
/ {
/^
\s
*plugins=
\(
/ {
multi=1
multi=1
sub(/
\s
+(
${
(j
:|:
)dis_plugins
}
)/,
\"\"
)
g
sub(/
\s
+(
${
(j
:|:
)dis_plugins
}
)/,
\"\"
)
sub(/(
${
(j
:|:
)dis_plugins
}
)
\s
+/,
\"\"
)
g
sub(/(
${
(j
:|:
)dis_plugins
}
)
\s
+/,
\"\"
)
sub(/
\(
(
${
(j
:|:
)dis_plugins
}
)
\)
/,
\"\"
)
g
sub(/
\(
(
${
(j
:|:
)dis_plugins
}
)
\)
/,
\"\"
)
print
\$
0
print
\$
0
next
next
}
}
...
@@ -251,17 +251,17 @@ function _omz::plugin::disable {
...
@@ -251,17 +251,17 @@ function _omz::plugin::disable {
# add new plugins and disable multi flag
# add new plugins and disable multi flag
multi == 1 && /^[^#]*
\)
/ {
multi == 1 && /^[^#]*
\)
/ {
multi=0
multi=0
sub(/
\s
+(
${
(j
:|:
)dis_plugins
}
)/,
\"\"
)
g
sub(/
\s
+(
${
(j
:|:
)dis_plugins
}
)/,
\"\"
)
sub(/(
${
(j
:|:
)dis_plugins
}
)
\s
+/,
\"\"
)
g
sub(/(
${
(j
:|:
)dis_plugins
}
)
\s
+/,
\"\"
)
sub(/
\(
(
${
(j
:|:
)dis_plugins
}
)
\)
/,
\"\"
)
g
sub(/
\(
(
${
(j
:|:
)dis_plugins
}
)
\)
/,
\"\"
)
print
\$
0
print
\$
0
next
next
}
}
multi == 1 {
multi == 1 {
sub(/
\s
+(
${
(j
:|:
)dis_plugins
}
)/,
\"\"
)
g
sub(/
\s
+(
${
(j
:|:
)dis_plugins
}
)/,
\"\"
)
sub(/(
${
(j
:|:
)dis_plugins
}
)
\s
+/,
\"\"
)
g
sub(/(
${
(j
:|:
)dis_plugins
}
)
\s
+/,
\"\"
)
sub(/
\(
(
${
(j
:|:
)dis_plugins
}
)
\)
/,
\"\"
)
g
sub(/
\(
(
${
(j
:|:
)dis_plugins
}
)
\)
/,
\"\"
)
print
\$
0
print
\$
0
next
next
}
}
...
@@ -283,13 +283,13 @@ multi == 1 {
...
@@ -283,13 +283,13 @@ multi == 1 {
# Exit if the new .zshrc file has syntax errors
# Exit if the new .zshrc file has syntax errors
if
!
zsh
-n
~/.zshrc
;
then
if
!
zsh
-n
~/.zshrc
;
then
_omz::log error
"broken syntax in ~/.zshrc. Rolling back changes..."
_omz::log error
"broken syntax in ~/.zshrc. Rolling back changes..."
mv
~/.zshrc ~/.zshrc.disabled
command mv
-f
~/.zshrc ~/.zshrc.disabled
mv
~/.zshrc.swp ~/.zshrc
command mv
-f
~/.zshrc.swp ~/.zshrc
return
1
return
1
fi
fi
# Restart the zsh session if there were no errors
# Restart the zsh session if there were no errors
_omz::log info
""
_omz::log info
"
plugins disabled:
${
(j
:,
:
)dis_plugins
}
.
"
# Old zsh versions don't have ZSH_ARGZERO
# Old zsh versions don't have ZSH_ARGZERO
local
zsh
=
"
${
ZSH_ARGZERO
:-${
functrace
[-1]%
:
*
}}
"
local
zsh
=
"
${
ZSH_ARGZERO
:-${
functrace
[-1]%
:
*
}}
"
...
@@ -344,26 +344,27 @@ multi == 1 && /^[^#]*\)/ {
...
@@ -344,26 +344,27 @@ multi == 1 && /^[^#]*\)/ {
{ print
\$
0 }
{ print
\$
0 }
"
"
awk
"
$awk_script
"
~/.zshrc
>
~/.zshrc.
dis
abled
\
awk
"
$awk_script
"
~/.zshrc
>
~/.zshrc.
en
abled
\
&&
mv
~/.zshrc ~/.zshrc.swp
\
&&
command mv
-f
~/.zshrc ~/.zshrc.swp
\
&&
mv
~/.zshrc.dis
abled ~/.zshrc
&&
command mv
-f
~/.zshrc.en
abled ~/.zshrc
# Exit if the new .zshrc file wasn't created correctly
# Exit if the new .zshrc file wasn't created correctly
[[
$?
-eq
0
]]
||
{
[[
$?
-eq
0
]]
||
{
local
ret
=
$?
local
ret
=
$?
_omz::log error
"error
dis
abling plugins."
_omz::log error
"error
en
abling plugins."
return
$ret
return
$ret
}
}
# Exit if the new .zshrc file has syntax errors
# Exit if the new .zshrc file has syntax errors
if
!
zsh
-n
~/.zshrc
;
then
if
!
zsh
-n
~/.zshrc
;
then
_omz::log error
"broken syntax in ~/.zshrc. Rolling back changes..."
_omz::log error
"broken syntax in ~/.zshrc. Rolling back changes..."
mv
~/.zshrc ~/.zshrc.dis
abled
command mv
-f
~/.zshrc ~/.zshrc.en
abled
mv
~/.zshrc.swp ~/.zshrc
command mv
-f
~/.zshrc.swp ~/.zshrc
return
1
return
1
fi
fi
# Restart the zsh session if there were no errors
# Restart the zsh session if there were no errors
_omz::log info
"plugins enabled:
${
(j
:,
:
)add_plugins
}
."
# Old zsh versions don't have ZSH_ARGZERO
# Old zsh versions don't have ZSH_ARGZERO
local
zsh
=
"
${
ZSH_ARGZERO
:-${
functrace
[-1]%
:
*
}}
"
local
zsh
=
"
${
ZSH_ARGZERO
:-${
functrace
[-1]%
:
*
}}
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment