Home > Net >  How do I debug where files break in a sourceing of files via wild card in zsh
How do I debug where files break in a sourceing of files via wild card in zsh

Time:11-24

I have a line in my .zshrc file, source $SNIPPETS/*.zsh and I know it's partially working because some functions defined in the directory work, but others do not unless I specifically source the file exclusively.

What steps would I take to find where in the sourcing there is an early exit or break?

CodePudding user response:

You can only source one file at a time. The first file is being sourced, but not the rest.

You'll need to use a loop in .zshrc

for i in "$SNIPPETS"/*.zsh; do
    [[ -e "$i" ]] && source "$i"
done

CodePudding user response:

TODAY I LEARNED: that source only works on explicitly called files. One can input multiple files but no wild cards.

None of my files were breaking.

Steps I took for debugging:

  1. Started a new shell.
  2. Enabled zprof. (zmodload zsh/zprof)
  3. Ran the source line. source $SNIPPETS/*.zsh
  4. Realized that only one file was being sourced.
  5. Re scoped my search for 'zsh source wildcard`
  6. Found and implemented option one from this answer (https://stackoverflow.com/a/14680403/5724147).
  • Related