When executing a script from the path (scriptname, rather than "sh scriptname") I receive the following error:
-bash: ./gitup: /bin/bash/: bad interpreter: Not a directory
All of the other scripts in the same directory execute without issue, and I do not encounter this issue when the script is executed manually (sh scriptname), only when executed by itself. So the script, itself, seems to not be the issue as it does execute normally, and did so until I opened a new shell session and encountered this error for this script alone.
The script is executable, includes all requisite lines to execute in the way I've described (it worked properly until earlier today) and is able to be executed by my user, so I am unsure of what the issue could be.
The shebang line reads #!/bin/bash. I used the command "export PATH=$PATH:repos/utilities
" to direct to the directory storing these scripts, all of which, besides this one, execute simply by calling the script name (i.e. gitup).
Best Answer
There are a few things I can think of.
You said your script is in your $PATH, yet you call it with its full path (
./gitup
as opposed to justgitup
). Could it be that you have edited one version of the script (the one in your $PATH, say~/bin/gitup
) and have then executed another (./gitup
)?Could there be multiple versions in your $PATH? You can check with
You may have inadvertently entered a strange invisible character while editing the script. Check the shebang line using
od
:Make sure there is nothing after
#!/bin/bash
but the newline character (\n
). It should look like this: