znap pull
command in a Zsh script?
#34
-
Is there a way to execute the Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
If you make sure that Znap has been sourced before you source the script, then yes, that should work. In Zsh, there’s no difference between calling commands from the command line, in your |
Beta Was this translation helpful? Give feedback.
-
Oh, it's not a sourced script — it's a script file (where that command is) and I tried running it manually from the shell but I get an error that znap wasn't found. I guess it won't work that way?... And there's no workaround? |
Beta Was this translation helpful? Give feedback.
-
@andylima I have no idea what you’re talking about. Can you please give a concrete example? |
Beta Was this translation helpful? Give feedback.
-
These are the contents of the script file:
The name of that script file is
|
Beta Was this translation helpful? Give feedback.
-
@andylima I dug into it a bit and found out that what happens when you run your The easiest way around this is to convert your script to a function. So, instead of adding it to your |
Beta Was this translation helpful? Give feedback.
-
@marlonrichert I see. Thank you — I will use that workaround. |
Beta Was this translation helpful? Give feedback.
@andylima I dug into it a bit and found out that what happens when you run your
znu
script as an executable, rather thansource
ing it, it gets executed in a subshell. The subshell inheritsexport
ed 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
andautoload
it. That way, it will run inside the same shell.