Skip to main content

Questions tagged [shebang]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
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/...
marcio's user avatar
  • 223
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?
t7e's user avatar
  • 711
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 ...
Ole Tange's user avatar
  • 4,881
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 .....
aefxx's user avatar
  • 133
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 /...
user208769's user avatar
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 ...
user1537366's user avatar
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/...
Dread Boy's user avatar
  • 117
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 ...
Eric's user avatar
  • 181
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/...
Dustin Oprea's user avatar
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 ...
Mr. Minty Fresh's user avatar