Why did PATH='$PATH:/Path/to/bin' overwrite my PATH?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
In the command line, I appended a directory to my PATH without exporting it:
$ PATH='$PATH:/home/user/anaconda3/bin'
For some reason this has overwritten the PATH environment variable but I'm not sure why this happened. The PATH above is still a colon separated list of directories like it should be so what's the problem? I usually prepend a new directory to my PATH but this time I tested appending it instead which caused unexpected outcomes.
Now any time I try even the simplest commands like ls
I get this error (which I expect) followed by a prompt asking me to install the command I typed:
bash: sed: command not found...
Additionally, since I didn't acually export PATH, the subsequent commands are not supposed to inherit the environment of the above PATH variable so what caused it to happen?.
I know I can open a new terminal window to fix it but I'm interested in knowing why this happened?
linux command-line sed environment-variables path
add a comment |Â
up vote
0
down vote
favorite
In the command line, I appended a directory to my PATH without exporting it:
$ PATH='$PATH:/home/user/anaconda3/bin'
For some reason this has overwritten the PATH environment variable but I'm not sure why this happened. The PATH above is still a colon separated list of directories like it should be so what's the problem? I usually prepend a new directory to my PATH but this time I tested appending it instead which caused unexpected outcomes.
Now any time I try even the simplest commands like ls
I get this error (which I expect) followed by a prompt asking me to install the command I typed:
bash: sed: command not found...
Additionally, since I didn't acually export PATH, the subsequent commands are not supposed to inherit the environment of the above PATH variable so what caused it to happen?.
I know I can open a new terminal window to fix it but I'm interested in knowing why this happened?
linux command-line sed environment-variables path
Related: unix.stackexchange.com/q/400447/117549
â Jeff Schaller
Jul 11 at 19:28
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In the command line, I appended a directory to my PATH without exporting it:
$ PATH='$PATH:/home/user/anaconda3/bin'
For some reason this has overwritten the PATH environment variable but I'm not sure why this happened. The PATH above is still a colon separated list of directories like it should be so what's the problem? I usually prepend a new directory to my PATH but this time I tested appending it instead which caused unexpected outcomes.
Now any time I try even the simplest commands like ls
I get this error (which I expect) followed by a prompt asking me to install the command I typed:
bash: sed: command not found...
Additionally, since I didn't acually export PATH, the subsequent commands are not supposed to inherit the environment of the above PATH variable so what caused it to happen?.
I know I can open a new terminal window to fix it but I'm interested in knowing why this happened?
linux command-line sed environment-variables path
In the command line, I appended a directory to my PATH without exporting it:
$ PATH='$PATH:/home/user/anaconda3/bin'
For some reason this has overwritten the PATH environment variable but I'm not sure why this happened. The PATH above is still a colon separated list of directories like it should be so what's the problem? I usually prepend a new directory to my PATH but this time I tested appending it instead which caused unexpected outcomes.
Now any time I try even the simplest commands like ls
I get this error (which I expect) followed by a prompt asking me to install the command I typed:
bash: sed: command not found...
Additionally, since I didn't acually export PATH, the subsequent commands are not supposed to inherit the environment of the above PATH variable so what caused it to happen?.
I know I can open a new terminal window to fix it but I'm interested in knowing why this happened?
linux command-line sed environment-variables path
edited Jul 11 at 17:34
asked Jul 11 at 17:32
MyWrathAcademia
1369
1369
Related: unix.stackexchange.com/q/400447/117549
â Jeff Schaller
Jul 11 at 19:28
add a comment |Â
Related: unix.stackexchange.com/q/400447/117549
â Jeff Schaller
Jul 11 at 19:28
Related: unix.stackexchange.com/q/400447/117549
â Jeff Schaller
Jul 11 at 19:28
Related: unix.stackexchange.com/q/400447/117549
â Jeff Schaller
Jul 11 at 19:28
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
Single quotes suppress parameter expansion.
$ foo=42
$ echo '$foo' "$foo"
$foo 42
yes, that was it. Does this also apply to environment variables defined in scripts like.profile
and.bashrc
?
â MyWrathAcademia
Jul 11 at 17:56
Also using your example$ echo "$foo" '$foo' '"$foo"' "'$foo'"
ouputs42 $foo "$foo" '42'
â MyWrathAcademia
Jul 11 at 18:03
1
It applies to all parameter expansion everywhere.
â Ignacio Vazquez-Abrams
Jul 11 at 18:06
then its a good thing I never tried this in.profile
or any other environment variable containing files - such a subtle difference yet substantial consequences.
â MyWrathAcademia
Jul 11 at 19:08
The choices between those substantially different consequences have to be made so often it's worth offering such convenient, even subtle shorthand for specifying which of the possible outcomes you want this time.
â jthill
Jul 11 at 20:32
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Single quotes suppress parameter expansion.
$ foo=42
$ echo '$foo' "$foo"
$foo 42
yes, that was it. Does this also apply to environment variables defined in scripts like.profile
and.bashrc
?
â MyWrathAcademia
Jul 11 at 17:56
Also using your example$ echo "$foo" '$foo' '"$foo"' "'$foo'"
ouputs42 $foo "$foo" '42'
â MyWrathAcademia
Jul 11 at 18:03
1
It applies to all parameter expansion everywhere.
â Ignacio Vazquez-Abrams
Jul 11 at 18:06
then its a good thing I never tried this in.profile
or any other environment variable containing files - such a subtle difference yet substantial consequences.
â MyWrathAcademia
Jul 11 at 19:08
The choices between those substantially different consequences have to be made so often it's worth offering such convenient, even subtle shorthand for specifying which of the possible outcomes you want this time.
â jthill
Jul 11 at 20:32
add a comment |Â
up vote
4
down vote
accepted
Single quotes suppress parameter expansion.
$ foo=42
$ echo '$foo' "$foo"
$foo 42
yes, that was it. Does this also apply to environment variables defined in scripts like.profile
and.bashrc
?
â MyWrathAcademia
Jul 11 at 17:56
Also using your example$ echo "$foo" '$foo' '"$foo"' "'$foo'"
ouputs42 $foo "$foo" '42'
â MyWrathAcademia
Jul 11 at 18:03
1
It applies to all parameter expansion everywhere.
â Ignacio Vazquez-Abrams
Jul 11 at 18:06
then its a good thing I never tried this in.profile
or any other environment variable containing files - such a subtle difference yet substantial consequences.
â MyWrathAcademia
Jul 11 at 19:08
The choices between those substantially different consequences have to be made so often it's worth offering such convenient, even subtle shorthand for specifying which of the possible outcomes you want this time.
â jthill
Jul 11 at 20:32
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Single quotes suppress parameter expansion.
$ foo=42
$ echo '$foo' "$foo"
$foo 42
Single quotes suppress parameter expansion.
$ foo=42
$ echo '$foo' "$foo"
$foo 42
answered Jul 11 at 17:34
Ignacio Vazquez-Abrams
31.9k66680
31.9k66680
yes, that was it. Does this also apply to environment variables defined in scripts like.profile
and.bashrc
?
â MyWrathAcademia
Jul 11 at 17:56
Also using your example$ echo "$foo" '$foo' '"$foo"' "'$foo'"
ouputs42 $foo "$foo" '42'
â MyWrathAcademia
Jul 11 at 18:03
1
It applies to all parameter expansion everywhere.
â Ignacio Vazquez-Abrams
Jul 11 at 18:06
then its a good thing I never tried this in.profile
or any other environment variable containing files - such a subtle difference yet substantial consequences.
â MyWrathAcademia
Jul 11 at 19:08
The choices between those substantially different consequences have to be made so often it's worth offering such convenient, even subtle shorthand for specifying which of the possible outcomes you want this time.
â jthill
Jul 11 at 20:32
add a comment |Â
yes, that was it. Does this also apply to environment variables defined in scripts like.profile
and.bashrc
?
â MyWrathAcademia
Jul 11 at 17:56
Also using your example$ echo "$foo" '$foo' '"$foo"' "'$foo'"
ouputs42 $foo "$foo" '42'
â MyWrathAcademia
Jul 11 at 18:03
1
It applies to all parameter expansion everywhere.
â Ignacio Vazquez-Abrams
Jul 11 at 18:06
then its a good thing I never tried this in.profile
or any other environment variable containing files - such a subtle difference yet substantial consequences.
â MyWrathAcademia
Jul 11 at 19:08
The choices between those substantially different consequences have to be made so often it's worth offering such convenient, even subtle shorthand for specifying which of the possible outcomes you want this time.
â jthill
Jul 11 at 20:32
yes, that was it. Does this also apply to environment variables defined in scripts like
.profile
and .bashrc
?â MyWrathAcademia
Jul 11 at 17:56
yes, that was it. Does this also apply to environment variables defined in scripts like
.profile
and .bashrc
?â MyWrathAcademia
Jul 11 at 17:56
Also using your example
$ echo "$foo" '$foo' '"$foo"' "'$foo'"
ouputs 42 $foo "$foo" '42'
â MyWrathAcademia
Jul 11 at 18:03
Also using your example
$ echo "$foo" '$foo' '"$foo"' "'$foo'"
ouputs 42 $foo "$foo" '42'
â MyWrathAcademia
Jul 11 at 18:03
1
1
It applies to all parameter expansion everywhere.
â Ignacio Vazquez-Abrams
Jul 11 at 18:06
It applies to all parameter expansion everywhere.
â Ignacio Vazquez-Abrams
Jul 11 at 18:06
then its a good thing I never tried this in
.profile
or any other environment variable containing files - such a subtle difference yet substantial consequences.â MyWrathAcademia
Jul 11 at 19:08
then its a good thing I never tried this in
.profile
or any other environment variable containing files - such a subtle difference yet substantial consequences.â MyWrathAcademia
Jul 11 at 19:08
The choices between those substantially different consequences have to be made so often it's worth offering such convenient, even subtle shorthand for specifying which of the possible outcomes you want this time.
â jthill
Jul 11 at 20:32
The choices between those substantially different consequences have to be made so often it's worth offering such convenient, even subtle shorthand for specifying which of the possible outcomes you want this time.
â jthill
Jul 11 at 20:32
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f454746%2fwhy-did-path-path-path-to-bin-overwrite-my-path%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Related: unix.stackexchange.com/q/400447/117549
â Jeff Schaller
Jul 11 at 19:28