Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In connection with developing GNU Parallel I seem to have hit a limit in the length of #! (shebang). This shebang-line:

#!/bin/echo 123456789a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789k123456789done bar

prints this on Debian, Mandriva, SuSE, Ubuntu, Centos, RedHat:

123456789a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789k12345 ./shebang

So it seems to be chopped off after 128 bytes. But it does what I would expect (printing the full line) on FreeBSD, DragonFlyBSD and Hurd. On OpenBSD and Tru64 it prints nothing(?!).

What causes this limitation? Can I work around it?

Background

GNU Parallel's --shebang makes it possible to write the full parallel command in the #!-line. It is therefore somewhat limiting if the full command can only be 128 chars.

The rest of the file is used as input for parallel, thus the command cannot be written there.

share|improve this question
    
That's what heredocs are for. –  Ignacio Vazquez-Abrams Aug 21 '13 at 4:41
    
@IgnacioVazquez-Abrams Is there a heredoc construct that will allow any input (including \0, \n, the heredoc string and any combination of those)? My input can be a binary file, so it is not an acceptable solution if certain strings in the input are forbidden. –  Ole Tange Aug 21 '13 at 4:55
1  
Hrm. No, but you could use a sentinel at the end of the text portion and append the binary data afterwards. This technique is often used by installers. –  Ignacio Vazquez-Abrams Aug 21 '13 at 5:00

1 Answer 1

up vote 1 down vote accepted

Limit of length depends on implementation. I recently investigated similar question and I found this wonderful report by Sven Mascheck about shebang line in different versions of Unix and Linux. You should definitely take a look. It says that, in particular, shebang line originally was limited to 16 bytes.

share|improve this answer
    
Funny, I can see in my browser that I have visited that page earlier, but I clearly did not read the length section. –  Ole Tange Dec 14 '13 at 11:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.