|
It's confusing because the Unix-y side of IBM i seems nestled in arms of
the classic side.
In "real" Unix, the OS is a runtime env, device handler and task
scheduler. When a user logs in, a process is created and the shell chosen
by/for that user is launched. The shell is just a command interpreting
program, a very sophisticated one that amounts to a programming language in
itself.
As the shell loads, it reads config files in a hierarchical order, the
user's own config files last and overriding anything that came before.
The commands in the green screen that change env vars for PASE / QSH
sessions effectively set those variables for shells as they launch, but
they can always be overridden in the particular user session, either in the
.profile (or .bashrc or .bash_profile) or subsequently by user manual
command entry or by scripts.
One trick that always traps the beginner: A script you execute from a Unix
shell runs in its own process, inheriting from the parent process, BUT not
writing back to it. If a script exports a variable, any command the script
calls (and any command THAT command calls, nesting down) gets the new
variable value. BUT when the script is done, the parent shell DOES NOT have
that new variable.
If you write a script to change the current shell's variables, you invoke
it with the source command, or dot (.) which is the same thing.
$ cat ./chgvar.sh
EXPORT foo="bar"
echo $foo
$ ./chgvar.sh
bar
$ echo $foo
$ . ./chgvar.sh
bar
$ echo $foo
bar
On Fri, Jan 4, 2019 at 11:14 AM Justin Taylor <JUSTIN@xxxxxxxxxxxxx>
wrote:
Thanks guys. I thought it would be fine, but I've never overwritten an
IBM environment variable before. I wanted to be sure.
I have a Python package that can't handle POSIX time zones. Now I can
try changing the variable safe in the knowledge I won't break anything
outside my current session.
-----Original Message-----
From: Jack Woehr [mailto:jwoehr@xxxxxxxxxxxxxxxxxxxxxxxx]
Sent: Thursday, January 03, 2019 4:01 PM
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxx>
Subject: Re: [IBMiOSS] bash overwrite environment variable
yes
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
Jack Woehr
Absolute Performance, Inc.
12303 Airport Way, Suite 100
Broomfield, CO 80021
NON-DISCLOSURE NOTICE: This communication including any and all
attachments is for the intended recipient(s) only and may contain
confidential and privileged information. If you are not the intended
recipient of this communication, any disclosure, copying further
distribution or use of this communication is prohibited. If you received
this communication in error, please contact the sender and delete/destroy
all copies of this communication immediately.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.