I'm trying to understand one of the answers to this question:
Cannot pass an argument to python with "#!/usr/bin/env python"
#!/bin/sh
''''exec python -u -- "$0" ${1+"$@"} # '''
Run Code Online (Sandbox Code Playgroud)
This works well, but I do not understand why it works with four ticks at the beginning of that line rather than three.
In addition, why the hash near the end of that string?
尝试在两台不同的计算机上运行python脚本时遇到问题.在每台计算机上,我想使用python版本2.7.3运行脚本,但我遇到的问题是两台计算机以不同的方式命名python 2.7.3.其中一台计算机运行arch linux,在这台计算机上运行它名为python2.另一台计算机正在运行redhat linux,它使用名称python2.7.3.
我应该在shebang行中使用什么,以便脚本可以在两台计算机上执行而无需任何更改?我真正想要的是某种有条件的shebang系列,它可以选择使用哪个版本的Python.我只是运气不好,我必须保留两个不同版本的脚本?
PS我不能只使用#!/ usr/bin/env python在arch linux计算机上这将引用python 3.2.3,在redhat linux计算机上它将引用python 2.4.