This didn't used to happen, but now when I try to execute a shell script in my path by name, it just hangs.
The script: ~/bin/foo
:
#!/bin/sh
echo this is foo
My PATH:
/usr/bin:/bin
What happens when I try to run it:
$ sh ~/bin/foo
this is foo
$ ~/bin/foo
(hangs forever)
The script's file mode is 0755.
OS is Ventura 13.6.4
Changing the shebang to bash did not help. Changing to zsh did not help.
Python scripts are seeing the same problem.
More information, by request:
I used vim to edit the script. cat bin/foo > bin/bar; chmod +x bin/bar
did not fix it. I want to stress that scripts that used to work are now broken.
Problem happens with sh, bash, zsh, and even python3, so I don't think it's a corrupt shell.
I changed the shebang line to #!/usr/bin/env -S -v -i bash
and it still hung without generating any output.
/bin/sh $HOME/bin/foo
works perfectly.
Piping through xxd was a good idea, but nothing unexpected. Again, problem is happening with all scripts with a shebang line, including old ones that worked before. I just tried it with a script that has a modification date of 2019.
I've double-checked PATH. echo $PATH
returns
/usr/bin:/bin
Both sh $HOME/bin/foo
and /bin/sh $HOME/bin/foo
succeed.
type sh
say?foo
?#!/usr/bin/env -S -v -i bash
and run~/bin/foo
again, do you see any lines prefixed with#env
?