How to execute an alias, encapsulated in another source file?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















For instance



~/.cshrc:



alias job_start 'cd $PROJ_DIR && source .env/bin/activate.csh && rehash && job_run'



$PROJ_DIR/.env/bin/activate.csh:



alias job_run '(cd $PROJ_DIR/builds; sh run.sh)'


after calling job_start:



% job_start [4/36]
job_run: Command not found.


But aliases updates after calling job_start -> job_run appears.



Manually calling job_run will proceed as expected.










share|improve this question






























    0















    For instance



    ~/.cshrc:



    alias job_start 'cd $PROJ_DIR && source .env/bin/activate.csh && rehash && job_run'



    $PROJ_DIR/.env/bin/activate.csh:



    alias job_run '(cd $PROJ_DIR/builds; sh run.sh)'


    after calling job_start:



    % job_start [4/36]
    job_run: Command not found.


    But aliases updates after calling job_start -> job_run appears.



    Manually calling job_run will proceed as expected.










    share|improve this question


























      0












      0








      0








      For instance



      ~/.cshrc:



      alias job_start 'cd $PROJ_DIR && source .env/bin/activate.csh && rehash && job_run'



      $PROJ_DIR/.env/bin/activate.csh:



      alias job_run '(cd $PROJ_DIR/builds; sh run.sh)'


      after calling job_start:



      % job_start [4/36]
      job_run: Command not found.


      But aliases updates after calling job_start -> job_run appears.



      Manually calling job_run will proceed as expected.










      share|improve this question
















      For instance



      ~/.cshrc:



      alias job_start 'cd $PROJ_DIR && source .env/bin/activate.csh && rehash && job_run'



      $PROJ_DIR/.env/bin/activate.csh:



      alias job_run '(cd $PROJ_DIR/builds; sh run.sh)'


      after calling job_start:



      % job_start [4/36]
      job_run: Command not found.


      But aliases updates after calling job_start -> job_run appears.



      Manually calling job_run will proceed as expected.







      alias tcsh csh






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 25 '17 at 11:00









      GAD3R

      28k1958114




      28k1958114










      asked Jan 25 '17 at 10:45









      kAldownkAldown

      67210




      67210




















          1 Answer
          1






          active

          oldest

          votes


















          0














          Have your alias source a script, rather than trying to have it execute things directly:



          alias job_start 'cd $PROJ_DIR && source ~/bin/job_start'


          where ~/bin/job_start looks like this:



          source .env/bin/activate.csh
          rehash
          job_run


          Alternatively, if the changes to the enviroment don't need to be retained, you could just have the alias execute ~/bin/job_start.



          Also, if ~/bin is in your path, renaming ~/bin/job_start script to something else might be appropriate :-)






          share|improve this answer























          • Sorry, I can't understand your advice :D. You didn't ask the question and didn't write a solution either.

            – kAldown
            Jan 25 '17 at 11:56












          • Yes I did? Your problem is that the alias tries to figure out what to do when the alias is defined. That doesn't work for things that aren't defined yet when the alias is created. The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do)

            – Wouter Verhelst
            Jan 25 '17 at 11:58











          • The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do) -> Isn't that what I've did already by calling source activate.csh, which contains alias of a script, that I want to be executed?

            – kAldown
            Jan 25 '17 at 12:01











          • yes, but the new alias isn't created in a way that makes it visible for the old alias. If you run it in a separate script (which gets sourced), then it is. That is why you need to source rather than directly add things in your alias. This is also what the official tcsh website suggests (TIP#1) for your problem.

            – Wouter Verhelst
            Jan 25 '17 at 12:23











          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          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%2f340009%2fhow-to-execute-an-alias-encapsulated-in-another-source-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Have your alias source a script, rather than trying to have it execute things directly:



          alias job_start 'cd $PROJ_DIR && source ~/bin/job_start'


          where ~/bin/job_start looks like this:



          source .env/bin/activate.csh
          rehash
          job_run


          Alternatively, if the changes to the enviroment don't need to be retained, you could just have the alias execute ~/bin/job_start.



          Also, if ~/bin is in your path, renaming ~/bin/job_start script to something else might be appropriate :-)






          share|improve this answer























          • Sorry, I can't understand your advice :D. You didn't ask the question and didn't write a solution either.

            – kAldown
            Jan 25 '17 at 11:56












          • Yes I did? Your problem is that the alias tries to figure out what to do when the alias is defined. That doesn't work for things that aren't defined yet when the alias is created. The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do)

            – Wouter Verhelst
            Jan 25 '17 at 11:58











          • The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do) -> Isn't that what I've did already by calling source activate.csh, which contains alias of a script, that I want to be executed?

            – kAldown
            Jan 25 '17 at 12:01











          • yes, but the new alias isn't created in a way that makes it visible for the old alias. If you run it in a separate script (which gets sourced), then it is. That is why you need to source rather than directly add things in your alias. This is also what the official tcsh website suggests (TIP#1) for your problem.

            – Wouter Verhelst
            Jan 25 '17 at 12:23















          0














          Have your alias source a script, rather than trying to have it execute things directly:



          alias job_start 'cd $PROJ_DIR && source ~/bin/job_start'


          where ~/bin/job_start looks like this:



          source .env/bin/activate.csh
          rehash
          job_run


          Alternatively, if the changes to the enviroment don't need to be retained, you could just have the alias execute ~/bin/job_start.



          Also, if ~/bin is in your path, renaming ~/bin/job_start script to something else might be appropriate :-)






          share|improve this answer























          • Sorry, I can't understand your advice :D. You didn't ask the question and didn't write a solution either.

            – kAldown
            Jan 25 '17 at 11:56












          • Yes I did? Your problem is that the alias tries to figure out what to do when the alias is defined. That doesn't work for things that aren't defined yet when the alias is created. The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do)

            – Wouter Verhelst
            Jan 25 '17 at 11:58











          • The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do) -> Isn't that what I've did already by calling source activate.csh, which contains alias of a script, that I want to be executed?

            – kAldown
            Jan 25 '17 at 12:01











          • yes, but the new alias isn't created in a way that makes it visible for the old alias. If you run it in a separate script (which gets sourced), then it is. That is why you need to source rather than directly add things in your alias. This is also what the official tcsh website suggests (TIP#1) for your problem.

            – Wouter Verhelst
            Jan 25 '17 at 12:23













          0












          0








          0







          Have your alias source a script, rather than trying to have it execute things directly:



          alias job_start 'cd $PROJ_DIR && source ~/bin/job_start'


          where ~/bin/job_start looks like this:



          source .env/bin/activate.csh
          rehash
          job_run


          Alternatively, if the changes to the enviroment don't need to be retained, you could just have the alias execute ~/bin/job_start.



          Also, if ~/bin is in your path, renaming ~/bin/job_start script to something else might be appropriate :-)






          share|improve this answer













          Have your alias source a script, rather than trying to have it execute things directly:



          alias job_start 'cd $PROJ_DIR && source ~/bin/job_start'


          where ~/bin/job_start looks like this:



          source .env/bin/activate.csh
          rehash
          job_run


          Alternatively, if the changes to the enviroment don't need to be retained, you could just have the alias execute ~/bin/job_start.



          Also, if ~/bin is in your path, renaming ~/bin/job_start script to something else might be appropriate :-)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 25 '17 at 11:54









          Wouter VerhelstWouter Verhelst

          7,579935




          7,579935












          • Sorry, I can't understand your advice :D. You didn't ask the question and didn't write a solution either.

            – kAldown
            Jan 25 '17 at 11:56












          • Yes I did? Your problem is that the alias tries to figure out what to do when the alias is defined. That doesn't work for things that aren't defined yet when the alias is created. The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do)

            – Wouter Verhelst
            Jan 25 '17 at 11:58











          • The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do) -> Isn't that what I've did already by calling source activate.csh, which contains alias of a script, that I want to be executed?

            – kAldown
            Jan 25 '17 at 12:01











          • yes, but the new alias isn't created in a way that makes it visible for the old alias. If you run it in a separate script (which gets sourced), then it is. That is why you need to source rather than directly add things in your alias. This is also what the official tcsh website suggests (TIP#1) for your problem.

            – Wouter Verhelst
            Jan 25 '17 at 12:23

















          • Sorry, I can't understand your advice :D. You didn't ask the question and didn't write a solution either.

            – kAldown
            Jan 25 '17 at 11:56












          • Yes I did? Your problem is that the alias tries to figure out what to do when the alias is defined. That doesn't work for things that aren't defined yet when the alias is created. The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do)

            – Wouter Verhelst
            Jan 25 '17 at 11:58











          • The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do) -> Isn't that what I've did already by calling source activate.csh, which contains alias of a script, that I want to be executed?

            – kAldown
            Jan 25 '17 at 12:01











          • yes, but the new alias isn't created in a way that makes it visible for the old alias. If you run it in a separate script (which gets sourced), then it is. That is why you need to source rather than directly add things in your alias. This is also what the official tcsh website suggests (TIP#1) for your problem.

            – Wouter Verhelst
            Jan 25 '17 at 12:23
















          Sorry, I can't understand your advice :D. You didn't ask the question and didn't write a solution either.

          – kAldown
          Jan 25 '17 at 11:56






          Sorry, I can't understand your advice :D. You didn't ask the question and didn't write a solution either.

          – kAldown
          Jan 25 '17 at 11:56














          Yes I did? Your problem is that the alias tries to figure out what to do when the alias is defined. That doesn't work for things that aren't defined yet when the alias is created. The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do)

          – Wouter Verhelst
          Jan 25 '17 at 11:58





          Yes I did? Your problem is that the alias tries to figure out what to do when the alias is defined. That doesn't work for things that aren't defined yet when the alias is created. The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do)

          – Wouter Verhelst
          Jan 25 '17 at 11:58













          The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do) -> Isn't that what I've did already by calling source activate.csh, which contains alias of a script, that I want to be executed?

          – kAldown
          Jan 25 '17 at 12:01





          The solution to that is that you should do something which is guaranteed to be possible (i.e., source a different script) which can then do whatever is needed (in your case, do what your alias currently tries to do) -> Isn't that what I've did already by calling source activate.csh, which contains alias of a script, that I want to be executed?

          – kAldown
          Jan 25 '17 at 12:01













          yes, but the new alias isn't created in a way that makes it visible for the old alias. If you run it in a separate script (which gets sourced), then it is. That is why you need to source rather than directly add things in your alias. This is also what the official tcsh website suggests (TIP#1) for your problem.

          – Wouter Verhelst
          Jan 25 '17 at 12:23





          yes, but the new alias isn't created in a way that makes it visible for the old alias. If you run it in a separate script (which gets sourced), then it is. That is why you need to source rather than directly add things in your alias. This is also what the official tcsh website suggests (TIP#1) for your problem.

          – Wouter Verhelst
          Jan 25 '17 at 12:23

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f340009%2fhow-to-execute-an-alias-encapsulated-in-another-source-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown






          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay