From owner-freebsd-questions Fri Jul 28 9:48: 7 2000 Delivered-To: freebsd-questions@freebsd.org Received: from smof.fiawol.org (fiawol.org [209.122.117.89]) by hub.freebsd.org (Postfix) with ESMTP id A074237BBE2 for ; Fri, 28 Jul 2000 09:48:02 -0700 (PDT) (envelope-from gus@fiawol.org) Received: (from gus@localhost) by smof.fiawol.org (8.9.3/8.9.3) id MAA98488; Fri, 28 Jul 2000 12:47:43 -0400 (EDT) (envelope-from gus) From: Gus Mancuso Message-Id: <200007281647.MAA98488@smof.fiawol.org> Subject: Re: declare -x In-Reply-To: "from Jim Freeze at Jul 27, 2000 01:59:12 pm" To: Jim Freeze Date: Fri, 28 Jul 2000 12:47:42 -0400 (EDT) Cc: questions@freebsd.org X-Mailer: ELM [version 2.4ME+ PL77 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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