incedo / fabricate

Automatically exported from code.google.com/p/fabricate
0 stars 0 forks source link

Consider changing run()/shell() to take *args like Popen instead of one command line string #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is not quite as nice, but is much better as soon as you start having
escaping issues, or spaces in your file names, like Ben did just now. For
example, try calling `shell()` on a command whose path has spaces in it,
and with a filename argument with spaces in it -- I couldn't get it to work:

{{{
run(r'"c:\program files\catdoc\catdoc.exe" -w "word document.doc"")
}}}

It doesn't work, no matter what backslash and quote combos I tried. I'm
probably not trying hard enough.

All of which to say, I think we need to "do it properly", like Popen, or
similar:

{{{
run(r'c:\program files\catdoc\catdoc.exe', '-w', 'word document.doc')
}}}

Or we could make it so if you gave a list it'd do it Popen-style, otherwise
it'd consider it a single command line string as it does now. But is that
bad -- more than one way to do things? And then the "right" way takes an
extra set of brackets, like:

{{{
run([r'c:\program files\catdoc\catdoc.exe', '-w', 'word document.doc'])
}}}

Original issue reported on code.google.com by benh...@gmail.com on 6 Aug 2009 at 4:26

GoogleCodeExporter commented 9 years ago
Fixed in r39. Safer, as well as simpler and more Pythonic in many cases, 
because you
eliminate ' '.join()s. You now do run('gcc', '-o', target, objects) instead of
run('gcc -o %s %s' % (target, ' '.join(objects)))

Original comment by benh...@gmail.com on 11 Aug 2009 at 11:41