Vladimir Nikishkin <lockyw...@gmail.com> writes:
> So, my point is the following. A shebang is an almost universally > accepted way to specify which interpreter should be used for code > evaluation. > > In the ob-core.el, at line 787, the function called > org-babel-expand-src-block makes a buffer out of the noweb-expanded > code. > (I am working with org 20200907) > > The sexp is looking like this: > > (org-edit-src-code > expanded (concat "*Org-Babel Preview " (buffer-name) "[ " lang " ]*")) > > I suggest replacing this sexp with > > (org-edit-src-code > (seq-concatenate 'string (or (alist-get :shebang params) "") "\n" > expanded) (concat "*Org-Babel Preview " (buffer-name) "[ " lang " > ]*")) > > This way the expanded buffer would respect the shebang, and the > resulting buffer would be saveable as a runnable file. > > I suspect that the second branch of the (if) should be left as it is, > because non-interactive usage probably means that the code will be > used later as a part of something, and therefore does not need a > shebang. > > Vlad > I'm not sure about this one. - I often have multiple src blocks which make up one final script once tangled. When editing these blocks, I don't want a shebang line for each of them. - Would this work with different shells? I write scripts in multiple shell dialects e.g. bash, sh, zsh, ksh etc. Will this add the correct shebang? - Which form of shebang e.g #!/bin/<shell> or #!/usr/bin/env <shell>? The only thing worse than having to add the shebang manually is having to remember to remove/change it when not needed :) Perhaps this could be a user configurable option that you can turn on if you want it rather than a default action? -- Tim Cross