From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id IH1kMFnZLGZrugAAe85BDQ:P1 (envelope-from ) for ; Sat, 27 Apr 2024 12:54:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id IH1kMFnZLGZrugAAe85BDQ (envelope-from ) for ; Sat, 27 Apr 2024 12:54:17 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1714215257; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=EqcghA4p3kO/han0reB+yhaU8Z0ZjeF9a4Nxce0aU+Y=; b=LpCXZWLdnrugBndh4EwpkdMzZkEv4WIBIuRVxVD082aduArbyFJzSKlDXKZB/gtedOu5f1 0R4SBmj8PVOnxDuNbKgEUIEygtX6x/CNf1NwT4nJzpOvPtRDMG7NyN7sxFwmgaEHAnQ6Gp RCm404Xzh6dVdjqGA95jlwzj/cAP5imk14l1JHBr3oQyx1NA7kbnzZ2Rncn1zFtfMe55h1 r8KLwtoG3RC1BJBMXTWpKv014nmhN02ib2pzgz+yCQzO31bLUecnwYx7mbtrcgZ6jZh2yR aUSJXwo9uCYPm/JsFDR+Gt6b5o1LM0RYnXrFFNBoZ8tS6Xkwi3g/OQHxBQxUGQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1714215257; a=rsa-sha256; cv=none; b=FWUIggdR90uReV4/FDVeH7JUyGduWxx/meyhNlTpno4fkwzAaQl1CHh1mvX0Z/FqwLz6aM BCHMzHMtlZaxxDFlosgyXnykhyX5F1x2HqmHDVb2hIaNYVsgBTzRsj7m0fmarhu6pfL20D TVwkJDbM4Ms/CpdeGJeGVvO2SiPlyV3YWRmFlt3l9r9yRGMDVr364K+5KEQm0xdaJxU40x GOPfZkHhlTkl6oLW1SLsPBUW9AgTtC5rhcK2xQsAQByPyRTpvRZVKzdaVK6pyhw7h9p/fb bDNZkEupKPHyKUeiKKx/1jzYFnlfteNZ0n0o1TYJ+v2uBlD9W8hifHZKn3czbg== 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 9469B176D5 for ; Sat, 27 Apr 2024 12:54:17 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0fga-00083E-44; Sat, 27 Apr 2024 06:53:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0fgY-00082p-E7 for emacs-orgmode@gnu.org; Sat, 27 Apr 2024 06:53:38 -0400 Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0fgV-0003tl-BK for emacs-orgmode@gnu.org; Sat, 27 Apr 2024 06:53:38 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1s0fgT-0000z8-3W for emacs-orgmode@gnu.org; Sat, 27 Apr 2024 12:53:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: [DISCUSSION] The meaning of :cmdline header argument across babel backends Date: Sat, 27 Apr 2024 17:53:25 +0700 Message-ID: References: <18f01342a2f.124ad27612732529.8693431365849276517@excalamus.com> <871q6suv7z.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla Thunderbird Content-Language: en-US, ru-RU In-Reply-To: <871q6suv7z.fsf@localhost> Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -0.86 X-Spam-Score: -0.86 X-Migadu-Queue-Id: 9469B176D5 X-Migadu-Scanner: mx13.migadu.com X-TUID: OmeGaeKXIBa/ On 26/04/2024 20:09, Ihor Radchenko wrote: > Max Nikulin writes: > >> However looking wider, I do not like that :cmdline for ob-shell has >> different meaning than for other languages, see e.g. ob-sql. Only for >> shell this parameter is treated as arguments of a *script*. In other >> cases :cmdline is used to specify arguments of *interpreter* and I think >> ob-shell should follow this convention. > > Alas, we already have the current state of affairs documented in > https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-shell.html#orge70bc7b > > So, no breaking changes. It is documented as " :cmdline ... [arg_n] Use the :cmdline header arg to pass arguments to a shell command." However current implementation allows code injection through args, including a trivial one #+header-arg: :results verbatim #+begin_src sh :cmdline 1 ; touch /tmp/not-an-arg printf '%s\n' "$@" #+end_src #+RESULTS: : 1 "touch ..." *are not arguments of the script*. So users should be careful to get documented behavior. > And shell scripts are not like SQL queries - they often do need to check > arguments. So, the current behaviour is justified, IMHO. stackoverflow is full of suggestion how to pass arguments to a SQL script executed by mysql. Unfortunately it is unsafe and allows injection of code. psql (PostgreSQL) allows to pass parameters, however it is more like :var than script arguments. So it is true that CLI clients for SQL databases do not implement positional parameters. ARGV is treated in a quite specific way by awk. It may contain file names, variable assignments, and might be overwritten in BEGIN block. However a close ob-awk header argument is :cmd-line, not :cmdline, so inconsistency is even greater. > What might be done is introducing _two_ different header arguments - one > for interpreter switches, and another for script/program switches. > > Say, :interpreter-cmdline and :script-cmdline. > Then, we can call the current :cmdline behaviour "dwim" and allow users > to be more explicit if necessary. It is too easy to confuse org-babel, so "dwim" works in simple cases only. Independent header arguments make things more clear, I would prefer :script-args. The question is whether they should be interpreted by shell (flexibility and shooting feet) or more strict syntax `("hello world" 1 a) should be used.