2

Given a command:

ssh user@host command

where command, when executed on the remote host host, should be:

somecmd --option1 'option value with spaces' 'arg1 with spaces' 'arg2 with weird chars, like ('

How can I execute this command using the Haskell Shelly or the Haskell Turtle?

Shelly provides a sshPairs, but it didn't quote command correctly.

Quoting in a bash script can be fragile, does these two libraries, (or any Haskell libraries, for that matter), tries to improve this?

Incömplete
  • 853
  • 8
  • 20
  • Note that this has been fixed in the latest version of Shelly:https://github.com/yesodweb/Shelly.hs/issues/146 – Sibi Dec 07 '17 at 09:02
  • @Sibi not really, see [here](https://github.com/yesodweb/Shelly.hs/pull/147#issuecomment-349934385) – Incömplete Dec 07 '17 at 11:02
  • Ah okay. I will look into it. Note that other option for use is shell-conduit: https://github.com/psibi/shell-conduit ( Disclosure: I'm it's current maintainer) – Sibi Dec 07 '17 at 12:13
  • If `sshPairs` doesn't do quoting correctly, you could try to implement the correct quoting yourself and then run the command with a more primitive functionality, like [`shell`](https://hackage.haskell.org/package/turtle-1.4.5/docs/Turtle-Prelude.html#v:shell). Also note that the documentation on `sshPairs` explicitly states: "the commands will not be shell escaped". Neither library attempts to solve the problem of fragility of shell quoting (indeed, trying to solve this problem in a shell interop lib doesn't make sense, since there are so many different shells out there) – user2407038 Dec 07 '17 at 17:14
  • @user2407038 guess have to do it manually then – Incömplete Dec 08 '17 at 06:35

0 Answers0