sourcing csh script does not set the path variable without Bad subtitute

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am writing a simple script to source path variable as below:
#!/bin/csh
echo "setting path"
set path=($path /sbin:/mscc/apps)
However, the path variable does not change and remain the same. The csh shell does not have any errors/warnings.
If I add an invalid line, for example:
setenv PATH $PATH:sbin
It complains "Bad substitute." but the two path above are added. Why is it happening?
path csh
add a comment |Â
up vote
0
down vote
favorite
I am writing a simple script to source path variable as below:
#!/bin/csh
echo "setting path"
set path=($path /sbin:/mscc/apps)
However, the path variable does not change and remain the same. The csh shell does not have any errors/warnings.
If I add an invalid line, for example:
setenv PATH $PATH:sbin
It complains "Bad substitute." but the two path above are added. Why is it happening?
path csh
2
Are you executing the sample script and expecting your current (the parent) shell's $path to change?
â Jeff Schaller
Mar 16 at 17:16
Yes, I expect my current opened shell (from GNOME) to change the $path. I tried your answers with both ways and it is not working. The only time it works is when I add an invalid line at the end of the file (eg, like dummy text: ppp).
â Allen W
Mar 16 at 17:36
sourcing the script doesn't change the path? Did you try using a space instead of a colon?
â Jeff Schaller
Mar 16 at 17:38
Yes, to eliminate the concern, I am setting only one path variable now which has the same result.
â Allen W
Mar 16 at 17:46
Can you edit a transcript of your session into your question, showing your initial path, your execution of the script, and the resulting path?
â Jeff Schaller
Mar 16 at 18:40
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am writing a simple script to source path variable as below:
#!/bin/csh
echo "setting path"
set path=($path /sbin:/mscc/apps)
However, the path variable does not change and remain the same. The csh shell does not have any errors/warnings.
If I add an invalid line, for example:
setenv PATH $PATH:sbin
It complains "Bad substitute." but the two path above are added. Why is it happening?
path csh
I am writing a simple script to source path variable as below:
#!/bin/csh
echo "setting path"
set path=($path /sbin:/mscc/apps)
However, the path variable does not change and remain the same. The csh shell does not have any errors/warnings.
If I add an invalid line, for example:
setenv PATH $PATH:sbin
It complains "Bad substitute." but the two path above are added. Why is it happening?
path csh
asked Mar 16 at 17:14
Allen W
6
6
2
Are you executing the sample script and expecting your current (the parent) shell's $path to change?
â Jeff Schaller
Mar 16 at 17:16
Yes, I expect my current opened shell (from GNOME) to change the $path. I tried your answers with both ways and it is not working. The only time it works is when I add an invalid line at the end of the file (eg, like dummy text: ppp).
â Allen W
Mar 16 at 17:36
sourcing the script doesn't change the path? Did you try using a space instead of a colon?
â Jeff Schaller
Mar 16 at 17:38
Yes, to eliminate the concern, I am setting only one path variable now which has the same result.
â Allen W
Mar 16 at 17:46
Can you edit a transcript of your session into your question, showing your initial path, your execution of the script, and the resulting path?
â Jeff Schaller
Mar 16 at 18:40
add a comment |Â
2
Are you executing the sample script and expecting your current (the parent) shell's $path to change?
â Jeff Schaller
Mar 16 at 17:16
Yes, I expect my current opened shell (from GNOME) to change the $path. I tried your answers with both ways and it is not working. The only time it works is when I add an invalid line at the end of the file (eg, like dummy text: ppp).
â Allen W
Mar 16 at 17:36
sourcing the script doesn't change the path? Did you try using a space instead of a colon?
â Jeff Schaller
Mar 16 at 17:38
Yes, to eliminate the concern, I am setting only one path variable now which has the same result.
â Allen W
Mar 16 at 17:46
Can you edit a transcript of your session into your question, showing your initial path, your execution of the script, and the resulting path?
â Jeff Schaller
Mar 16 at 18:40
2
2
Are you executing the sample script and expecting your current (the parent) shell's $path to change?
â Jeff Schaller
Mar 16 at 17:16
Are you executing the sample script and expecting your current (the parent) shell's $path to change?
â Jeff Schaller
Mar 16 at 17:16
Yes, I expect my current opened shell (from GNOME) to change the $path. I tried your answers with both ways and it is not working. The only time it works is when I add an invalid line at the end of the file (eg, like dummy text: ppp).
â Allen W
Mar 16 at 17:36
Yes, I expect my current opened shell (from GNOME) to change the $path. I tried your answers with both ways and it is not working. The only time it works is when I add an invalid line at the end of the file (eg, like dummy text: ppp).
â Allen W
Mar 16 at 17:36
sourcing the script doesn't change the path? Did you try using a space instead of a colon?
â Jeff Schaller
Mar 16 at 17:38
sourcing the script doesn't change the path? Did you try using a space instead of a colon?
â Jeff Schaller
Mar 16 at 17:38
Yes, to eliminate the concern, I am setting only one path variable now which has the same result.
â Allen W
Mar 16 at 17:46
Yes, to eliminate the concern, I am setting only one path variable now which has the same result.
â Allen W
Mar 16 at 17:46
Can you edit a transcript of your session into your question, showing your initial path, your execution of the script, and the resulting path?
â Jeff Schaller
Mar 16 at 18:40
Can you edit a transcript of your session into your question, showing your initial path, your execution of the script, and the resulting path?
â Jeff Schaller
Mar 16 at 18:40
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
I can only duplicate this if I execute such a script:
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
$ ./script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
If you instead source the script, you'll see different behavior:
$ source script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin /sbin:/mscc/apps
(Perhaps you want /sbin /mscc/apps with a space instead of a colon separating the elements?)
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I can only duplicate this if I execute such a script:
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
$ ./script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
If you instead source the script, you'll see different behavior:
$ source script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin /sbin:/mscc/apps
(Perhaps you want /sbin /mscc/apps with a space instead of a colon separating the elements?)
add a comment |Â
up vote
1
down vote
I can only duplicate this if I execute such a script:
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
$ ./script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
If you instead source the script, you'll see different behavior:
$ source script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin /sbin:/mscc/apps
(Perhaps you want /sbin /mscc/apps with a space instead of a colon separating the elements?)
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I can only duplicate this if I execute such a script:
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
$ ./script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
If you instead source the script, you'll see different behavior:
$ source script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin /sbin:/mscc/apps
(Perhaps you want /sbin /mscc/apps with a space instead of a colon separating the elements?)
I can only duplicate this if I execute such a script:
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
$ ./script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin
If you instead source the script, you'll see different behavior:
$ source script.csh
setting path
$ echo $path
/usr/local/bin /usr/bin /usr/local/sbin /usr/sbin /sbin:/mscc/apps
(Perhaps you want /sbin /mscc/apps with a space instead of a colon separating the elements?)
answered Mar 16 at 17:24
Jeff Schaller
31.2k846105
31.2k846105
add a comment |Â
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%2f430656%2fsourcing-csh-script-does-not-set-the-path-variable-without-bad-subtitute%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
2
Are you executing the sample script and expecting your current (the parent) shell's $path to change?
â Jeff Schaller
Mar 16 at 17:16
Yes, I expect my current opened shell (from GNOME) to change the $path. I tried your answers with both ways and it is not working. The only time it works is when I add an invalid line at the end of the file (eg, like dummy text: ppp).
â Allen W
Mar 16 at 17:36
sourcing the script doesn't change the path? Did you try using a space instead of a colon?
â Jeff Schaller
Mar 16 at 17:38
Yes, to eliminate the concern, I am setting only one path variable now which has the same result.
â Allen W
Mar 16 at 17:46
Can you edit a transcript of your session into your question, showing your initial path, your execution of the script, and the resulting path?
â Jeff Schaller
Mar 16 at 18:40