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

The name of the pictureThe name of the pictureThe name of the pictureClash 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?







share|improve this question
















  • 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














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?







share|improve this question
















  • 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












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?







share|improve this question












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?









share|improve this question











share|improve this question




share|improve this question










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












  • 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










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?)






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    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






























    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?)






    share|improve this answer
























      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?)






      share|improve this answer






















        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?)






        share|improve this answer












        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?)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 16 at 17:24









        Jeff Schaller

        31.2k846105




        31.2k846105






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            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













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)