From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yG4xC5vWWV8vYAAA0tVLHw (envelope-from ) for ; Thu, 10 Sep 2020 07:32:43 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id sDMVB5vWWV+XdgAAB5/wlQ (envelope-from ) for ; Thu, 10 Sep 2020 07:32:43 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BCCD19402A0 for ; Thu, 10 Sep 2020 07:32:42 +0000 (UTC) Received: from localhost ([::1]:52836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGH4T-0007FL-M4 for larch@yhetil.org; Thu, 10 Sep 2020 03:32:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGH2Q-0004xn-5H for emacs-orgmode@gnu.org; Thu, 10 Sep 2020 03:30:34 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:35015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kGH2O-0005IR-B9 for emacs-orgmode@gnu.org; Thu, 10 Sep 2020 03:30:33 -0400 Received: by mail-pf1-x441.google.com with SMTP id o68so4257030pfg.2 for ; Thu, 10 Sep 2020 00:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:in-reply-to:message-id:date :mime-version; bh=5pC00nD+UEMPyvzo0KGaGHPctawxey06lKkRuYOxDIg=; b=gziuG27JQwPQMvYv0UZzRFK6mRlDFmMI/WmNyHe98g39YYZbVrukIRFGhfDGExCh2D tlnt8SkZFBoG1rj+Y1MrgmOMFJQcKqhB7qGrrDJbiS1vQ3hUwnRQ0YUsWF+Gov7coXD7 /H/C4CCuvWNs3EnoO/9JAlObAU0w0cnSyeLaJeDX7rfgQa97L8xmd9+8XeHD36RkyHoN h6LGMwW+BAhAOrLQk11k44koYu1jClKQ1c3S761QqrOo3J5wlAG0JiBVZY5GUX96Zp6Q Ks28g8mrRQIYaO8KHizwKwW3IkK943/xoRl6501vRRfXSceiXgNDJOjJLd9GDvvxuQL6 C7XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject :in-reply-to:message-id:date:mime-version; bh=5pC00nD+UEMPyvzo0KGaGHPctawxey06lKkRuYOxDIg=; b=qnmOFuE5hw5sqRBdcsaGiTU132jmW9hy+gX+YkJbvhKl60w+L3bpUCFFXqeLk/WnA4 73vN8VWO8ce1/Xk0YiHIfpTJ/CwumWpLFTorf9ksAgUwQgneebTNunU3Ox/Q1Kb27RaI zNHoh6dusnro5b8NA2GWYT3iDeREyLCnI/2nhx9qLU2XuBOzsmJz2pUtz50rIpFhRQGi qv8h+dnCyX2UiPmCD3nk2I9ueLcmOoA/7/A+hX2DIsV34cPQPkwnVSbvN+uEcVY+j9vt qvaqfPTRtOlAepC9nuqAmJnDQNlllEKX+lIiatC5hdbyYrnFEABqRjZJsUbnWaUeg7gJ srSA== X-Gm-Message-State: AOAM530tM0mqjmKE31XPQwPEBdtNLC8tABzm7Ze2ihai4aeKnW6wdquq bcQWdE7uTC6AbkiwqFxLErvw0ZHboYY= X-Google-Smtp-Source: ABdhPJzAuff1PUlJiBc6PaRyqbfzBGHlEffrIUlLDpCmYS7PqQqoGtdxPYZH9ggTU8CJ82VjzS3sXA== X-Received: by 2002:a62:7e04:: with SMTP id z4mr4207663pfc.64.1599723030176; Thu, 10 Sep 2020 00:30:30 -0700 (PDT) Received: from tim-desktop (220-235-2-107.dyn.iinet.net.au. [220.235.2.107]) by smtp.gmail.com with ESMTPSA id n68sm5001899pfn.145.2020.09.10.00.30.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 00:30:29 -0700 (PDT) References: <87y2loakcw.fsf@gnu.org> <87d030ae7g.fsf@bzg.fr> User-agent: mu4e 1.5.5; emacs 28.0.50 From: Tim Cross To: emacs-orgmode@gnu.org Subject: Re: Shouldn't ob-shell's org-babel-expand-src-block prepend the :shebang value? In-reply-to: Message-ID: <871rjaytpq.fsf@gmail.com> Date: Thu, 10 Sep 2020 17:30:25 +1000 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=theophilusx@gmail.com; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=gziuG27J; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.71 X-TUID: ADYhfNC3oOG2 Vladimir Nikishkin 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/ or #!/usr/bin/env ? 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