Questions tagged [shebang]
The shebang tag has no usage guidance.
10
questions
12
votes
2
answers
4k
views
Can I have a conditional shebang?
I have a script that can be run with different interpreters:
#!/usr/bin/env default-interpreter
[my script]
But I would like to use an alternative-interpreter if it's available, like this:
#!/usr/...
6
votes
1
answer
15k
views
What does 'x' mean in this line #!/bin/sh -x?
Could you explain what 'x' means in the shebang #!/bin/sh -x ?
Does it necessary to put '-x' in this line?
3
votes
2
answers
2k
views
#! (shebang) line length limitation
In connection with developing GNU Parallel I seem to have hit a limit in the length of #! (shebang). This shebang-line:
#!/bin/echo ...
3
votes
1
answer
113
views
Are shebang invocations detectable?
Is there a way for a bash script to detect if it's being run via the #!/usr/bin/env shebang?
Some magic bash foo that would let me write:
#!/bin/bash
...
if [ __INVOKED_VIA_USR_BIN_ENV__ ]; then
.....
2
votes
2
answers
1k
views
Shebangs do not like sudo in OSX
Using sudo in the shebang seems completely broken. The following code:
#!/usr/bin/sudo /bin/bash
echo "this should work"
works fine on Ubuntu, but on OSX gives me:
sudo: effective uid is not 0, is /...
2
votes
2
answers
70
views
Avoiding accidental execution of python scripts as bash scripts
I like to run my python scripts directly in bash like so
$ ./script.py
But sometimes I forget the shebang line #!/usr/bin/env python3, and it has the potential to overwrite a file named np if the ...
1
vote
1
answer
723
views
Why node shebang works for Angular CLI but doesn't for my file?
Internet is telling me Windows doesn't support shebang lines but apparently Angular Cuses it and it works. Example of file that uses it and works on Windows:
https://github.com/angular/angular-cli/...
1
vote
1
answer
393
views
How to restore ".sh" association in bash?
For some unknown reason I have a Debian 7 VM where .sh files that don't have a shebang line (#!/bin/sh) are no longer associated/executed by bash, ie. under bash, with "test.sh" an executable shell ...
0
votes
1
answer
243
views
Linux: Shebang interpreter complains about encoding when run as root
Weird phenomenon: A Python script runs as an unprivileged user but refuses to as root:
doprea@mlll2584:~$ python /opt/updatednsfix.py
Please retry with super-user privileges
$ sudo su
# /opt/...
0
votes
2
answers
630
views
Info on '#!' (shebang, hashbang, crunchbang, etc.)
I have a question about the phrase '#!' that appears at the top of every python file, most bash files, and several others.
I've already performed a search for this term on both Google and this ...