Open nrvale0 opened 6 years ago
Thanks for reporting this. I don't have time to look into this right now, but I would certainly review and merge a PR for this.
This is not because of the nested quoting but because of the multiline escaped commands passed to Python shlex.
Ah, good catch @nrvale0 . I've renamed the issue.
The root issue is that the cli.py/run is reading the session one line at a time and then feeds each line to shlex.split(). In the situation where the command is multiline shlex is rightfully complaining that there's nothing following the line escape character. Some adjustments are necessary to the parsing logic in run()...seems like it should not be particularly difficult to add support for multiline.
Handle lines broken by '\' as one single line (on play and record) would fix the issue. But that would lead to the behaviour that the written file will contain all parts of the '\'-broken lines in a single line and if you replay a script with such broken lines they will be concated to one single line.
If that behaviour acceptable, I create a PR for that.
@sparrow242 Can you clarify your suggestion? Do you mean that if you have
vault write -format=yaml pki_root/root/generate/internal \
common_name='somefakeorg.example Root CA' \
ttl=8760h
in your session file, that it would play back as
vault write -format=yaml pki_root/root/generate/internal common_name='somefakeorg.example Root CA' ttl=8760h ```
?
@sloria Exactly. If this behavior is okay, I would have a corresponding PR.
Appreciate the follow-up.
I don't have the original document anymore but I can mock something that works similarly and try that out... It'll be a minute. Stand by...
Nice package. Having a problem using it when there are single or double-quotes in either command or the comments (using commentecho: true). For instance, the following line:
cause the following backtrace:
At least in the case of comments you can avoid the backtrace by escaping the single or double quotes but then the escaping also shows up in the commentecho output.
Ideas?