schell / steeloverseer

A file watcher and development tool.
BSD 3-Clause "New" or "Revised" License
128 stars 15 forks source link

Commands with quotes fail to parse #30

Open michalrus opened 6 years ago

michalrus commented 6 years ago

On 85d40083ac893bebc3696ab48f223da8af928874, e.g.:

$ echo "cabal test --test-options='1234'\\'' 567'"
cabal test --test-options='1234'\'' 567'

$ sos . -c "cabal test --test-options='1234'\\'' 567'"
sos: Error parsing command 'cabal test --test-options='1234'\'' 567''

(1)$ 
schell commented 6 years ago

@michalrus what's the use case here?

michalrus commented 6 years ago

@schell, say, if I wanted to match a Tasty test case with a space in name, I’d need that. The pure Cabal command would then be:

cabal test --test-options='-p '\''some test name w/ spaces'\'' --color=always'

Currently there’s no way to pass that command to sos -c [ … here … ].

schell commented 6 years ago

Yes, I see. The difficulty here is that within a command we use \ as the leader to a capture group. It's possible we simply need some logic around that to check for quotes, as that is obviously not a valid capture group.

I'll get this when I can but until then I welcome any pull request, @michalrus! Here's where the logic should probably go: https://github.com/schell/steeloverseer/blob/master/src/Sos/Template.hs#L41