1
vote
3answers
37 views

How Long do the Contents of the .bash_history File Last?

How can I modify the contents of my bash_history file? What values or variables control how long the history lasts? Are there any other things I can change to provide finer control of my BASH ...
1
vote
1answer
21 views

several virtual profiles for the same user

Many times there are several "identities" which one user uses: for work, open-source, academia etc., all require different ssh keys, editor configurations, git configs etc. I was wondering if there ...
1
vote
1answer
68 views

Why is variable assignment preceding command ignored? [duplicate]

The bash 4.1 manpage states (emphasis added)... Simple Commands A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and ...
1
vote
0answers
46 views

export -f in .bashrc after upgrade to bash 4.3.30 kills builtins?

I recently upgraded my bash (Mac OS X 10.6.8) from 3.2.48(1) to 4.3.30(1) via macports, and while the install seems to have gone smoothly, the two spots in my ~/.bashrc where I had export -f myfunc; ...
2
votes
1answer
83 views

How to pass environment variables to a non-interactive shell (with example)?

In a sh script another sh script is started with su -l <user> -c /path/to/script.sh. As far as I understood script.sh will be run in a non-interactive shell. The official documentation tries to ...
7
votes
1answer
190 views

Why does bash even parse/run stuff put in the environment variable?

The shellshock bug in bash works by way of environment variables. Honestly I was suprised by the fact that there is such a feature like: "passing on of function definitions via env vars" Therefore ...
8
votes
2answers
146 views

Why is the ability to definine functions in an enviromental variable not a security risk in itself?

As I understand it, generally it is considered safe to let anyone provide information that will be stored in an environmental variable. The shellshock vulnerability is an issue here because it means ...
-1
votes
0answers
31 views

Latest Bash shell hack [duplicate]

What is all this recent fuss about Bash being vulnerable? I read that it is somehow related to environment variables but could not get a hold of it. Can someone explain this vulnerability to me?
0
votes
0answers
22 views

Can't set PATH with a script [duplicate]

I have written a script which was supposed to add some value to environmental variable PATH, but script doesn't do that if I start it with ./script.sh. #! /bin/bash INSTALLDIR="/opt/ARM" ...
0
votes
1answer
56 views

Trying to access environment variable (array) declared in ~/.profile from shell script

I'm currently fighting with this problem. I've already read some older posts here on SE, and got the conclusion that the only sane way to put a variable (even an array) is ~/.profile. So OK, array ...
1
vote
1answer
32 views

Global variable for every script

I want to declare a variable in such way that every script can access and alter its value. I have written a script that set the value of a variable called flag on exit and I am using a crontab entry ...
1
vote
2answers
56 views

profile.d on headless server

Is it a bad idea to put variables needed by a daemon program running at boot on a headless system in /etc/profile.d/? From my understanding profile.d doesn't get executed until someone logs into the ...
6
votes
1answer
244 views

Echo difference between Ubuntu and Red Hat

I have mostly been experimenting with Ubuntu but recently was using a Red Hat Enterprise system and was surprised at a difference I found setting and displaying environment variables. In Ubuntu I ...
20
votes
2answers
862 views

Does ~ always equal $HOME

I know this has probably been asked before, but I couldn't find it with Google. Given Linux Kernel No configurations that change $HOME bash Will ~ == $HOME be true?
5
votes
3answers
226 views

Run program with environment set to variables in a file

I would like to run a program (in this case Python) with only the environment variables defined in a file, say vars.env: FOO=bar X=12 Here's a simply Python script that prints the environment: ...
2
votes
1answer
75 views

How can I find where LANG, LANGUAGE and MAIL environmental variables are set?

I've had a few issues with environmental variables not set correctly in my Raspbmc Raspberry Pi. Specifically, I've had to manually specify the following in ~/.bashrc. export LANG='en_AU.UTF-8" ...
14
votes
3answers
658 views

Using variables to store terminal color codes for PS1?

In my .bashrc, I use ANSI terminal color codes to colorize various bits. It looks like this: PS1='\u@\h:\w\[\033[33m\]$(virtual_env)\[\033[32m\]$(git_branch)\[\033[0m\]$ ' where virtual_env and ...
15
votes
2answers
493 views

How do I start all shell sessions in a directory other than $HOME?

