Tag Info

Hot answers tagged

5

Option -0/--null was first introduce on 28-10-2009, and release with GNU coreutils version 8.1. If your coreutils is too old, you should upgrade. Or you can use perl: perl -e '$ENV{_}="/usr/bin/env"; print "$_ => $ENV{$_}\0" for keys %ENV' As @Stéphane Chazelas pointed out in his comment, the above approach doesn't include environment strings that ...


3

To invoke a login shell using sudo just use -i. When command is not specified you'll get a login shell prompt, otherwise you'll get the output of your command. Example (login shell): sudo -i Example (with a specified user): sudo -i -u user Example (with a command): sudo -i -u user whoami Example (print user's $HOME): sudo -i -u user echo \$HOME ...


3

You're giving Bash to much credit. All "login shell" means to Bash is what files are sourced at startup and shutdown. The $HOME variable doesn't figure into it. The Bash docs explain some more what login shell means: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Bash-Startup-Files In fact, Bash doesn't do anything to set $HOME. ...


3

If you are working with python anyway you could use: import os import sys for k in sorted(os.environ): if k == '_': v = '/usr/bin/env' else: v = os.environ[k] sys.stdout.write("{}={}\0".format(k, v)) to get very similar output compared to env --null.


3

As it was discussed in this question most programs don't have 'English' locale but use default ('C') locale with English messages instead. So if I want to use some languages with preferred English then I have to add 'C' locale right after the English locale in the list. In my case the 'LANGUAGES' must be: LANGUAGES=en:C:ru Which means "Use English then ...


2

By default /etc/environment is read as-is, i.e. no parsing / evaluation / interpolation of variable is done. Put another way: it's not meant to be a shell script. That is why the $GRADLE_HOME is literally there in your PATH. You could simply replace the $GRADLE_HOME in your PATH definition with the actual value.


2

You could replace $USER with $(whoami) (a command that is built in on almost all Unix systems). As for why $USER isn't set, it's typically set by login. But since you're SSH'ing into the server instead of using an actual interactive shell, the $USER variable is (and several other environment variables are) never set.


2

Non-interactive shells don't source .bashrc unless manually requested, and moreover, the service likely doesn't invoke shell (unless it has some kind of wrapper script). How to proceed depends on what exactly are you trying to achieve. Services usually have their own config files to modify their behaviour, and environment can also be specified for each ...


2

Environment variables aren't supposed to have an empty name, so many utilities don't support them. The env command from GNU coreutils supports setting the environment variable with an empty name but not unsetting it. That's a bug. $ env '=wibble' env |grep wibble =wibble $ env '=wibble' env -u '' env env: cannot unset `': ...


2

If you use proxy to make internet connection, maybe your system set some environment variable for your user to set the proxy server IP. When you use sudo without -E option, your environment variables are not preserved, so you can't connect to internet, causing add-apt-repository show that error. Checking add-apt-repository source code, you can see: try: ...


1

make is almost certainly executing both lines of commands. However, the line export LD_LIBRARY_PATH=$< (or whatever make expands it) gets executed by a shell that's a child process of the make process. When you type echo $LD_LIBRARY_PATH, you get whatever the environment variable LD_LIBRARY_PATH had in it. Your shell didn't execute the "export", a ...


1

Your node wants to start Chrome (or any browser) and use environment variables to set it out. Just export the variable along with the path pointing to the binary and it should work: export CHROME_BIN=/usr/bin/chromium-browser Now, actually it should just call sensible-browser instead of forcing you to do this.


1

So, combining the answers from @gilles and @bruno-a (and a couple of other sed tricks) I came up with this one-liner, which will remove (every) REMOVE_PART from PATH, regardless of whether it occurs at the beginning, middle or end of PATH PATH=$(REMOVE_PART="/d/Programme/cygwin/bin" sh -c 'echo ":$PATH:" | sed "s@:$REMOVE_PART:@:@g;s@^:\(.*\):\$@\1@"') ...



Only top voted, non community-wiki answers of a minimum length are eligible