-1
OS: Ubuntu 18.04

I am trying to use my /etc/environment file, to export some variables, to be used by Rails.

cat /etc/environment

....
RAILS_ENV='test'
RAILS_DB_PWD='X35i#98n'

However, when I try:

echo $RAILS_DB_PWD

I get:

X35i

It looks like it's cut off at the #. I would like to include # in the password, and make it available system wide, not just from my local bash shell.

However, if I add this to my .bashrc file, it works fine

Any ideas?

2

2 Answers 2

0

What does shopt show?

echo "${RAILS_DB_PWD}" 

Should prevent the shell from interpreting the # that way.

0

As Elias Soares said in his comment, /etc/environment is not a good place to set a variable with embedded #. Set it in your bash initialization file (for instance /etc/profile) as

RAILS_DB_PWD='X35i#98n'

and it should work. If you intend to span (non-bash) subshells or run programs you are supposed to use this environment variable, don't forget to export it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.