I use a
Match exec ... in my .ssh/config for some rules. (Specifically, I change my ProxyJump based on my IP address). In the man page it explains
The exec keyword executes the specified command under the user's shell. If the command returns a zero exit status then the condition is considered true. Commands containing whitespace characters must be quoted.
I use two shells with fairly different syntax (zsh and xonsh) which makes it difficult to write one exec statement that works equally well on both. Is there a way to force ssh to pass the exec command to a specific shell rather than using the user's shell?
Note that this is executed with the local shell and is not related to which shell runs on the remote server.
Here's some more details. I have the following in my ssh config:
match !exec "ifconfig | egrep -q 'inet (123\.45\.|67\.89\.)'" ProxyJump hop
This is bash syntax. The single quotes force raw string interpretation, so the slashes are passed to egrep.
In xonsh, this syntax is illegal due to python string quoting rules. I would have to use
r'123\.' to disable quoting. Note that I can't work around this by calling a different shell inside the exec command because the string quoting still is performed by the outside shell, which may change depending on the current value of $SHELL.