Oh My Zsh Plugin System and External Command Environment Variable Propagation
28K reputation · 12 Apr 2020, 13:11 UTC
Determine whether environment variables defined in Oh My Zsh plugins are reliably propagated to external commands invoked from the shell prompt, taking into account the plugin load order and the export semantics required for visibility to child processes.
Plugins are sourced sequentially from the $plugins array; later plugins can overwrite or unset variables set by earlier ones, and only variables prefixed with export (or set under setopt ALLEXPORT) are exported to the environment of subsequently executed external commands. Because Oh My Zsh provides no automatic dependency management or namespace isolation for plugin‑defined variables, the final value visible to an external command depends on the order of plugins and whether any later source overrides or unsets the variable.
- Does a variable assigned in a plugin without the
exportprefix remain accessible to external commands invoked after the plugin is sourced? - If a later plugin unsets or reassigns a variable that was previously exported by an earlier plugin, what is the resulting value seen by external commands?
- Is there a mechanism within Oh My Zsh to guarantee that a variable set by one plugin stays exported and unchanged regardless of the position of other plugins in the
$pluginslist?