Skip to content

znap pull command in a Zsh script? #34

Answered by marlonrichert
andylima asked this question in Q&A
Discussion options

You must be logged in to vote

@andylima I dug into it a bit and found out that what happens when you run your znu script as an executable, rather than sourceing it, it gets executed in a subshell. The subshell inherits exported parameters, but nothing else from the parent shell. So, for all practical purposes, when you run your script as such, it is as if Znap has never been initialized.

The easiest way around this is to convert your script to a function. So, instead of adding it to your $path, add it to your $fpath and autoload it. That way, it will run inside the same shell.

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by marlonrichert
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
documentation Improvements or additions to documentation
2 participants
Converted from issue

This discussion was converted from issue #25 on February 05, 2021 20:00.