From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bjarte Johansen Subject: Make ob-shell conform to the org-babel interface Date: Wed, 27 May 2015 17:30:27 +0200 Message-ID: <3651FC40-E9B3-4027-91D7-DD03147591C4@infomedia.uib.no> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_C839F3FF-CD00-43B5-B818-7FFFD33D8897" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxdHv-0003WA-Qc for emacs-orgmode@gnu.org; Wed, 27 May 2015 11:30:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxdHr-00059c-KO for emacs-orgmode@gnu.org; Wed, 27 May 2015 11:30:35 -0400 Received: from alfons.uib.no ([2001:700:200:30::141]:38545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxdHr-00058N-75 for emacs-orgmode@gnu.org; Wed, 27 May 2015 11:30:31 -0400 Received: from alfux.uib.no (smtp.uib.no) [2001:700:200:6::a:1f0c] by alfons.uib.no for emacs-orgmode@gnu.org with esmtp (Exim 4.84) id 1YxdHo-0005tz-1M; Wed, 27 May 2015 17:30:28 +0200 Received: from pc-115-18.eduroam.uib.no [129.177.115.18]:50439 by smtp.uib.no for emacs-orgmode@gnu.org with esmtpsa (Exim 4.84) id 1YxdHn-0005RC-Lw; Wed, 27 May 2015 17:30:27 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode --Apple-Mail=_C839F3FF-CD00-43B5-B818-7FFFD33D8897 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi, I found that ob-shell=E2=80=99s org-babel-variable-assignments:bash = function does not respect the interface for org-babel. It takes multiple = arguments when it should only take 1. This is a problem when f.ex. = org-babel-sha1-hash tries to expand the body of a bash source block and = tries to call that function with only 1 argument. I am not sure if the following patch follows best practices in the = project, but it solves the problem for me.=20 --Apple-Mail=_C839F3FF-CD00-43B5-B818-7FFFD33D8897 Content-Disposition: attachment; filename=0001-ob-shell-Conform-to-variable-assignment-interface.patch Content-Type: application/octet-stream; name="0001-ob-shell-Conform-to-variable-assignment-interface.patch" Content-Transfer-Encoding: quoted-printable =46rom=2004f00e4f69c5352d51b7de1ba8783ddd96124c1f=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Bjarte=20Johansen=20= =0ADate:=20Wed,=2027=20May=202015=2017:20:41=20= +0200=0ASubject:=20[PATCH]=20ob-shell:=20Conform=20to=20variable=20= assignment=20interface=0A=0AChange=20org-babel-variable-assignments=20= functions=20in=20ob-shell=20to=20use=20the=0Asame=20function=20so=20= conform=20to=20the=20interface=20used=20for=20variable=20assignment=0Ain=20= org-babel.=0A---=0A=20lisp/ob-shell.el=20=20=20=20=20=20=20=20=20=20=20=20= =20=20|=2016=20++++++++++------=0A=20testing/lisp/test-ob-shell.el=20|=20= 11=20+++++++++++=0A=202=20files=20changed,=2021=20insertions(+),=206=20= deletions(-)=0A=0Adiff=20--git=20a/lisp/ob-shell.el=20b/lisp/ob-shell.el=0A= index=205b74821..c8db512=20100644=0A---=20a/lisp/ob-shell.el=0A+++=20= b/lisp/ob-shell.el=0A@@=20-48,10=20+48,14=20@@=0A=20=20=20=20=20= (set-default=20symbol=20(second=20value))=0A=20=20=20=20=20(mapc=0A=20=20= =20=20=20=20(lambda=20(name)=0A-=20=20=20=20=20=20=20(eval=20`(defun=20= ,(intern=20(concat=20"org-babel-execute:"=20name))=20(body=20params)=0A-=09= =09,(format=20"Execute=20a=20block=20of=20%s=20commands=20with=20Babel."=20= name)=0A-=09=09(let=20((shell-file-name=20,name))=0A-=09=09=20=20= (org-babel-execute:shell=20body=20params)))))=0A+=20=20=20=20=20=20=20= (eval=0A+=09`(progn=0A+=09=20=20=20(defun=20,(intern=20(concat=20= "org-babel-execute:"=20name))=20(body=20params)=0A+=09=20=20=20=20=20= ,(format=20"Execute=20a=20block=20of=20%s=20commands=20with=20Babel."=20= name)=0A+=09=20=20=20=20=20(let=20((shell-file-name=20,name))=0A+=09=20=20= =20=20=20=20=20(org-babel-execute:shell=20body=20params)))=0A+=09=20=20=20= (defvar=20,(intern=20(concat=20"org-babel-variable-assignments:"=20= name))=0A+=09=20=20=20=20=20'org-babel-variable-assignments:sh))))=0A=20=20= =20=20=20=20(second=20value))))=0A=20=0A=20(defun=20= org-babel-execute:shell=20(body=20params)=0A@@=20-121,7=20+125,7=20@@=20= This=20function=20is=20called=20by=20`org-babel-execute-src-block'."=0A=20= =20=20=20=20=20values=0A=20=20=20=20=20=20"\n")))=0A=20=0A-(defun=20= org-babel-variable-assignments:bash=20(varname=20values=20&optional=20= sep=20hline)=0A+(defun=20org-babel--variable-assignments-bash=20(varname=20= values=20&optional=20sep=20hline)=0A=20=20=20"Represents=20the=20= parameters=20as=20useful=20Bash=20shell=20variables."=0A=20=20=20(if=20= (listp=20values)=0A=20=20=20=20=20=20=20(if=20(and=20(listp=20(car=20= values))=20(=3D=201=20(length=20(car=20values))))=0A@@=20-138,7=20+142,7=20= @@=20This=20function=20is=20called=20by=20= `org-babel-execute-src-block'."=0A=20=20=20=20=20(mapcar=0A=20=20=20=20=20= =20(lambda=20(pair)=0A=20=20=20=20=20=20=20=20(if=20(string-match=20= "bash$"=20shell-file-name)=0A-=09=20=20=20= (org-babel-variable-assignments:bash=0A+=09=20=20=20= (org-babel--variable-assignments-bash=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20(car=20pair)=20(cdr=20pair)=20sep=20hline)=0A=20=20=20=20=20=20=20=20= =20=20(org-babel-variable-assignments:sh-generic=0A=20=09=20=20(car=20= pair)=20(cdr=20pair)=20sep=20hline)))=0Adiff=20--git=20= a/testing/lisp/test-ob-shell.el=20b/testing/lisp/test-ob-shell.el=0A= index=2058a7859..5a050fe=20100644=0A---=20= a/testing/lisp/test-ob-shell.el=0A+++=20b/testing/lisp/test-ob-shell.el=0A= @@=20-27,6=20+27,17=20@@=0A=20(unless=20(featurep=20'ob-shell)=0A=20=20=20= (signal=20'missing-test-dependency=20"Support=20for=20Shell=20code=20= blocks"))=0A=20=0A+(ert-deftest=20= test-ob-shell/should-respect-ob-interface-naming-convention=20()=0A+=20=20= "Functions=20used=20to=20interface=20with=20the=20different=20org-babel=0A= +=20=20should=20have=20the=20correct=20signature."=0A+=20=20(dolist=20= (shell=20org-babel-shell-names)=0A+=20=20=20=20(org-test-with-temp-text=0A= +=09(format=20"#+BEGIN_SRC=20%s=20:cache=20yes=0A+=20=20echo=20= test=0A+#+END_SRC"=20shell)=0A+=20=20=20=20=20=20(let=20((info=20= (org-babel-get-src-block-info)))=0A+=09(org-babel-sha1-hash=20info)))))=0A= +=0A=20(ert-deftest=20= test-ob-shell/dont-insert-spaces-on-expanded-bodies=20()=0A=20=20=20= "Expanded=20shell=20bodies=20should=20not=20start=20with=20a=20blank=20= line=0A=20unless=20the=20body=20of=20the=20tangled=20block=20does."=0A--=20= =0A2.3.2=20(Apple=20Git-55)=0A=0A= --Apple-Mail=_C839F3FF-CD00-43B5-B818-7FFFD33D8897--