Closed gregwebs closed 6 years ago
@gregwebs
what do you think about how this PR has 2 different escaping options?
You mean adding a new option, something like escapingOnRemote :: Bool
?
I think:
ssh user@host "echo $HOME"
# user wants to use the local $HOME
ssh user@host 'echo $HOME'
# user wants to use the remote $HOME
ssh -i $HOME/secret/id_rsa user@host 'echo $HOME && echo '"$HOME"
# user wants to use both the local and remote $HOME
But it's a good compramise, if, it can be implemented correctly:
Implementing escapingOnRemote = True
is easy: quote everything with signle quotes and you are covered.
However, implementing escapingOnRemote = False
is tricky, because every shell has different escaping rules, and it cannot even be done trivially just for the POSIX one, (see 2.2 Quoting).
The best I can think of is that, we expose some primitive functions, (like Shelly.quoteOne
), and let the user compose the remote command string themselves, and we promise that the string will not be interpreted by the local shell, it's far far away from perfect though.
This PR tried to do remote escaping behavior based on the existing escaping setting. But I can see how that could easily cause more problems.
Doing no escaping and giving the user some quoting functions is definitely a good approach for extensibility.
@qwfy what do you think about how this PR has 2 different escaping options?