shebang

How to create Sublime Text 3 build system which reads shebang

落爺英雄遲暮 提交于 2019-12-04 14:06:14
How can I create a build system in Sublime Text 3 where "cmd" is replaced with a shebang if it exists? More specifically, is there a way to alter the Python build system to use the version of Python specified in the shebang, and use a default if no shebang is present? Sublime build systems have an option named target which specifies a WindowCommand that is to be invoked to perform the build. By default this is the internal exec command. You can create your own command that would examine the file for a shebang and use that interpreter or some default otherwise. For example (caveat: I'm not

Shebang for psql

↘锁芯ラ 提交于 2019-12-04 12:17:31
问题 I'm trying to write PostgreSQL script(s) but having a problem with shebang line #! /usr/bin/psql [ psql_args_here ] -f select now(); This gives me error as if I just entered psql without any arguments in command line. How do I do it right? 回答1: The problem is that psql don't skip the first line of the file. You could try #! /bin/sh exec sh -c "tail -n +3 $0 | psql -f -" select now(); or simply #! /bin/sh psql << E_O_SQL select now(); E_O_SQL 回答2: There is a even better solution. The first

Relative shebang: How to write an executable script running portable interpreter which comes with it

 ̄綄美尐妖づ 提交于 2019-12-04 09:02:06
Let's say we have a program/package which comes along with its own interpreter and a set of scripts which should invoke it on their execution (using shebang). And let's say we want to keep it portable, so it remains functioning even if simply copied to a different location (different machines) without invoking setup/install or modifying environment (PATH). A system interpreter should not be mixed in for these scripts. The given constraints exclude both known approaches like shebang with absolute path: #!/usr/bin/python and search in the environment #!/usr/bin/env python Separate launchers look

/usr/bin/env questions regarding shebang line pecularities

隐身守侯 提交于 2019-12-04 06:57:10
Questions : What does the kernel do if you stick a shell-script into the shebang line? How does the Kernel know which interpreter to launch? Explanation : I recently wanted to write a wrapper around /usr/bin/env because my CGI Environment does not allow me to set the PATH variable, except globally (which of course sucks!). So I thought, "OK. Let's set PREPENDPATH and set PATH in a wrapper around env.". The resulting script (here called env.1 ) looked like this: #!/bin/bash /usr/bin/env PATH=$PREPENDPATH:$PATH $* which looks like it should work. I checked how they both react, after setting

“python myscript” ignores “#!/usr/bin/env pythonX” where pythonX doesn't exist

余生颓废 提交于 2019-12-04 05:55:17
问题 Why doesn't test.py throw error env: python3: No such file or directory when Python 3 is not installed? My system (Mac OS X) has Python 2.7 installed, but not Python 3: $ /usr/bin/env python -V Python 2.7.12 $ /usr/bin/env python3 -V env: python3: No such file or directory File test.py: #!/usr/bin/env python3 import sys print sys.executable Executing test.py: $ python test.py /usr/local/opt/python/bin/python2.7 I thought that since Python 3 does not exist on my system, having the shebang line

shebang line not working

橙三吉。 提交于 2019-12-04 01:24:20
问题 Don't know what's wrong with my shebang line: vic@ubuntu:~/Desktop$ ./test.py : No such file or directory vic@ubuntu:~/Desktop$ ls -l ... -rwxr-xr-x 1 vic vic 35 2011-11-06 15:46 test.py ... vic@ubuntu:~/Desktop$ cat test.py #!/usr/bin/env python print('!') vic@ubuntu:~/Desktop$ /usr/bin/env python Python 2.7.2+ (default, Oct 4 2011, 20:06:09) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> Any ideas? vic@ubuntu:~/Desktop$ head -n 2 test.py

Require ruby file without .rb extension?

心不动则不痛 提交于 2019-12-03 23:41:38
问题 I have a ruby file that does not have a .rb extension, and is instead identified as ruby code with a shebang at the beginning of the file: #!/usr/bin/env ruby . I want to require the code in this file in another ruby file, but it seems to be having a problem because require automatically appends the .rb extension to the files it looks for. Is there any way to suppress this behavior and make require only look for the file as the name is given? 回答1: Use load instead: load 'file-name' 回答2: We

#!/usr/bin/python and #!/usr/bin/env python, which support?

冷暖自知 提交于 2019-12-03 17:31:06
问题 How should the shebang for a Python script look like? Some people support #!/usr/bin/env python because it can find the Python interpreter intelligently. Others support #!/usr/bin/python , because now in most GNU/Linux distributions python is the default program. What are the benefits of the two variants? 回答1: The Debian Python Policy states: The preferred specification for the Python interpreter is /usr/bin/python or /usr/bin/pythonX.Y . This ensures that a Debian installation of python is

Is there a standard way to make sure a python script will be interpreted by python3 and not python2?

丶灬走出姿态 提交于 2019-12-03 16:38:11
Related: Is there a standard way to make sure a python script will be interpreted by python2 and not python3? Apparently not all distros ship with a python3 symlink, either. #!/usr/bin/env python3 causes a no-such-file-or-directory error. What shebang line should I use if my script requires any version of Python 3? import sys try: assert sys.version_info[0] == 3 except: print "ERROR NOT PYTHON 3!" sys.exit() 来源: https://stackoverflow.com/questions/19625768/is-there-a-standard-way-to-make-sure-a-python-script-will-be-interpreted-by-pyth

How do I set the taint mode in a perl script with a '#!/usr/bin/env perl'- shebang?

我与影子孤独终老i 提交于 2019-12-03 12:18:04
问题 how do I set the taint mode in a perl script with a #!/usr/bin/env perl shebang? 回答1: You can pass the PERL5OPT environment variable on the shebang line: #!/usr/bin/env PERL5OPT=-T perl This seems all rather backwards to me. Another option, is to re-execute the script under taint mode if you detect it's not on: #!/usr/bin/env perl warn 'Taint mode is '.(${^TAINT} ? 'on' : 'off'); # For debugging exec($^X,'-T',$0,@ARGV) unless ${^TAINT}; # do stuff under taint mode here Obviously, this is a