I think I understand the current behaviour. So why was it different before? One thing that has changed is the switch from bash to zsh as the default shell - but that shouldn’t matter if you were explicitly invoking /bin/bash. I don’t believe that the bash or ssh behaviour has changed. Mysterious.
Re this example:
/usr/bin/ssh max /bin/bash -c "ls /Volumes"
That runs this command on the remote machine (note no quotes):
/bin/bash -c ls /Volumes
According to man bash, the effect of bash -c is that “commands are read from
the first non-option argument command_string. If there
are arguments after the command_string, the first argument
is assigned to $0 and any remaining arguments are assigned
to the positional parameters. The assignment to $0 sets
the name of the shell, which is used in warning and error
messages.”
So your command just runs ls, while (uselessly) setting $0 to /Volumes. You want to run
/bin/bash -c ‘ls /Volumes’
which is what your final version does.
Topic:
App & System Services
SubTopic:
Core OS
Tags: