From owner-freebsd-questions Mon May 24 15:40:33 1999 Delivered-To: freebsd-questions@freebsd.org Received: from www.inx.de (www.inx.de [195.21.255.251]) by hub.freebsd.org (Postfix) with ESMTP id B27FC14CF9 for ; Mon, 24 May 1999 15:40:22 -0700 (PDT) (envelope-from jnickelsen@acm.org) Received: from n65-53.berlin.snafu.de ([194.42.65.53] helo=goting.jn.berlin.snafu.de) by www.inx.de with esmtp (Exim 2.12 #2) id 10m3ON-0001K8-00; Tue, 25 May 1999 00:40:20 +0200 Received: from ockholm.jn.berlin.snafu.de (ockholm.jn.berlin.snafu.de [10.0.0.3]) by goting.jn.berlin.snafu.de (Postfix) with ESMTP id 8728117D; Tue, 25 May 1999 00:14:05 +0200 (CEST) Date: Tue, 25 May 1999 00:14:14 +0200 From: Juergen Nickelsen To: "Alexey V.Vinogradov" Cc: freebsd-questions@FreeBSD.ORG Subject: Re: about stty and TERM variable Message-ID: <829909.3136580054@ockholm.jn.berlin.snafu.de> In-Reply-To: <199905241116.OAA21115@Sun.Farlep.Net> Originator-Info: login-id=nickel; server=goting.jn.berlin.snafu.de X-Mailer: Mulberry Demo (MacOS) [1.4.2.1, s/n Evaluation] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --On Mon, 24. Mai 1999 14:16 +0300 "Alexey V.Vinogradov" wrote: > who i can change TERM variable for stty? > i do in sh shell scripts TERM=vt100; export TERM > and have after run: > tput: no terminal tipe specified and no TERM enviromental variable If you set or unset an environment variable of a process (usually the shell), the change will be inherited to the child processes, but not to the parent. Changing environment variables in a shell script will thus effect the shell script and the programs started by the script, but not your login shell (which, I assume, has started the script). To change an environment variable for your login shell (or any other interactive shell), set it either by hand or in a script that is sourced by this shell (without starting a subprocess), or in a shell function or alias. For instance, I have a shell function (I use bash) "path" to change the PATH variable. It calls a perl script, which does things to PATH (show the PATH, add or delete components, or even call a text editor on PATH). The script then writes the new PATH setting to stdout, which is evaluated by the shell function. This works, because a shell function runs in the process context of the shell which called the function. Oh well, I think this still sounds complicated. Let me summarize: - *Calling* a script (or any other program) to set an environment variable in your current shell does *not* work. - *Sourcing* a script (which is then executed by your current shell) works. ("." with sh, ksh, zsh, bash; "source" with csh, tcsh.) - Using a shell function or alias works. E. g. to add a directory in front of the path you could use a shell function like adpath () { [ "$1" != "" ] && PATH=$1:$PATH ; } for sh, ksh, zsh, bash; or for csh and tcsh an alias like alias addpath 'set path = ( \!* $path )' Greetings, Juergen. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message