Re:Fix the unit test and open a giant hole everywhere
by im3w1l on Saturday December 25, 2021 @04:41AM
(#29681838)
This does not work for all values of path. And I'm not just referring to blorgle's complaint. I'm being deliberately vague to make you pause for a second and think.
[ Parent
| on HN ]
Re:Fix the unit test and open a giant hole everywhere
by ynik on Saturday December 25, 2021 @06:48AM
(#29682494)
You seem to be getting downvoted for being too vague, so I will post the solution:
The snippet breaks for paths starting with a minus, as mkdir will interpret those as another option.
The solution is:
subprocess.run(["mkdir", "-p", "--", path])
Re:Fix the unit test and open a giant hole everywhere
by Kinrany on Saturday December 25, 2021 @05:40AM
(#29682096)
Does `path = "$(rm -rf /)"` work in this context?
Re:Fix the unit test and open a giant hole everywhere
by bstpierre on Saturday December 25, 2021 @07:24AM
(#29682717)
No, because this isn’t being run through the shell, it’s directly exec’ing the program. So you’re just going to get a dir named “$(rm -rf /)”.