Skip to content

Commit

Permalink
Propagate -o xtrace when needed and prepend builtin to emulate (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
psprint authored May 29, 2022
1 parent eb19b5b commit bcedc9f
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 62 deletions.
4 changes: 2 additions & 2 deletions zinit-additional.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
local ___data="$(<$1)"

() {
builtin emulate -LR zsh -o extendedglob -o interactivecomments
builtin emulate -LR zsh -o extendedglob -o interactivecomments ${=${options[xtrace]:#off}:+-o xtrace}
local ___subst ___tabspc=$'\t'
for ___subst ( "${___substs[@]}" ) {
___ab=( "${(@)${(@)${(@s:->:)___subst}##[[:space:]]##}%%[[:space:]]##}" )
Expand All @@ -39,7 +39,7 @@
# $2 - mode - for plugin (light or load)
# $3 - id - URL or plugin ID or alias name (from id-as'')
.zinit-service() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops

local ___tpe="$1" ___mode="$2" ___id="$3" ___fle="${ZINIT[SERVICES_DIR]}/${ICE[service]}.lock" ___fd ___cmd ___tmp ___lckd ___strd=0
Expand Down
32 changes: 16 additions & 16 deletions zinit-autoload.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ ZINIT[EXTENDED_GLOB]=""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-uninstall-completions() {
builtin emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops

typeset -a completions symlinked backup_comps
Expand Down Expand Up @@ -708,7 +708,7 @@ ZINIT[EXTENDED_GLOB]=""
#
# User-action entry point.
.zinit-self-update() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob typesetsilent warncreateglobal

[[ $1 = -q ]] && +zinit-message -n "{pre}[self-update]{msg2} Updating Zinit repository{msg2}" \
Expand Down Expand Up @@ -766,7 +766,7 @@ ZINIT[EXTENDED_GLOB]=""
#
# User-action entry point.
.zinit-show-registered-plugins() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops

typeset -a filtered
Expand Down Expand Up @@ -882,7 +882,7 @@ ZINIT[EXTENDED_GLOB]=""
if [[ "$sw_arr4" = "-M" && "$sw_arr6" != "-R" ]]; then
if [[ -n "$sw_arr3" ]]; then
() {
emulate -LR zsh -o extendedglob
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
(( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3 ${ZINIT[col-info]}in map ${ZINIT[col-rst]}$sw_arr5"
}
bindkey -M "$sw_arr5" "$sw_arr1" "$sw_arr3"
Expand Down Expand Up @@ -915,7 +915,7 @@ ZINIT[EXTENDED_GLOB]=""
else
if [[ -n "$sw_arr3" ]]; then
() {
emulate -LR zsh -o extendedglob
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
(( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3"
}
bindkey "$sw_arr1" "$sw_arr3"
Expand Down Expand Up @@ -1422,7 +1422,7 @@ ZINIT[EXTENDED_GLOB]=""
# $3 - plugin (only when $1 - i.e. user - given)
.zinit-update-or-status() {
# Set the localtraps option.
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops

local -a arr
Expand Down Expand Up @@ -1831,7 +1831,7 @@ ZINIT[EXTENDED_GLOB]=""
#
# User-action entry point.
.zinit-update-or-status-all() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops

local -F2 SECONDS=0
Expand Down Expand Up @@ -1975,7 +1975,7 @@ ZINIT[EXTENDED_GLOB]=""
} # ]]]
# FUNCTION: .zinit-update-in-parallel [[[
.zinit-update-all-parallel() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent \
noshortloops nomonitor nonotify

Expand Down Expand Up @@ -2173,7 +2173,7 @@ ZINIT[EXTENDED_GLOB]=""
#
# User-action entry point.
.zinit-show-times() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal noshortloops

local opt="$1 $2 $3" entry entry2 entry3 user plugin
Expand Down Expand Up @@ -2706,7 +2706,7 @@ ZINIT[EXTENDED_GLOB]=""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-cd() {
builtin emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt extendedglob warncreateglobal typesetsilent rcquotes

.zinit-get-path "$1" "$2" && {
Expand Down Expand Up @@ -2753,7 +2753,7 @@ ZINIT[EXTENDED_GLOB]=""
# $1 - snippet URL or plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-delete() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent

local -a opts match mbegin mend
Expand Down Expand Up @@ -2933,7 +2933,7 @@ builtin print -Pr \"\$ZINIT[col-obj]Done (with the exit code: \$_retval).%f%b\""
#
# $1 - time spec, e.g. "1 week"
.zinit-recently() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt nullglob extendedglob warncreateglobal \
typesetsilent noshortloops

Expand Down Expand Up @@ -2970,7 +2970,7 @@ builtin print -Pr \"\$ZINIT[col-obj]Done (with the exit code: \$_retval).%f%b\""
# $1 - (optional) plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-create() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt localoptions extendedglob warncreateglobal typesetsilent \
noshortloops rcquotes

Expand Down Expand Up @@ -3210,7 +3210,7 @@ EOF
)

(
emulate -LR ksh
builtin emulate -LR ksh ${=${options[xtrace]:#off}:+-o xtrace}
builtin unsetopt shglob kshglob
for i in "${ZINIT_STRESS_TEST_OPTIONS[@]}"; do
builtin setopt "$i"
Expand Down Expand Up @@ -3276,7 +3276,7 @@ EOF
# ("%" "/home/..." and also "%SNIPPETS/..." etc.), or a plugin
# nickname (i.e. id-as'' ice-mod), or a snippet nickname.
.zinit-get-path() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops

[[ $1 == % ]] && local id_as=%$2 || local id_as=$1${1:+/}$2
Expand All @@ -3288,7 +3288,7 @@ EOF
# ]]]
# FUNCTION: .zinit-recall [[[
.zinit-recall() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops

local -A ice
Expand Down
40 changes: 20 additions & 20 deletions zinit-install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# $2: jq path
# $3: name of the associative array to store the key/value pairs in
.zinit-json-to-array() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt localoptions noglob

.zinit-jq-check || return 1
Expand All @@ -60,7 +60,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
.zinit-get-package() {
.zinit-jq-check || return 1

emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes

local user=$1 pkg=$2 plugin=$2 id_as=$3 dir=$4 profile=$5 \
Expand Down Expand Up @@ -291,7 +291,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# $1 - user
# $2 - plugin
.zinit-setup-plugin-dir() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal noshortloops rcquotes

local user=$1 plugin=$2 id_as=$3 remote_url_path=${1:+$1/}$2 \
Expand Down Expand Up @@ -523,7 +523,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# $2 - plugin (only when $1 - i.e. user - given)
# $3 - if 1, then reinstall, otherwise only install completions that aren't there
.zinit-install-completions() {
builtin emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops

local id_as=$1${2:+${${${(M)1:#%}:+$2}:-/$2}}
Expand Down Expand Up @@ -605,7 +605,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# This might be called during sourcing when setting up the plugins dir, so check that OPTS is actually existing
[[ -n $OPTS && -n ${OPTS[opt_-p,--parallel]} && $1 != 1 ]] && return

emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt nullglob extendedglob warncreateglobal typesetsilent

integer use_C=$2
Expand Down Expand Up @@ -643,7 +643,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
.zinit-download-file-stdout() {
local url="$1" restart="$2" progress="${(M)3:#1}"

emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt localtraps extendedglob

# Return file directly for file:// urls, wget doesn't support this schema
Expand Down Expand Up @@ -784,7 +784,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
#
# $1 - completion function name, e.g. "_cp"; can also be "cp"
.zinit-forget-completion() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob typesetsilent warncreateglobal

local f="$1" quiet="$2"
Expand Down Expand Up @@ -812,7 +812,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-compile-plugin() {
builtin emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes

local id_as=$1${2:+${${${(M)1:#%}:+$2}:-/$2}} first plugin_dir filename is_snippet
Expand Down Expand Up @@ -856,7 +856,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
+zinit-message -n "{note}Note:{rst} Compiling{ehi}:{rst} {b}{file}$fname{rst}{…}"
if [[ -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} ]] {
() {
builtin emulate -LR zsh -o extendedglob
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
if { ! zcompile -U "$first" } {
+zinit-message "{msg2}Warning:{rst} Compilation failed. Don't worry, the plugin will work also without compilation."
+zinit-message "{msg2}Warning:{rst} Consider submitting an error report to Zinit or to the plugin's author."
Expand All @@ -883,7 +883,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
integer retval
for first in $list; do
() {
builtin emulate -LR zsh -o extendedglob
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
zcompile -U "$first"; retval+=$?
}
done
Expand All @@ -907,7 +907,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# supports Subversion protocol and allows to clone subdirectories.
# This is used to provide a layer of support for Oh-My-Zsh and Prezto.
.zinit-download-snippet() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent

local save_url=$1 url=$2 id_as=$3 local_dir=$4 dirname=$5 filename=$6 update=$7
Expand Down Expand Up @@ -1042,7 +1042,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
${+ICE[nocompile]} -eq 0
]] {
() {
builtin emulate -LR zsh -o extendedglob
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
zcompile -U "${list[1]}" &>/dev/null || \
+zinit-message "{u-warn}Warning{b-warn}:{rst} couldn't compile {apo}\`{file}${list[1]}{apo}\`{rst}."
}
Expand Down Expand Up @@ -1134,7 +1134,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
$file_path != */dev/null && ${+ICE[nocompile]} -eq 0
]] {
() {
builtin emulate -LR zsh -o extendedglob
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
if ! zcompile -U "$file_path" 2>/dev/null; then
builtin print -r "Couldn't compile \`${file_path:t}', it MIGHT be wrongly downloaded"
builtin print -r "(snippet URL points to a directory instead of a file?"
Expand Down Expand Up @@ -1352,7 +1352,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
} # ]]]
# FUNCTION: .zinit-update-snippet [[[
.zinit-update-snippet() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes

local -a tmp opts
Expand Down Expand Up @@ -1447,7 +1447,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# Gets version string of latest release of given Github
# package. Connects to Github releases page.
.zinit-get-latest-gh-r-url-part() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops

REPLY=
Expand Down Expand Up @@ -1593,7 +1593,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# $1 - url
# $2 - file
ziextract() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob typesetsilent noshortloops # warncreateglobal

local -a opt_move opt_move2 opt_norm opt_auto opt_nobkp
Expand Down Expand Up @@ -1903,7 +1903,7 @@ ziextract() {
} # ]]]
# FUNCTION: .zinit-extract [[[
.zinit-extract() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent
local tpe=$1 extract=$2 local_dir=$3
(
Expand Down Expand Up @@ -1951,7 +1951,7 @@ zpextract() { ziextract "$@"; }
} # ]]]
# FUNCTION: .zinit-get-cygwin-package [[[
.zinit-get-cygwin-package() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes

REPLY=
Expand Down Expand Up @@ -2036,7 +2036,7 @@ zpextract() { ziextract "$@"; }
} # ]]]
# FUNCTION: zicp [[[
zicp() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes

local -a mbegin mend match
Expand Down Expand Up @@ -2331,7 +2331,7 @@ zimv() {
# Compile plugin
if [[ -z $ICE[(i)(\!|)(sh|bash|ksh|csh)] ]] {
() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal
if [[ $tpe == snippet ]] {
.zinit-compile-plugin "%$dir" ""
Expand Down
8 changes: 4 additions & 4 deletions zinit-side.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-exists-physically-message() {
builtin emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
if ! .zinit-exists-physically "$1" "$2"; then
.zinit-any-to-user-plugin "$1" "$2"
Expand Down Expand Up @@ -126,7 +126,7 @@
# directory) or regular URL (points to file), returns 2 possible paths for
# further examination
.zinit-two-paths() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob typesetsilent warncreateglobal noshortloops

local url=$1 url1 url2 local_dirA dirnameA svn_dirA \
Expand Down Expand Up @@ -170,7 +170,7 @@
# $5 - name of output string parameter, to hold filename ("filename")
# $6 - name of output string parameter, to hold is-snippet 0/1-bool ("is_snippet")
.zinit-compute-ice() {
emulate -LR zsh
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob typesetsilent warncreateglobal noshortloops

local ___URL="${1%/}" ___pack="$2" ___is_snippet=0
Expand Down Expand Up @@ -382,7 +382,7 @@
.zinit-countdown() {
(( !${+ICE[countdown]} )) && return 0

emulate -L zsh -o extendedglob
builtin emulate -L zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
trap "+zinit-message \"{ehi}ABORTING, the ice {ice}$ice{ehi} not ran{rst}\"; return 1" INT
local count=5 tpe="$1" ice
ice="${ICE[$tpe]}"
Expand Down
Loading

0 comments on commit bcedc9f

Please sign in to comment.