Reputation: 94267
I want to pass strings like key="value"
to a littler script. In bash, I have argtest.sh
:
#!/bin/sh
echo $1
which I can call, preserving the quotes from the shell by backslashes, and I see them in the output:
$ ./argtest.sh x=\"1\"
x="1"
However I can't get args like that through littler/docopt. Here's my test script:
#!/usr/bin/env r
doc <- "Usage: thing -t thing
-t --thing thing some args
"
opt <- docopt::docopt(doc)
print(opt$thing)
target = 'x="1"'
if(opt$thing==target){
message("Winner")
}else{
message("Loser")
}
Simple backquoting as in the shell example doesn't work:
$ ./argtest.r -t x=\"1\"
[1] "x=1"
Loser
And everything else I've tried also fails. Like:
$ ./argtest.r -t 'x=\"1\"'
[1] "x=\\1\\"
Loser
Can anyone be a winner here?
Upvotes: -1
Views: 111
Reputation: 368439
I think this wants to be an issue ticket over at the docopt repo.
As I recall, Jenny once had a corner case too. Methinks that docopt deparses the arguments so thoroughly that you cannot (easily) protect the spaces otherwise used as demarcation.
Upvotes: 2