When I open my non-login shell in Ubuntu, my present working directory is /home/user_name (my $HOME environment variable), but I want to change this such that when I start my terminal I am in some ...
0
votes
2answers
64 views

Why do I have to execute bash programs with ./? [duplicate]

Why is it that some bash programs will only run on my system when I type ./ before their name? An example: In my [...]/android/sdk folders I have to execute adb like this: ./adb devices Why not ...
3
votes
3answers
521 views

Messed up bash.bashrc file, commands not working anymore

Trying installing Java, I tried to add it to the executable path with the line: export PATH=/usr/lib/jvm/jdk1.7.0_60/bin:$PATH in the system-wide /etc/bash.bashrc file. For some reason this ...
2
votes
1answer
378 views

Bash script for running python virtual environment does not execute

I am trying to wrap the following call into a script, which runs my Python virtual environment: [lucas@lucas-ThinkPad-W520]/home/lucas/bin$ source ...
8
votes
4answers
186 views

Save output of command that modifies environment into a variable

How to save output of a command that modifies environment into a variable? I'm using bash shell. Assume that I have: function f () { a=3; b=4 ; echo "`date`: $a $b"; } And now, I can use commands ...
0
votes
0answers
31 views

Parameters files, pfiles director: how to overwrite default settings

This is a quite general question that I am not sure to be able to address correctly. I must manage some bash or tcsh scripts that invoke other software's tools. These tools are invoked by name and ...
6
votes
2answers
245 views

if statement in .bashrc not working correctly

