/bin/bash: bad interpreter: No such file or directory

  • Thread starter Thread starter Deleted member 63539
  • Start date Start date
D

Deleted member 63539

Guest
Porting a software from Linux (for personal use, not planned to put it in ports). Should I just create a symlink or fix their shell scripts? There are too many of them to edit by hand. Someone with scripting skills please help me writing a script to convert all of these #!/bin/bash to #!/usr/bin/env bash. I think it will involve sed or awk, and I don't want to deal with both of them. Thank you very much.
 
Is , "ln -s /usr/local/bin/bash /bin/bash", insufficient ?
I asked very clearly in my first post here about should I just use the symlink workaround or fixing it. Since currently I'm only keep it for myself, but who know if someday I contributed it to ports or even attempt to get the upstream project to merge my fixes?
 
Could you give me a shell script?
Bash:
#!/bin/sh

# Sample usage:
#     /path/to/script.sh ./.bash_scripts ./src/bash_helpers
# Will work recursively, thanks to find(1).
# Will ignore paths containing a path component with
# a leading dot (e.g. .git, .svn, .bashrc).

set +f &&
        find "$@" -type f -path '*/[!.]*' -print0 |
            xargs -0 \
              sed -i'' \
                '1s%^#!.*/bin/bash[[:blank:]]*$%#!/usr/bin/env bash%'
Not POSIX portable in the least (what with all the -print0 and -0 and -i''), but it works on FreeBSD and should also work on any Linux distro as far as I'm aware (and NetBSD and OpenBSD as far as I can tell from their man pages).
 
Back
Top