Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shebang line limit in bash and linux kernel

I'm trying to execute python scripts automatically generated by zc.buildout so I don't have control over them. My problem is that the shebang line (#!) is too long for either bash (80 character limit) or direct execution (some Linux kernel constant I don't know).

This is an example script to help you reproduce my problem:

#!/././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././bin/bash echo Hola! 

How can be bash or the kernel configured to allow for bigger shebang lines?

like image 329
sortega Avatar asked May 30 '12 09:05

sortega


People also ask

What is the correct shebang line for a bash script?

What is bash shebang? The #! syntax is used in scripts to indicate an interpreter for execution under UNIX / Linux operating systems. The directive must be the first line in the Linux shell script and must start with shebang #! .

Can shebang be on second line?

The shebang must be the first line because it is interpreted by the kernel, which looks at the two bytes at the start of an executable file.

Does a bash script need a shebang?

It's not required and has no effect if you for example write bash ./script.sh or source the script. Shebang is only for executables, not sourced scripts.

What is shebang value in Linux?

The shebang is the combination of the # (pound key) and ! (exclamation mark). This character combination has a special meaning when it is used in the very first line of the script. It is used to specify the interpreter with which the given script will be run by default. So, if the first line of a script is: #!/bin/bash.


1 Answers

Limited to 127 chars on 99.9% of systems due to kernel compile time buffer limit.

It's limited in the kernel by BINPRM_BUF_SIZE, set in include/linux/binfmts.h.

like image 166
Ignacio Vazquez-Abrams Avatar answered Sep 19 '22 21:09

Ignacio Vazquez-Abrams