I'm trying to understand how zsh modules are loaded. According to the docs:
Some optional parts of zsh are in modules, separate from the core of the shell. Each of these modules may be linked in to the shell at build time, or can be dynamically linked while the shell is running if the installation supports this feature. Modules are linked at runtime with the zmodload command.
If I startup a new shell and run the command zmodload it displays the currently loaded modules (zsh/datetime is not loaded).
I can load it at run time using zmodload zsh/datetime. If I then run zmodload again, I can see that it's now listed.
However, when I execute the script like this, the zmodload command can't be found:
%./testload.zsh
#!/usr/bin/env zsh
zmodload zsh/datetime
echo "EPOCHSECONDS: $EPOCHSECONDS"
./testload.zsh: line 3: zmodload: command not found
But, if I execute the script while invoking a new zsh shell, it runs successfully:
% zsh testload.zsh
#!/usr/bin/env zsh
zmodload zsh/datetime
echo "EPOCHSECONDS: $EPOCHSECONDS"
EPOCHSECONDS: 1501004101
Any idea why this behavior is occurring?