ReproNim / reproman

ReproMan (AKA NICEMAN, AKA ReproNim TRD3)
https://reproman.readthedocs.io
Other
24 stars 14 forks source link

any sane way to overcome shlex_quote's dislike of $ ? #545

Open yarikoptic opened 4 years ago

yarikoptic commented 4 years ago

I am trying to use BIDSonym, but unfortunately due to https://github.com/PeerHerholz/BIDSonym/issues/28 I am doomed to provide "$PWD". With datalad run, since I guess we do magical decision making on either to run in a shell, I could encode entire command as '$PWD ...', so then $PWD gets expanded by the shell and everything works. In reproman's run we use shlex_quote to guard each command's argument so we have them neatly pasted into command-array etc. But shlex does not include $ among safe characters in its

_find_unsafe = re.compile(r'[^\w@%+=:,./-]', re.ASCII).search

so it quotes the argument whenever it discovers $ and we then plug that quoted argument into the command-array and nothing ever can expand it into the actual path.

@kyleam -- do you see any sensible way to make it possible to submit commands which would still be able to carry env vars to be expanded? (well -- not good for reproducibility somewhat, so not even 100% certain it should be the default behavior)

kyleam commented 4 years ago

Can't you spell that sh -c '... $PWD ...'?

(That's not meant as an argument against any tweaks/enhancements to this handling.)

yarikoptic commented 4 years ago

I don't think so - those are arguments to the entry point of a container which isn't a shell .