3 ms·
subprocess.run([“mkdir”, “-p”, path]) This does not work for all values of path. And I'm not just referring to blorgle's complaint. I'm being deliberately vagu
by im3w1l 5y ago
subprocess.run([“mkdir”, “-p”, path])
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.
- Kinrany 5y agoDoes `path = "$(rm -rf /)"` work in this context?
- bstpierre 5y agoNo, 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 /)”.
- im3w1l 5y agoIt's funny how easy it is to miss characters with special meaning. In this case it's the slash. You would get a directory named "$(rm -rf " with a subdirectory named ")"
- ynik 5y agoYou 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])