I set up .bashrc to show a long prompt if the terminal is at least 80 characters wide. Otherwise it shows a degraded, smaller prompt. I use an if statement to achieve this: dp_smaller_than=80 if [ ...
5
votes
3answers
330 views

Is there any harm in using variables that aren't set?

Say I have the following code: # Check if the color prompt is enabled and supported on this system if [ -n "$force_color_prompt" ] && [ -x /usr/bin/tput ] && tput setaf 1 ...
1
vote
2answers
123 views

How to guarantee availability of $BASH_ENV

A non-interactive, non-login shell will try to source any script specified in $BASH_ENV. But how do I guarantee $BASH_ENV is set before a cron job or script has a chance to set $BASH_ENV for any ...
1
vote
2answers
427 views

Setting PATH vs. exporting PATH in ~/.bash_profile [duplicate]

What's the difference and which is better to use when customizing my bash profile? Documentation on the export command is scarce, as it's a builtin cmd. Excerpt from version 1 of my ~/.bash_profile: ...
4
votes
3answers
238 views

Environment variables are not set when my function is called in a pipeline

I have the following recursive function to set environment variables: function par_set { PAR=$1 VAL=$2 if [ "" != "$1" ] then export ${PAR}=${VAL} echo ${PAR}=${VAL} shift ...
2
votes
4answers
331 views

How do I pass a variable from my local server to a remote server?

I am trying to pass a variable from my local server (location1) to a remote server (location2). The purpose of the code is to copy a file from the remote server from a predefined location. In simpler ...
3
votes
1answer
116 views

Difference between “.” and “./” while setting the environment variables using export? [duplicate]

Please excuse me if I am not clear while asking questions. I will try my best to be very clear while asking questions. While learning Embedded Linux, we are setting an environment for our project. ...
1
vote
0answers
65 views

Create global enviromental variable after boot

I know about /etc/profile and /etc/environment, but I would like to set a global environmental variable after boot and login. By global, I mean an environment variable that can be accessed by any ...
1
vote
2answers
191 views

Variable value is not recognized after using gnu parallel?

I have a below shell script from which I am trying to copy 5 files in parallel. I am running my below shell script on machineA which tries to copy the file from machineB and machineC. If the file is ...
18
votes
5answers
1k views

why is setting a variable before a command legal in bash?

I've just encountered several answers such as to parsing a delimited text file... that use the construct: while IFS=, read xx yy zz;do echo $xx $yy $zz done < input_file where the IFS ...
2
votes
4answers
1k views

bash script and local env variable namespace collision

I have a bash script with a variable called VAR_A I also have a local env variable called VAR_A The bash script calls the command: echo ${VAR_A} I am not able to change the variable in the script ...
2
votes
2answers
176 views

What does `env COLUMNS=%S ps …` do?

I have seen the syntax env COLUMNS=%sin shell scripts, e.g. see the line below from the Helm package in Emacs: env COLUMNS=%s ps -axo pid,user,pri,nice,ucomm,tty,start,vsz,%%cpu,%%mem,etime,command ...
4
votes
3answers
151 views

Why does export -p exclude $_ variable?

As far I know, there are 3 ways to see exported variables: $ export -p | wc -l 50 $ env | wc -l 51 $ printenv | wc -l 51 As you can see, export -p misses single variable. It's a $_ one: $ diff ...
1
vote
1answer
50 views

Who is setting http_proxy?

On an Ubuntu system with bash as the default shell for the interested user, the http_proxy environment variable is set to a specific value in a fresh GNOME Terminal. The .bashrc file for this user ...
2
votes
1answer
78 views

Where do I place commands to automatically be exported for all users?

I have an embedded platform running an Arago linux distribution. Right now the only "user" is root but there will eventually be others, but I don't know how many or what user IDs they will have. ...
1
vote
1answer
80 views

$@ and 'set env $PATH' - Why should this statement go into .inputrc?

I have a line in my .zshrc that says: set env $PATH Apparently this affects the value of $@. I have read that $@ should be empty and that I should not have any set statements in my .zshrc (at least ...
3
votes
1answer
36 views

How to read value of variable, where the name of variable is the value of another variable

I think an example is in order. Consider I have these two environment variables setup (by a Continuous Delivery tool): PACKAGE_VER=1.2.3 and USE_VERSION_FROM=PACKAGE_VER. What I want now is a script ...
3
votes
3answers
740 views

How do I create a GUI application launcher for xfce4-terminal with fish but inheriting the environment variables from bash?

If I run fish from a bash prompt, it will inherit the environment variables I have set in my .bashrc and .profile files, including the important $PATH variable. So far so good. Now, I want ...
1
vote
2answers
2k views

Removing a directory from PATH

I'm trying to compile wxWidgets using MingW, and I have cygwin in my path, which seems to conflict. So I would like to remove /d/Programme/cygwin/bin from the PATH variable and I wonder if there is ...
0
votes
3answers
607 views

I have an environment variable for LANG set in ~/.profile but it is not getting set

I want to set the locale. I have this in my ~/.profile #language export LANG=en_GB.utf8 export TESTING123=en_GB.utf8 But when I type: echo $LANG $TESTING123 I get (LANG not set, but TESTING123 ...
8
votes
2answers
2k views

using export in .bashrc

I have noticed in my .bashrc, that some lines have export in front, such as export HISTTIMEFORMAT="%b-%d %H:%M " ... export MYSQL_HISTFILE="/root/.mysql_history" whereas other have not, such as ...
1
vote
2answers
337 views

How to loop through xargs where each script uses a common env variable

Is it possible to initiate 10 of the same shell scripts which also initiate more copies, and have them all use the same env variable? For example: script.sh: #!/bin/bash export ...
0
votes
1answer
162 views

ENV variables in relation to xargs loops

Are env variables (set using export) treated differently when the same script is run multiple times simultaneously? That's a weird question, so here's an example I built out which is similar to my ...
0
votes
0answers
78 views

Application does not see environmental variables

I am running following 32 bit command on 64 bit system: LIBGL_DEBUG=verbose glxinfo32 -v -t | head -5 It's output says direct rendering: No (If you want to find out why, try setting ...
1
vote
2answers
52 views

Running a program to output in Dutch

I'm running KDE Arch linux and trying to update my system using pacman and have it output in Dutch. I've tried the following sudo LANG=nl_NL.UTF-8 pacman -Syy sudo KDE_LANG=nl_NL.UTF-8 pacman -Syy ...
2
votes
1answer
85 views

How to avoid warnings from subshells if the function in PROMPT_COMMAND is not defined?

I'm using the following code to get a nice prompt (including git information etc.): function set_prompt { # magic happens in here ;) } export PROMPT_COMMAND='set_prompt' However, sometimes I ...
1
vote
2answers
100 views

modify user-defined System Variables(that is a number) of remote Server machine using ssh?

I want to modify the value of a System Variable of a remote server . The IP of server is 172.16.22.53. The server runs Windows OS,and Cygwin instlled in it.In ...