unix command line execute with . (dot) vs. without

后端 未结 5 567
失恋的感觉
失恋的感觉 2020-12-02 20:57

At a unix command line, what\'s the difference between executing a program by simply typing it\'s name, vs. executing a program by typing a . (dot) followed by the program n

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 21:32

    Running "runme" will create a new process which will go on its merry little way and not affect your shell.

    Running ". runme" will allow the script "runme" to change your environment variables, change directories, and all sorts of other things that you might want it to do for you. It can only do this because it's being interpreted by the shell process that's already running for you. As a consequence, if you're running bash as your login shell, you can only use the "." notation with a bash script, not (for example) a binary on C shell script.

提交回复
热议问题