From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id yKm4IL5htGK3+QAAbAwnHQ (envelope-from ) for ; Thu, 23 Jun 2022 14:51:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id KI7AH75htGKKrgAAG6o9tA (envelope-from ) for ; Thu, 23 Jun 2022 14:51:10 +0200 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 113983C112 for ; Thu, 23 Jun 2022 14:51:10 +0200 (CEST) Received: from localhost ([::1]:58254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4MIe-00050F-Hk for larch@yhetil.org; Thu, 23 Jun 2022 08:51:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4MD7-000355-5N for emacs-orgmode@gnu.org; Thu, 23 Jun 2022 08:45:26 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]:35662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4MD5-0005Wb-7m for emacs-orgmode@gnu.org; Thu, 23 Jun 2022 08:45:24 -0400 Received: by mail-ot1-x332.google.com with SMTP id t26-20020a9d775a000000b006168f7563daso2594521otl.2 for ; Thu, 23 Jun 2022 05:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=gc9TdmaO+PdvNgCT4vtlIoYlmQv1v63Qsb3PHZnK6Kw=; b=MlTP8hXV2mx2acS6ML0+PkbyRbpJvG4HJWF7QQuWylE9Yc8JypcKRvZS0vlUWwzV1B G3WD1dBBZuOCSOQ3Uqj3+/IKZWz5gRQuvJAUpRmg4HNEExijCngfscXbwp6ryzl2jdPJ UIlHE1Rcg1sdK5QByqeSjCOIZWk5/fUFxBi3WqeU2p0bOkzVXLJvkKXoFhuU0T4xPvmN s1j4wx7dNlp9Z90venJEFh8EmDbaSU36Zq4S36Gz5Mvir01QX9SiLPqL+L4TQ3pikjQN jH7isgHVPZfDs4s2g5cYf1XFQYR+/nB2uZ5ymNYvenNxLHh3Frg4pqi8FsYGIo/v82uv L1aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=gc9TdmaO+PdvNgCT4vtlIoYlmQv1v63Qsb3PHZnK6Kw=; b=H71/smw0CzYtnyk9MwgmBTIz2rY346XhJJsFcBCiJBe5Y/OiY1xWh2OpH/IJwJocO5 I4qwBGRuH/N7PFmTCmWw2zY8hmUvCwbolcW7aI3BzUWdGZHhAPhFGUVnpdqrGcJXMLXE GHFNQgJ2MB8ewA4bxt4MZi+0amOfrfPuEjqRtIOgekgg98i+kbm641YD5DWymP81gtgl 1JrVZwPpjDFOrjFJs1IEqICFMjyGb+E2mOvZwPd7vcSzxk7PRzG4XRVA8fZPuT46TW5m 7Ix9L+zoIInvDSzKA1J8K0dn9dKHV9FXEiYVtQHA+oIFrSOtXWcM4CaCxUABFtu1yyeo s/CQ== X-Gm-Message-State: AJIora+HOERh4pBbjmi27lkTvd8Mi9hwOHENovVofeS4jWtXwAPl651b zajdahevtdSyfmZJtunjtsI= X-Google-Smtp-Source: AGRyM1ueuwS+dCklRdCELezU81zWsDNjgi8wy52ThuQ0RDVbMqJqWPuUOQV23Uns9EvYfG4KjlUzyA== X-Received: by 2002:a05:6830:31a3:b0:60c:3dd3:708f with SMTP id q3-20020a05683031a300b0060c3dd3708fmr3750435ots.172.1655988321979; Thu, 23 Jun 2022 05:45:21 -0700 (PDT) Received: from localhost ([207.126.88.10]) by smtp.gmail.com with ESMTPSA id f2-20020a056870d30200b000f5d8d031b6sm12386778oag.49.2022.06.23.05.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 05:45:21 -0700 (PDT) From: Ihor Radchenko To: Bruno Barbier Cc: Felix Freeman , emacs-orgmode@gnu.org Subject: Re: [BUG] ob-shell: cmdline and stdin broken when used with TRAMP In-Reply-To: References: Date: Thu, 23 Jun 2022 20:46:32 +0800 Message-ID: <87k097a6on.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::332; envelope-from=yantar92@gmail.com; helo=mail-ot1-x332.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655988670; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=gc9TdmaO+PdvNgCT4vtlIoYlmQv1v63Qsb3PHZnK6Kw=; b=GUnuUIgT5Lax/ZMyHWWQKJR7++GlzNUm9MPD6f1djC24T6DA6/tIWhBhQLIQHba7lqmCk5 9Kn1gJ5DH8k03xJlvqomtKq9kfpIieta4aRR04DAcccNnQD3vAZY9wqX6CV3G/pfH0H3mb e2VT0DI2j2CE8t8jUMnmX7Lj/LNagSQE4UACE3V5yKdfu9prxeolTQ8tzruuaOnL3lLtOC LQxGxE+knfOe20OwO9gJKyw1PTqsBLTK6hcVcLDWUo+puaSACGRDqBt/5Zm5eKdg52K5Gl iwH08bZuRtCdqT9oZ4+IwCKSJUoZ/rTs9Rr08fcp9o5jBrvo+ZLsmsh/1mS+Cg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655988670; a=rsa-sha256; cv=none; b=jK85xIkUGfOv0EFbhpw6SvvN4+FhA0Cc2+Q0XNUjO1vke+ecX60+i8jEjlFxVOqQ3xWfgL kVOzuw4Vxx+6CY9WsUurY0PJRkIowBQsF8PUnY9E17lpzAZAtB6gfpCYtoAPVukWfgyWw9 JNgwpTHoU9hImDkPKONh0KU8vX8rua+qu9jfCu6xcUdzzvMf4CCYuv5PPKOKFwqNNAlELd RZgVn0fDLQKPFER7u/3v3pg2Vz4zH3gHGO+9vBxwrULAXYt8ksYVU1VkWK9seCUoyTcaJs OYcXuoAJDf/ijM3+LOgakgADLLvksfopilCfRZw2aHfpYObPntwCPGhhbJpTtw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MlTP8hXV; dmarc=pass (policy=none) header.from=gmail.com; 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" X-Migadu-Spam-Score: -3.46 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MlTP8hXV; dmarc=pass (policy=none) header.from=gmail.com; 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" X-Migadu-Queue-Id: 113983C112 X-Spam-Score: -3.46 X-Migadu-Scanner: scn1.migadu.com X-TUID: VDDerCzqkmPj Bruno Barbier writes: > From what I understand, the function 'org-babel-sh-evaluate' relies on > 'call-process'; and that function ignores file name handlers; as TRAMP > relies on those file name handlers, it just cannot do the right thing. > > Using 'process-file' instead works for me. > > See the attached patch. Thanks for the patch! I am not very familiar with TRAMP, but since you supplied tests and they are also passing on my side, everything looks good. > I've also included a test, as the problem is reproducible with TRAMP > "/mock::" connection. But, that test will only work on GNU/Linux > systems. Then you also need to guard the tests against system-type variable value. If we cannot tests things on Windows, we should at least make the tests not fail when they should not. > Warning: that's my first attempt to write a patch, and I don't have > (yet) signed the copyright papers. You patch is >15LOC so we do need your copyright assignment before merging. Let me know if you face any difficulties with the copyright process. Note that FSF should reply within 5 working days. > lib/ob-shell.el (org-babel-sh-evaluate): Use 'process-file' (instead > of 'call-process-shell-command') so that 'org-babel-sh-evaluate' will > invoke file name handlers based on 'default-directory', if needed, > like when using a remote directory. Note that we quote symbols like `symbols'. See https://orgmode.org/worg/org-contribute.html#commit-messages Also, please link to the bug report in the commit message for future reference. > + (apply #'process-file > + (if shebang (file-local-name script-file) > + shell-file-name) > + stdin-file > + (current-buffer) > + nil > + (if shebang (when cmdline (list cmdline)) > + (list shell-command-switch > + (concat (file-local-name script-file) " " cmdline))) > + )) Probably you do not need concat here. AFAIU, (list shell-command-switch (file-local-name script-file) cmdline) should be good enough as ARGS argument of `process-file'. > + (:stdin t :shebang t) > + (:cmdline t :stdin t :shebang t) > + )) Please do not leave closing parenthesis at a separate line. See D.1 Emacs Lisp Coding Conventions section of Elisp manual for details. > +(defconst org-test-tramp-remote-dir "/mock::/tmp/" > + "Remote tramp directory. > +We really should use 'tramp-test-temporary-file-directory', but that would require TRAMP sources.") Since TRAMP sources are not normally available, we can add this variable as defined in tramp-tests.el somewhere into testing/org-test.el, for example. Best, Ihor