Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jul 2000 12:47:42 -0400 (EDT)
From:      Gus Mancuso <gus@fiawol.org>
To:        Jim Freeze <jim@freeze.org>
Cc:        questions@freebsd.org
Subject:   Re: declare -x
Message-ID:  <200007281647.MAA98488@smof.fiawol.org>
In-Reply-To: <Pine.BSF.4.21.0007271356350.93317-100000@web2.sea.nwserv.com> "from Jim Freeze at Jul 27, 2000 01:59:12 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
As others have already pointed out, declare is a bash builtin, and 
should probably be avoided.  As to why it doesn't work in scripts,
there are a couple of reasons why it might not.  First, if your
scripts start out (as they should) with #!/bin/sh, then they won't
be using bash, and thus, no declare builtin is available.  Also,
unless you "source" the script, it gets its own environment.  WHich
means, that when you change the environment in a script, the altered
environment is the _script's_, not the calling shell's.

There's probably more reasons, but those pop to my head first.

Hope that's helpful

-Gus

> I accidently discoverd that I can use 
> 
> declare -x ENVVAR="value"
> 
> from a bash command line to set an environment variable.
> 
> However, I cannot find 'declare' in the man pages (so I don't know what
> the -x does) and I cannot run this in a script. Works only from the
> command line.
> 
> Can someone tell me what 'declare' does, how to automate it in a script,
> and where the man pages on it are.
> 
> Thanks
> 
> 
> ============================================
> Jim Freeze
> jim@freeze.org
> --------------
> Save on CDs, DVDs, Movies and Books
> Visit www.freeze.org
> ============================================
> 
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message
> 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007281647.MAA98488>