Nicolas Goaziou writes: > Hello, > > stardiviner writes: > >> I hope ~:mkdirp~ header argument can also work for other related header arguments >> like ~:dir~, ~:file~ etc not just ~:tangle~. Like following example. >> >> #+begin_src sh :mkdirp yes :dir "data/code/mkdirp/dir" :file "test" :results file link >> echo "hello" >> #+end_src >> >> So I added a simple patch to make it work. > > Thank you. Some comments follow. > >> #+cindex: @samp{mkdirp}, header argument >> -The =mkdirp= header argument creates parent directories for tangled >> -files if the directory does not exist. =yes= enables directory >> -creation and =no= inhibits directory creation. >> +The =mkdirp= header argument creates parent directories for =dir= >> +header argument specified path and tangled files if the directory does >> +not exist. =yes= enables directory creation and =no= inhibits >> +directory creation. > > Please also support "t" and "nil", or, more generally, make "no" and > "nil" equivalent, and anything else would be "t". I use ~cond~ to handle this. Don't know whether have better. I can use ~if~ to exclusive on "no" and "nil". But it is not robust. > >> - (or (and dir (file-name-as-directory (expand-file-name dir))) >> + (or (and dir >> + ;; Possibly create the parent directories for file. >> + (let (fnd (file-name-as-directory (expand-file-name dir))) >> + (if (and (string= mkdirp "yes") fnd) >> + (make-directory fnd 'parents)))) > >> +;;; test-ob-core.el --- tests for ob-core.el > > Tests are in "test-ob.el" file. You should add yours there instead of > creating a new file. I though it is "test-ob-core.el", but have not found it. So I created a new one. :) > >> +(ert-deftest test-ob-core/dir-mkdirp () >> + (org-test-with-temp-text >> + "#+begin_src sh :mkdirp yes :dir \"data/code\" >> +pwd >> +#+end_src" >> + (org-babel-execute-src-block) >> + (should (file-directory-p "data/code")))) > > Nitpick: `should' is better outside `org-test-with-temp-text'? Updated. > > Could you send an updated patch? New patch in attachment.