4

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.

17
  • Which shell are you running? What does type sh say?
    – nohillside
    Commented Apr 14 at 5:24
  • 1
    If you turn on logging in the Console, and then run it, do you see the same problem? Also, what are the file attributes of foo?
    – benwiggy
    Commented Apr 14 at 7:12
  • 1
    This has started happening for me as well, today.
    – ntessore
    Commented Apr 14 at 20:48
  • 1
    Only change the shebang line to #!/usr/bin/env -S -v -i bash and run ~/bin/foo again, do you see any lines prefixed with #env?
    – Aeronautix
    Commented Apr 15 at 13:08
  • 1
    Can you switch to another user account (or create one) and try there? If it happens as well, a reasonable next step would be to reinstall macOS from Recovery Mode.
    – nohillside
    Commented Apr 17 at 4:56

0

You must log in to answer this question.

Browse other questions tagged .