[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: spaces in the shebang interpreter path

From: Bob Proulx
Subject: Re: spaces in the shebang interpreter path
Date: Sun, 11 May 2008 12:37:12 -0600
User-agent: Mutt/1.5.13 (2006-08-11)

Felix Schwarz wrote:
>         I'm not able to specify an interpreter in a shebang line if the path
>         to this interpreter contains spaces.

That is correct.  It is part of the implementation of the Berkeley #!
exec(2) hack and as such is now simply the way things are and have
been for many years.

Here is a now somewhat dated explanation of this from decades ago:


Here is a pointer to the current online standards documentation:


I think the HP-UX man page does the best job of describing this:


  HP-UX Release 9.0: August 1992

      The initial line of a script file must begin with #! as the
      first two bytes, followed by zero or more spaces, followed by
      interpreter or interpreter argument.  One or more spaces or tabs
      must separate interpreter and argument.  The first line should
      end with either a new-line or null character.

           #! interpreter
           #! interpreter argument

>         I'm not quite sure if this is considered a bug or if its
>         just there for backwards compatibility but at least quoting
>         etc. does not work for me.

The "#! interpreter argument" is what is known as the Berkeley exec
hack.  As described in the first faq referenced above it was a simple
way to enable script interpreters and doesn't handle non-traditional
filenames.  This has been in existence for so many years (decades!)
that this is unlikely to change now.

>         IMHO bash should support every valid unix path for shebang lines.

This is part of the exec(2) kernel system call interface and is not
part of bash.  Bash doesn't have anything to do with the "#!" line.
The # is a comment character and bash sees that line as a comment.


Patient asks: "Doctor, doctor, it hurts when I use spaces in filenames."
Doctor responds:  "... then don't use spaces in filenames."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]