Questions tagged [environment-variables]
For questions pertaining to environment variables, a set of dynamic variables that can affect the running processes behavior and access to resources. Use this tag for questions about environment variables or questions about issues arising from the impact of setting or modifying the variables value in running processes behavior and access to resources.
1,592 questions
0 votes
1 answer
50 views
Why do environment variables in `~/.profile` appear in `systemctl --user show-environment` but not in my terminal?
I added some environment variables to my ~/.profile, for example: export PIPX_BIN_DIR=$HOME/.pipx-global/bin This works as expected—the executables installed via pipx are placed in the correct ...
0 votes
2 answers
69 views
How to start vipw/vigr without my vimrc?
my vimrc seems to not play along with vipw/vigr (probably because i only allow root to place tmp/buffers/etc in a secure location) so I tried (using bash): user@host$ EDITOR='/usr/bin/vim -u NONE' ...
7 votes
1 answer
281 views
Newlines in environment variable names under POSIX sh
This question asks how to get a list of environment variable names in POSIX sh. The top answer suggests invoking awk via the shell, but gives this caveat: The output is ambiguous if the name of an ...
0 votes
7 answers
2k views
Is it possible to protect a bash script against a hostile environment?
Bash allows to export read-only variables and functions to the environment. Also, when a bash script is run, Bash sources the file BASH_ENV was set to, unless invoked with -p. How do you protect ...
0 votes
0 answers
57 views
LibreOffice crashes with Miniconda3 in path
this is a post that has workaround but not an explanation Sometime in last 4 weeks my LibreOffice on my debian started crashing. Not producing window with eg. LOWriter, just a "crashed docs ...
0 votes
2 answers
99 views
How to temporarily substitute the login shell for running a shell command/subprocess?
My login shell is Fish, but I would like to execute a shell command (apt install ...) as if my login shell was Bash. Is it possible to make a command/subprocess believe that my login shell is /usr/bin/...
-4 votes
1 answer
89 views
Are simple command variable assignments accessible in nested scripts? e.g., does `child.sh` have "FOO=BAR" when running "FOO=BAR ./parent.sh"?
Although this is easy to try and see, I was looking for the answer on StackOverflow and couldn't find it. That's why I'm asking and answering my question. I recommend reading this first. The answer is ...
0 votes
0 answers
46 views
bash variable substitution inside heredoc delimiter: how does it work? [duplicate]
For a school project, I am tasked with making my own (simplified) shell, with bash being the reference point. This includes replicating heredoc behavior which was fun until I stumbled upon variable ...
2 votes
4 answers
202 views
Is there a Bash variable containing the name of the previously executed function?
I want to line up a couple of Bash functions based on the success or failure of the execution of the preceding function. If something fails, I want to print an error message: function_x has failed. ...
0 votes
0 answers
166 views
Resetting service environment variables on stop or restart
I'm looking to undo or essentially reset any environment variable changes made by the service when it stops. Can this be done easily by systemd, I haven't found any straight forward way to do so using ...
0 votes
1 answer
107 views
How to make bash not set the underscore _ environment variable?
How to make bash not set the underscrore _ variable for the processes that it's starting? Explanation of what it is if you haven't encountered it before: If you launch env from bash, you'll see the ...
0 votes
0 answers
50 views
How should one choose whether to utilise ~ or $HOME? [duplicate]
Context When utilising the IEEE Standard 1003.1-2017 Shell Command Language, I frequently want to reference the value which $HOME contains. However, two methods of dynamically acquiring the path are ...
0 votes
2 answers
6k views
How to check if env exist in bash?
What is the standard way, in bash, to check if an environment variable is set up? I'm a little confused between the following options: ! [ -z "${VAR}" ] [ -n "${VAR}" ] [ "${...
3 votes
1 answer
957 views
how to pass environment variables to singularity exec
I have a BASH pipeline which at a point runs a Singularity container with singularity exec as follows: singularity exec --bind `pwd`:/folder --bind $d:/results <image>.sif <tool_command> -...
5 votes
1 answer
1k views
My bash script keeps telling me my directory doesn't exist even though it does [duplicate]
I have a script and when I run it, it returns Directory not found: ~/Pictures/Wallpaper The script is as follows: #!/bin/bash # Check if the wallpaper directory exists if [ ! -d "$WALLPAPER_DIR&...