zsh-users
 help / color / mirror / code / Atom feed
* using variables from .zshenv in shell scripts
@ 2014-12-17 16:16 TJ Luoma
  2014-12-17 17:04 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: TJ Luoma @ 2014-12-17 16:16 UTC (permalink / raw)
  To: Zsh-Users List

Either something weird is happening or I'm missing something really
basic here. (I blame the cold I've had for 2 weeks.)

I have some variables set in ~/.zshenv which I want to use in shell scripts

However, those variables do not seem to be defined when the shell script runs.

For example, if I have this in ~/.zshenv :

export FOO='BAZ'

and then have a shell script:

#!/bin/zsh

echo "Foo is $FOO"

exit 0

shouldn't it output "Foo is BAZ" ?

Instead, I am getting "Foo is "

I thought that shell scripts would read from ~/.zshenv unless the
first line of the shell script included the '-f' such as "#!/bin/zsh
-f"

is there a 'setopt' that I'm missing here?

TjL

(How have I been writing shell scripts for this long and I'm still not
getting something this basic???)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: using variables from .zshenv in shell scripts
  2014-12-17 16:16 using variables from .zshenv in shell scripts TJ Luoma
@ 2014-12-17 17:04 ` Bart Schaefer
  2014-12-17 19:08   ` TJ Luoma
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2014-12-17 17:04 UTC (permalink / raw)
  To: Zsh-Users List

On Dec 17, 11:16am, TJ Luoma wrote:
}
} I have some variables set in ~/.zshenv which I want to use in shell
} scripts
}
} However, those variables do not seem to be defined when the shell
} script runs.

Is there possibly a value for ZDOTDIR already in your environment when
the script runs?

It's also possible that /etc/zshenv is doing something that causes your
$HOME/.zshenv to be skipped.

Try using

     #!/bin/zsh -x

in the script to see what's actually executing.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: using variables from .zshenv in shell scripts
  2014-12-17 17:04 ` Bart Schaefer
@ 2014-12-17 19:08   ` TJ Luoma
  0 siblings, 0 replies; 3+ messages in thread
From: TJ Luoma @ 2014-12-17 19:08 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh-Users List

Now it's doing it, when it wasn't before.

I am left to assume that I had somehow managed to not actually save
the changes to my ~/.zshenv or some such oddity, because I cannot
duplicate it now.

*sigh*

All I need is 3-4 weeks of sleep and I'm sure I'll be back on top of things.

Sorry for the bother

TjL

On Wed, Dec 17, 2014 at 12:04 PM, Bart Schaefer
<schaefer@brasslantern.com> wrote:
> On Dec 17, 11:16am, TJ Luoma wrote:
> }
> } I have some variables set in ~/.zshenv which I want to use in shell
> } scripts
> }
> } However, those variables do not seem to be defined when the shell
> } script runs.
>
> Is there possibly a value for ZDOTDIR already in your environment when
> the script runs?
>
> It's also possible that /etc/zshenv is doing something that causes your
> $HOME/.zshenv to be skipped.
>
> Try using
>
>      #!/bin/zsh -x
>
> in the script to see what's actually executing.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-17 19:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-17 16:16 using variables from .zshenv in shell scripts TJ Luoma
2014-12-17 17:04 ` Bart Schaefer
2014-12-17 19:08   ` TJ Luoma

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).