What's the difference of using #!/usr/bin/env or #!/bin/env in shebang?

前端 未结 4 866
野的像风
野的像风 2021-02-19 07:19

Will there be any difference or it\'s just a personal choice?

4条回答
  •  终归单人心
    2021-02-19 08:12

    #! tries to run to read and run the rest of the file.

    So #!/usr/bin/env means that there must be a program called /usr/bin/env;
    #!/bin/env means that there must be a program called /bin/env.

    Some systems have one and not the other.

    In my experience, most have /usr/bin/env, so #!/usr/bin/env is more common.

    Unix systems will try to run using execve, which is why it must be a full path, and #!env without a path will not work.

提交回复
热议问题