1
0
Fork 0
mirror of synced 2024-11-26 17:25:35 -05:00

Allow uninstalling modules with custom names

that have a slash, as that yields subdirectories. For example:

    zmodule duration-info -n zimfw/duration-info
    zmodule git-info -n zimfw/git-info
    zmodule asciiship -n zimfw/asciiship
This commit is contained in:
Eric Nielsen 2021-06-17 20:01:13 -05:00
parent 7d533fcecd
commit 5db2b66052
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
3 changed files with 29 additions and 5 deletions

View file

@ -62,11 +62,11 @@ Initialization options:
return 2 return 2
fi fi
shift shift
zmodule=${1} zmodule=${${1%%/##}##/##}
shift shift
fi fi
if [[ ${zurl} == /* ]]; then if [[ ${zurl} == /* ]]; then
zdir=${zurl} zdir=${zurl%%/##}
else else
zdir=${ZIM_HOME}/modules/${zmodule} zdir=${ZIM_HOME}/modules/${zmodule}
fi fi

View file

@ -2,6 +2,18 @@ _zimfw_uninstall() {
local zopt local zopt
if (( _zprintlevel > 0 )) zopt='-v' if (( _zprintlevel > 0 )) zopt='-v'
local zuninstalls=(${ZIM_HOME}/modules/*(N/:t)) local zuninstalls=(${ZIM_HOME}/modules/*(N/:t))
# Search into subdirectories
local -a subdirs
local -i i=1
while (( i <= ${#zuninstalls} )); do
if (( ${_zmodules[(I)${zuninstalls[i]}/*]} || ${_zdisableds[(I)${zuninstalls[i]}/*]} )); then
subdirs=(${ZIM_HOME}/modules/${zuninstalls[i]}/*(N/:t))
zuninstalls+=(${zuninstalls[i]}/${^subdirs})
zuninstalls[i]=()
else
(( i++ ))
fi
done
# Uninstall all installed modules not in _zmodules and _zdisableds # Uninstall all installed modules not in _zmodules and _zdisableds
zuninstalls=(${${zuninstalls:|_zmodules}:|_zdisableds}) zuninstalls=(${${zuninstalls:|_zmodules}:|_zdisableds})
if (( ${#zuninstalls} )); then if (( ${#zuninstalls} )); then

View file

@ -169,11 +169,11 @@ Initialization options:
return 2 return 2
fi fi
shift shift
zmodule=${1} zmodule=${${1%%/##}##/##}
shift shift
fi fi
if [[ ${zurl} == /* ]]; then if [[ ${zurl} == /* ]]; then
zdir=${zurl} zdir=${zurl%%/##}
else else
zdir=${ZIM_HOME}/modules/${zmodule} zdir=${ZIM_HOME}/modules/${zmodule}
fi fi
@ -335,7 +335,7 @@ _zimfw_compile() {
} }
_zimfw_info() { _zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2021-04-24 00:11:24 UTC, previous commit is 89d6f7b)' print -R 'zimfw version: '${_zversion}' (built at 2021-06-11 13:41:21 UTC, previous commit is 7d533fc)'
print -R 'ZIM_HOME: '${ZIM_HOME} print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION} print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a) print -R 'System info: '$(command uname -a)
@ -345,6 +345,18 @@ _zimfw_uninstall() {
local zopt local zopt
if (( _zprintlevel > 0 )) zopt='-v' if (( _zprintlevel > 0 )) zopt='-v'
local zuninstalls=(${ZIM_HOME}/modules/*(N/:t)) local zuninstalls=(${ZIM_HOME}/modules/*(N/:t))
# Search into subdirectories
local -a subdirs
local -i i=1
while (( i <= ${#zuninstalls} )); do
if (( ${_zmodules[(I)${zuninstalls[i]}/*]} || ${_zdisableds[(I)${zuninstalls[i]}/*]} )); then
subdirs=(${ZIM_HOME}/modules/${zuninstalls[i]}/*(N/:t))
zuninstalls+=(${zuninstalls[i]}/${^subdirs})
zuninstalls[i]=()
else
(( i++ ))
fi
done
# Uninstall all installed modules not in _zmodules and _zdisableds # Uninstall all installed modules not in _zmodules and _zdisableds
zuninstalls=(${${zuninstalls:|_zmodules}:|_zdisableds}) zuninstalls=(${${zuninstalls:|_zmodules}:|_zdisableds})
if (( ${#zuninstalls} )); then if (( ${#zuninstalls} )); then