"linux bash export vars between shell instances" Code Answer's
You're definitely familiar with the best coding language Shell/Bash that developers use to develop their projects and they get all their queries like "linux bash export vars between shell instances" answered properly. Developers are finding an appropriate answer about linux bash export vars between shell instances related to the Shell/Bash coding language. By visiting this online portal developers get answers concerning Shell/Bash codes question like linux bash export vars between shell instances. Enter your desired code related query in the search bar and get every piece of information about Shell/Bash code related question on linux bash export vars between shell instances.
linux bash export vars between shell instances
export_global_var () {
filename=/tmp/env
test -f $filename || touch $filename
{
flock 0 #prevents isssues with multi thread process
#set -x #enables verbose/debug
. /tmp/env
[ $# -eq 0 ] || export "$@"
echo "$@"
#echo "$@" >> /tmp/env #export into file
KEY=`echo "$@" | awk '{split($0,a,"="); print a[1]}'`
#sed '/"$KEY"/c > "$@"' $filename
VAR_IN_FILE=`cat $filename | grep "$KEY"`
(grep -q "$KEY" $filename || echo "$@" >> $filename) && grep -rl "$KEY" $filename | xargs sed -i "s/$VAR_IN_FILE/$@/g"
} < $filename
source $filename #import into mem
}
import_global_var () {
filename=/tmp/env
echo "importing global variables..."
source $filename #import into mem
}
USAGE:
export_global_var DEPLOY_BOOLEAN=0 EXEC=1 #export var gobally
import_global_var #import vars from global vars
All those coders who are working on the Shell/Bash based application and are stuck on linux bash export vars between shell instances can get a collection of related answers to their query. Programmers need to enter their query on linux bash export vars between shell instances related to Shell/Bash code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about linux bash export vars between shell instances for the programmers working on Shell/Bash code while coding their module. Coders are also allowed to rectify already present answers of linux bash export vars between shell instances while working on the Shell/Bash language code. Developers can add up suggestions if they deem fit any other answer relating to "linux bash export vars between shell instances". Visit this developer's friendly online web community, CodeProZone, and get your queries like linux bash export vars between shell instances resolved professionally and stay updated to the latest Shell/Bash updates.