shebang

shebang: use interpreter relative to the script path

人盡茶涼 提交于 2019-11-29 01:13:02
I try to build scripts that work everywhere and always. For this I use a custom-built python, which is always in the parent directory relative to the script. This way I could load my package on an USB-stick and it would work everywhere, regardless of where the stick is mounted and whether python is installed or not. However, when I use #!../python then it works only when the script gets invoked from its directory, which is of course not acceptable. Is there a way to do this or is this impossible in the current shebang-mechanism? There is a healthy set of multi-line shebang scripts on this page

How does argparse (and the deprecated optparse) respond to 'tab' keypress after python program name, in bash?

霸气de小男生 提交于 2019-11-28 20:48:41
I have tested optcomplete working with the optparse module. Its example is a simple file so I could get that working. I also tested it using the argparse module as the prior one is deprecated. But I really do not understand how and by whom the python program gets called on tab presses. I suspect bash together with the shebang line and the argparse (or optparse ) module are involved in some way. I have been trying to figure this out (now gonna read the source code). I have a little more complex program structure, which includes a wrapper around the piece of code which handles the arguments. Its

what is the use of “#!/usr/local/bin/ruby -w” at the start of a ruby program

人走茶凉 提交于 2019-11-28 19:50:30
问题 what is the use of writing the following command at the start of a ruby program ? #!/usr/local/bin/ruby -w Is it OS specific command? Is it valid for ruby on windows ? if not, then what is an equivalent command in windows ? 回答1: The Shebang line is optional, and if you run the ruby interpreter and pass the script to it as a command line argument, then the flags you set on the command line are the flags ruby runs with. A Shebang line is not ruby at all (unless you want to call it a ruby

node and shebang : help executing via command line

假装没事ソ 提交于 2019-11-28 18:05:30
My node installation is at: /usr/local/bin/node and I've added the shebang: #!/usr/local/bin/node to the top of the file and given my node app file the permissions 755, but when I try to run: > ./my-app I get the old: -bash: ./my-app: No such file or directory What am I doing wrong? secretformula The node shebang is: #!/usr/bin/env node Not all systems place node in the same location, its possible that you have the location incorrectly. This will find them all. Source Also 来源: https://stackoverflow.com/questions/24253027/node-and-shebang-help-executing-via-command-line

Proper shebang for Python script

江枫思渺然 提交于 2019-11-28 16:10:56
I'm usually using the following shebang declaration in my Python scripts: #!/usr/bin/python Recently, I've came across this shebang declaration: #!/usr/bin/env python In the script documentation, it was noted that using this form is "more portable". What does this declaration mean? How come there's a space in the middle of the path? Does it actually contribute to protability? #!/usr/bin/env python is more portable because in general the program /usr/bin/env can be used to "activate" the desired command without full path. Otherwise, you would have to specify the full path of the Python

Appropriate hashbang for Node.js scripts

China☆狼群 提交于 2019-11-28 09:34:44
I'm trying to create a script for node.js that will work in multiple environments. Particularly for me, I'm switching back and forth between OS X and Ubuntu. In the former, Node is installed as node , but in the latter it is nodejs . At the top of my script, I can have: #!/usr/bin/env node or #!/usr/bin/env nodejs I'd rather have the script run as an executable for either environment as long as node is installed rather than have one or the other have to specify the command ( ./script-name.js vs. node script-name.js ). Is there any way to specify a backup hashbang or one that is compatible in

Makefile as an executable script with shebang?

[亡魂溺海] 提交于 2019-11-28 09:03:23
Is it possible to create an executable script that would be interpreted by make? I tried this: #!/usr/bin/env make --makefile=/dev/stdin main: @echo Hello! but it does not work - hangs until press Ctrl-c . Flexo #!/usr/bin/make -f main: @echo Hello World! Is normally all you need in a standard make file. The filename is implicitly passed as the last argument. /dev/stdin here is (usually) the tty. You can do the whole env thing if there's a reason to, but often there's no need. ajw@rapunzel:~/code/videocc/tools > vi Makefile ajw@rapunzel:~/code/videocc/tools > chmod a+x Makefile ajw@rapunzel:~

Why should the shebang line always be the first line?

这一生的挚爱 提交于 2019-11-28 07:32:28
I have a simple perl script as below: #!/usr/bin/perl use strict; use warnings; print "hello world!\n"; I can execute this script as below: >temp.pl hello world! > If I add some comments like this: #this script is just for test #the shebang #!/usr/bin/perl use strict; use warnings; print "hello world!\n"; and when I try to execute, it gives me output as below: > temp.pl use: Command not found. use: Command not found. print: Command not found. > The point here is the shebang line should be always at the top, no matter what. Can anybody explain why? The shebang must be the first line because it

Use shebang/hashbang in Windows Command Prompt

北战南征 提交于 2019-11-28 06:16:44
I'm currently using the serve script to serve up directories with Node.js on Windows 7. It works well in the MSYS shell or using sh , as I've put node.exe and the serve script in my ~/bin (which is on my PATH), and typing just "serve" works because of it's Shebang ( #! ) directive which tells the shell to run it with node. However, Windows Command Prompt doesn't seem to support normal files without a *.bat or *.exe extension, nor the shebang directive. Are there any registry keys or other hacks that I can get to force this behavior out of the built-in cmd.exe ? I know I could just write up a

Should I use a Shebang with Bash scripts?

冷暖自知 提交于 2019-11-27 23:26:14
I am using Bash $ echo $SHELL /bin/bash and starting about a year ago I stopped using Shebangs with my Bash scripts. Can I benefit from using #!/bin/sh or #!/bin/bash ? Update: In certain situations a file is only treated as a script with the Shebang, example $ cat foo.sh ls $ cat bar.sh #!/bin/sh ls $ file foo.sh bar.sh foo.sh: ASCII text bar.sh: POSIX shell script, ASCII text executable Roland Smith On UNIX-like systems, you should always start scripts with a shebang line. The system call execve (which is responsible for starting programs) relies on an executable having either an executable