]> Sergey Matveev's repositories - zsh-autoenv.git/commitdiff
AUTOENV_DEBUG=3 sets xtrace while sourcing; doc (#65)
authorDaniel Hahler <github@thequod.de>
Sun, 30 Apr 2017 12:14:25 +0000 (14:14 +0200)
committerArash Rouhani <miffoljud@gmail.com>
Sun, 30 Apr 2017 12:14:25 +0000 (14:14 +0200)
README.md
autoenv.zsh

index dac04dcf1d5e2a59d96a961c3dccc7ccf99d8b84..e39ab7e280877c8c4a0025430e07ce9976a63c5f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -126,6 +126,13 @@ Default: 0
 ### AUTOENV\_DEBUG
 Enable debugging. Multiple levels are supported (max 2).
 
+- 0: no debug messages
+- 1: generic debug logging
+- 2: more verbose messages
+  - messages about adding/removing files on the internal stack
+- 3: everything
+  - sets xtrace option (`set -x`) while sourcing env files
+
 Default: `0`
 
 ## Recipes
index e6cfc13f665cc412494732a2f3722ef56b464d59..db059f292e319a81f36296d9e7907f3c09d7c040 100644 (file)
@@ -303,7 +303,16 @@ _autoenv_source() {
   # Source the env file.
   _autoenv_debug "== SOURCE: ${bold_color:-}$autoenv_env_file${reset_color:-}\n      PWD: $PWD"
   : $(( _autoenv_debug_indent++ ))
+
+  local restore_xtrace
+  if [[ $AUTOENV_DEBUG -gt 2 && ! -o xtrace ]]; then
+    restore_xtrace=1
+    setopt localoptions xtrace
+  fi
   source $autoenv_env_file
+  if (( restore_xtrace )); then
+    setopt noxtrace
+  fi
   : $(( _autoenv_debug_indent-- ))
   _autoenv_debug "== END SOURCE =="