All Questions
Tagged with environment-variables shell
277 questions
2
votes
1
answer
894
views
What do programs use to read their environment?
I'm on Fedora, where all preinstalled shells apparently support bashisms: bash --posix does, and even sh. Still, when I used this function,
pathprepend () {
if [[ ":$PATH:" != *":$1:...
0
votes
1
answer
48
views
best way to load an .env file as exported variables
I find .env files to be funny things, is there a one line utility to do this:
set -o allexport
source .env
set +o allexport
I do not like flipping the shell settings like that, wouldn't it be nice if ...
0
votes
1
answer
81
views
Fish shell add args to $EDITOR using export
How can I add args to the command I use as the $EDITOR in fish shell? Specifically using the export EDITOR=... syntax rather than the set command.
I want to do something like export EDITOR='code --...
0
votes
1
answer
66
views
When is the ENV variable set
according to POSIX, the ENV environment variable is used to specify initialization files to be read (such as some kind of .profile and .rc files), but if this variable is used to specify these files, ...
1
vote
1
answer
126
views
How to store and source environment variables when they contain semicolon (`;`) [duplicate]
I'm trying to exchange environment variables and restore them quickly between terminals.
I define two functions in my shell (~/.bashrc):
save_env(){
mkdir -p ~/tmp
printenv > ~/tmp/env
}
...
2
votes
2
answers
63
views
How to source environment variable in command line with && combiner?
For a NodeJs app, I wrote the following script to deploy the app:
"scripts": {
"deploy": "source private/create_env.sh && ./deploy.sh",
}
private/create_env.sh ...
1
vote
0
answers
58
views
Why am I using an interactive non login shell, but I can still access the environment variables defined in /etc/profile?
According to the bash manual,only login shell will load the /etc/profile file.
When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first ...
0
votes
1
answer
610
views
LINENO and BASH_LINENO
So I'm not sure why this is.. I know ${LINENO} normally contains the line in the script, and BASH_LINENO goes based on input from BASH_SOURCE as an array
$ (echo hi;declare -p LINENO BASH_LINENO;echo ...
-1
votes
2
answers
127
views
How to set one-command-lifelong variables in the shell? [duplicate]
Consider the following example:
file="test" echo $file
My idea is that file persists only during the command echo $file. Although $file does not persist after this command, echo prints ...
0
votes
1
answer
378
views
Set PATH for /bin/sh in Debian:11 image
Background
I am building an image based on Debian:11. I am trying to set the PATH for the /bin/sh with a dynamic value determined at image build-time. (The "at image build time" is important....
4
votes
3
answers
2k
views
Safely save and restore environment variables
I have a script that parses a rudimentary .env file and exports its contents as environment variables, before taking further action:
set -eu
test -f .env && load_dotenv
exec ./foobar x y z &...
0
votes
2
answers
93
views
how to make a subshell a "program"
I want to ignore all pre-existing env variables, and echo just one, like this:
env -i <(
export foo=bar;
env
)
and this would just print:
foo=bar
however, the construct of
env -i <()
...
1
vote
1
answer
793
views
diffing two .env files
I have two env files, let's say x.env and y.env, the order of the variables is different, but the content could be the same but likely different.
Is there some tool I could use to diff the variables?
...
0
votes
0
answers
116
views
Bash script or the like to erase env values that host secrets once used to initialized app in a kubernetes container
I have a flask app that runs in a kube cluster. It does all the right things by using kube secrets to set the env values required to initialize the application. There are some env values I suspect ...
0
votes
2
answers
331
views
Pass a variable that contains a comma as a -v option to qsub
After seeing the reactions on Stack Overflow on this question and an unfamiliarity with qsub, I believe thqt U&L is better suited for this question.
In qsub, we can pass environment variables (a ...