pydra icon indicating copy to clipboard operation
pydra copied to clipboard

Use shlex.quote/shlex.join to construct cmdlines

Open effigies opened this issue 2 months ago • 0 comments

After spending an annoying amount of time figuring out @yarikoptic's problem in nipype with dcm2niix failing if a directory had a space in it, I have discovered that it cannot be properly fixed without substantially breaking nipype, as some argstrs rely on not getting quoted.

I would suggest that pydra commit to constructing command lines as lists of arguments that are joined with shlex.join, and use shlex.split when pieces (singularity run) need splitting. shlex.quote is also useful at times, but probably not as much having a clear notion of when you are working with a list of arguments and when you are working with a command line that could be passed to a shell.

It will take a bit of working out and bug fixing, but perhaps we can avoid turning those bugs into load-bearing bugs.

effigies avatar Nov 07 '25 02:11 effigies