I wanted to load a secret value like a password when using a script on bash. I found this method of loading from a file rather exporting on bash profile.
I wrote this sample script to test it
cat -n run.sh
1 echo $val1
2 echo "-line1----"
3 set -o
4 source /tmp/jas/test.txt
5 set +o
6 echo $val1
7 echo $val2
8 echo "--line2---"
9 echo $val2
Seems it is working good , but when I run the script , I see output as
-line1----
allexport off
braceexpand on
emacs off
errexit off
errtrace off
functrace off
hashall on
histexpand off
history off
ignoreeof off
interactive-comments on
keyword off
monitor off
noclobber off
noexec off
noglob off
nolog off
notify off
nounset off
onecmd off
physical off
pipefail off
posix off
privileged off
verbose off
vi off
xtrace off
set +o allexport
set -o braceexpand
set +o emacs
set +o errexit
set +o errtrace
set +o functrace
set -o hashall
set +o histexpand
set +o history
set +o ignoreeof
set -o interactive-comments
set +o keyword
set +o monitor
set +o noclobber
set +o noexec
set +o noglob
set +o nolog
set +o notify
set +o nounset
set +o onecmd
set +o physical
set +o pipefail
set +o posix
set +o privileged
set +o verbose
set +o vi
set +o xtrace
value1
value2
--line2---
value2
Can someone help me with
- what are those values or suggestions on screen ? how to ignore them when I run a script?
- once the script is done, on command like I tried
$echo $val1
and got no result. So it seems like working and being used on script only. But I feel this is a security issue in a different level that, one knows the path of file can read the values as they are in plane text. Is there any better way?