* Shell sourced function not available to executed script
@ 2017-08-13 23:02 Clint Priest
2017-08-13 23:15 ` Clint Priest
0 siblings, 1 reply; 4+ messages in thread
From: Clint Priest @ 2017-08-13 23:02 UTC (permalink / raw)
To: Zsh Users
I could be wrong, but I swear that a function declared in my shell
environment was available to another script executed from the CLI.
In my case, I have a function:
pv() {
echo "\$$1='${(P)1}'";
}
Which is `source`ed into my environment. I could type pv PATH and it
would echo:
$PATH='...'
However when I run another script with executability set, shebang is
#!/bin/zsh it tells me pv is not available.
Any ideas?
--
-Clint
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Shell sourced function not available to executed script
2017-08-13 23:02 Shell sourced function not available to executed script Clint Priest
@ 2017-08-13 23:15 ` Clint Priest
2017-08-13 23:57 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Clint Priest @ 2017-08-13 23:15 UTC (permalink / raw)
To: Zsh Users
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
It would also seem that 'autoloaded functions' are also not available
from executed scripts... I created it as an autoloaded function and it
works from the CLI just fine.
On 8/13/2017 6:02 PM, Clint Priest wrote:
> I could be wrong, but I swear that a function declared in my shell
> environment was available to another script executed from the CLI.
>
> In my case, I have a function:
>
> pv() {
> echo "\$$1='${(P)1}'";
> }
>
> Which is `source`ed into my environment. I could type pv PATH and it
> would echo:
> $PATH='...'
>
> However when I run another script with executability set, shebang is
> #!/bin/zsh it tells me pv is not available.
>
> Any ideas?
>
--
-Clint
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Shell sourced function not available to executed script
2017-08-13 23:15 ` Clint Priest
@ 2017-08-13 23:57 ` Bart Schaefer
2017-08-14 1:18 ` Clint Priest
0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2017-08-13 23:57 UTC (permalink / raw)
To: Clint Priest; +Cc: Zsh Users
On Sun, Aug 13, 2017 at 4:15 PM, Clint Priest <cpriest@zsh-users.rxv.me> wrote:
> It would also seem that 'autoloaded functions' are also not available from
> executed scripts... I created it as an autoloaded function and it works
> from the CLI just fine.
>
>
> On 8/13/2017 6:02 PM, Clint Priest wrote:
>>
>> In my case, I have a function:
>>
>> Which is `source`ed into my environment.
This is going to depend on which of your startup files contain the
"source" or "autoload" commands. Interactive and login shells load a
different set of ~/.z* files than do scripts. Scripts typically read
only /etc/zshenv and ~/.zshenv. For complete details, "man zsh" and
read the section on "Startup/Shutdown Files" (or section 5.1 in "info
zsh" if you have that available).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Shell sourced function not available to executed script
2017-08-13 23:57 ` Bart Schaefer
@ 2017-08-14 1:18 ` Clint Priest
0 siblings, 0 replies; 4+ messages in thread
From: Clint Priest @ 2017-08-14 1:18 UTC (permalink / raw)
To: Zsh Users
[-- Attachment #1: Type: text/plain, Size: 975 bytes --]
On 8/13/2017 6:57 PM, Bart Schaefer wrote:
> On Sun, Aug 13, 2017 at 4:15 PM, Clint Priest <cpriest@zsh-users.rxv.me> wrote:
>> It would also seem that 'autoloaded functions' are also not available from
>> executed scripts... I created it as an autoloaded function and it works
>> from the CLI just fine.
>>
>> On 8/13/2017 6:02 PM, Clint Priest wrote:
>>> In my case, I have a function:
>>>
>>> Which is `source`ed into my environment.
> This is going to depend on which of your startup files contain the
> "source" or "autoload" commands. Interactive and login shells load a
> different set of ~/.z* files than do scripts. Scripts typically read
> only /etc/zshenv and ~/.zshenv. For complete details, "man zsh" and
> read the section on "Startup/Shutdown Files" (or section 5.1 in "info
> zsh" if you have that available).
Makes sense, I'm not sure but I don't think bash behaves in this way.
No matter, I can follow this pattern as well, thank you.
--
-Clint
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-14 1:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-13 23:02 Shell sourced function not available to executed script Clint Priest
2017-08-13 23:15 ` Clint Priest
2017-08-13 23:57 ` Bart Schaefer
2017-08-14 1:18 ` Clint Priest
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).