0

I have a bash script and will have the first line start with # and followed by the command to execute the script, and it seems the limitation is 80 characters due to the exec call has such limitation, is there anyway to change that ? because sometimes my path will be very long.

Update. My case is that I use virtualenv to generate a clean python environment. And in this environment, there's one executable file called pip, the shebang line is python executable path and sometimes this path will be very long, e.g.

#!/Users/myname/github/myproject/virtualenv_python3.4/bin/python3.4
zjffdu
  • 25,496
  • 45
  • 109
  • 159
  • 1
    Put the command in your path and use `#!usr/bin/env yourcommand` – 123 Feb 01 '16 at 10:04
  • The shebang is documented in `man execve`. I see this in my (fedora) man page: "A maximum line length of 127 characters is allowed for the first line in an interpreter scripts." – glenn jackman Feb 01 '16 at 14:53
  • 1
    The shebang line is normally `#!/bin/bash`, not the path to the script. Could you be a bit more precise about what you are trying to do? Where is the file with the shebang line, for example? – rici Feb 01 '16 at 15:58
  • Update this post with my use case – zjffdu Feb 02 '16 at 01:20
  • @zjffdu: There is no bash script visible in your question. I think your first sentence is misleading. – rici Feb 02 '16 at 01:24
  • maybe this link helps http://stackoverflow.com/questions/10813538/shebang-line-limit-in-bash-and-linux-kernel – ymonad Feb 02 '16 at 01:34
  • Found one workaround here, https://github.com/pypa/pip/issues/1773 – zjffdu Feb 02 '16 at 01:39

1 Answers1

1

If you don't want to modify your path to include the directory in which the executable, you can create a simple wrapper:

#!/bin/bash
/Users/myname/github/myproject/virtualenv_python3.4/bin/python3.4 <(cat <<"EOF"
# Python script goes here
EOF) "$@"
rici
  • 234,347
  • 28
  • 237
  • 341
  • @zjffdu: Curiously, that issue also describes `pip` as a shell script. It's not a shell script. It's a python script, and the python executable is started by the `execve` system call; see `man execve` for details. – rici Feb 02 '16 at 02:05