Philipp Haselwarter <philipp.haselwar...@gmx.de> writes: > Hi, > > Is there a way to call a source-block with (positional) arguments, like > one would do on the command line? > > I want to include some shell scripts in a paper and would prefer not > having to introduce some kind of artificial variables. > > So I could just write my scripts inline, like > > #+srcname: script.sh > #+begin_src sh > #!/bin/sh > echo $0: $@ > #+end_src > > and demonstrate their output by calling them > > #+call: script.sh("arg1", "arg2") :results output > > would produce something like > > #+results: > : script.sh: arg1 arg2 >
This wouldn't work under the current setup, for example, we don't even write the contents of the sh code block to a temporary file, so $0 wouldn't really mean anything... or actually, this would just return the file-name of the shell used to evaluate the code block, e.g., #+begin_src sh echo $0 #+end_src #+results: : sh > > > Can this be done? > Not currently, however if there is enough interest, it wouldn't be too hard to add a :cmdline header argument to shell scripts, which would result in the code block body being written to a temporary file, then called with the supplied :cmdline arguments. > > PS: > Is there a way to set «:results output» for the whole file? > Yes, see http://orgmode.org/manual/Buffer_002dwide-header-arguments.html Cheers -- Eric > > thanks,