From 89d6f7b7f31ec499528f1e956d7caced9ccf7427 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Wed, 21 Apr 2021 19:37:47 -0500 Subject: [PATCH] Rename .zim_degit_info to .zdegit Nicer and way simpler! --- src/tools/degit.zsh.erb | 13 +++++++------ zimfw.zsh | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/tools/degit.zsh.erb b/src/tools/degit.zsh.erb index 675fdfa..0919beb 100644 --- a/src/tools/degit.zsh.erb +++ b/src/tools/degit.zsh.erb @@ -6,9 +6,9 @@ readonly URL=${4} readonly REV=${6} readonly -i PRINTLEVEL=${7} readonly CLEAR_LINE=<%= clear_line %> -readonly PREFIX=.zim_degit_${RANDOM} -readonly TARBALL_TARGET=${DIR}/${PREFIX}_tarball.tar.gz -readonly INFO_TARGET=${DIR}/.zim_degit_info +readonly TEMP=.zdegit_${RANDOM} +readonly TARBALL_TARGET=${DIR}/${TEMP}_tarball.tar.gz +readonly INFO_TARGET=${DIR}/.zdegit print_error() { print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b ${1}%f"${2:+$'\n'${(F):- ${(f)^2}}} @@ -35,7 +35,7 @@ download_tarball() { print_error "${URL} is not a valid github.com URL. Will not try to ${ACTION}." return 1 fi - local -r headers_target=${DIR}/${PREFIX}_headers + local -r headers_target=${DIR}/${TEMP}_headers { local info_header if [[ -r ${INFO_TARGET} ]]; then @@ -108,7 +108,7 @@ create_dir() { { create_dir ${DIR} && download_tarball && untar_tarball ${DIR} && print_done installed } always { - # return 1 command does not change ${TRY_BLOCK_ERROR}, but only ${?} + # return 1 does not change ${TRY_BLOCK_ERROR}, only changes ${?} (( TRY_BLOCK_ERROR = ? )) command rm -f ${TARBALL_TARGET} 2>/dev/null if (( TRY_BLOCK_ERROR )); then @@ -117,11 +117,12 @@ create_dir() { } ;; update) + if [[ -r ${DIR}/.zim_degit_info ]] command mv -f ${DIR}/.zim_degit_info ${INFO_TARGET} if [[ ! -r ${INFO_TARGET} ]]; then print_error "Module was not installed using Zim's degit. Will not try to update. You can disable this with the zmodule option -z|--frozen." return 1 fi - local -r dir_new=${DIR}${PREFIX} + local -r dir_new=${DIR}${TEMP} { download_tarball || return 1 if [[ ! -e ${TARBALL_TARGET} ]]; then diff --git a/zimfw.zsh b/zimfw.zsh index 59f3a56..2cbd548 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -335,7 +335,7 @@ _zimfw_compile() { } _zimfw_info() { - print -R 'zimfw version: '${_zversion}' (built at 2021-04-08 16:37:09 UTC, previous commit is cffd456)' + print -R 'zimfw version: '${_zversion}' (built at 2021-04-22 00:36:56 UTC, previous commit is 2869851)' print -R 'ZIM_HOME: '${ZIM_HOME} print -R 'Zsh version: '${ZSH_VERSION} print -R 'System info: '$(command uname -a) @@ -420,9 +420,9 @@ readonly URL=\${4} readonly REV=\${6} readonly -i PRINTLEVEL=\${7} readonly CLEAR_LINE=$'\E[2K\r' -readonly PREFIX=.zim_degit_\${RANDOM} -readonly TARBALL_TARGET=\${DIR}/\${PREFIX}_tarball.tar.gz -readonly INFO_TARGET=\${DIR}/.zim_degit_info +readonly TEMP=.zdegit_\${RANDOM} +readonly TARBALL_TARGET=\${DIR}/\${TEMP}_tarball.tar.gz +readonly INFO_TARGET=\${DIR}/.zdegit print_error() { print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b \${1}%f\"\${2:+$'\n'\${(F):- \${(f)^2}}} @@ -449,7 +449,7 @@ download_tarball() { print_error \"\${URL} is not a valid github.com URL. Will not try to \${ACTION}.\" return 1 fi - local -r headers_target=\${DIR}/\${PREFIX}_headers + local -r headers_target=\${DIR}/\${TEMP}_headers { local info_header if [[ -r \${INFO_TARGET} ]]; then @@ -522,7 +522,7 @@ create_dir() { { create_dir \${DIR} && download_tarball && untar_tarball \${DIR} && print_done installed } always { - # return 1 command does not change \${TRY_BLOCK_ERROR}, but only \${?} + # return 1 does not change \${TRY_BLOCK_ERROR}, only changes \${?} (( TRY_BLOCK_ERROR = ? )) command rm -f \${TARBALL_TARGET} 2>/dev/null if (( TRY_BLOCK_ERROR )); then @@ -531,11 +531,12 @@ create_dir() { } ;; update) + if [[ -r \${DIR}/.zim_degit_info ]] command mv -f \${DIR}/.zim_degit_info \${INFO_TARGET} if [[ ! -r \${INFO_TARGET} ]]; then print_error \"Module was not installed using Zim's degit. Will not try to update. You can disable this with the zmodule option -z|--frozen.\" return 1 fi - local -r dir_new=\${DIR}\${PREFIX} + local -r dir_new=\${DIR}\${TEMP} { download_tarball || return 1 if [[ ! -e \${TARBALL_TARGET} ]]; then