eval $PATH produces a path list followed by No such file or directory warning
I have been teaching myself bash scripting and I wanted to add a bin subdirectory in my home directory so i backed up my .bash_profile and modified the path and when i used eval it gave my path list including my new directory and spit out the no such file or directory warning so i restored my copy and same deal. Is this some sort of bug or a problem on my part.
|
How why are you using eval in conjunction with the changed .bash_profile? The source command is more appropriate for testing.
|
May I ask how and why you used eval? How did you modify the PATH? In the terminal or in .bash_profile or .bashrc? What file/directory does it complain about?
|
Oh I am sorry I was not clear I used eval at the cli not in the bash_profile and I don't know which directory it says it after the list prints
|
Please post the exact command you typed in, the exact error message you got and the changes you made to your Bash configuration.
|
If you want to add any dir. to your PATH variable, then add following lines at the end of ~/.bash_profile or ~/.bashrc file:
Quote:
PATH=$PATH:/opt/bin/ export PATH Simply append these two lines at the end of your .bash_profile or .bashrc file. Fyi, these files get sourced automatically when you login. So either exit from session to take new path into effect or do as "source ~/.bash_profile" or "source ~/.bashrc" |
Incidentally, you should also not be playing around with eval unless you know exactly what you're doing.
Eval command and security issues http://mywiki.wooledge.org/BashFAQ/048 99% of the time eval is not only completely unnecessary, it is the wrong choice. Most often we see it used to do things like creating dynamic variable names, when modern shells have other, safer options such as arrays available. As the saying goes, if eval is the answer, then you're asking the wrong question. |
Y
Thank you shivaa I will modify my profile that way.
To David the H. How can I find the value of an environmental variable from command line ? |
Quote:
Code:
echo $PATH |
Quote:
To check value of any env. variable, invoke:- Quote:
|
As mentioned, to see the current value of any parameter, just echo it. Be sure to add double quotes around them to protect the contents from being further evaluated by the shell.
To list all existing parameters, or a specific set, in bash I usually just use the declare built-in, rather than the external env or printenv. It can display existing values as well as set them. Run help declare for a synopsis of the command. |
All times are GMT -5. The time now is 01:54 PM. |