From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id QCR5BEwtH19kTwAA0tVLHw (envelope-from ) for ; Mon, 27 Jul 2020 19:38:52 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id oIFqAEwtH1/VKwAA1q6Kng (envelope-from ) for ; Mon, 27 Jul 2020 19:38:52 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7A7BF940224 for ; Mon, 27 Jul 2020 19:38:50 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 33C9527C31; Mon, 27 Jul 2020 15:38:42 -0400 (EDT) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by mail.notmuchmail.org (Postfix) with ESMTPS id CE9B11F9FA for ; Mon, 27 Jul 2020 15:38:39 -0400 (EDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id A04FF1B0033E; Mon, 27 Jul 2020 22:38:37 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1595878717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=elx9nSj2j4oWrJYmH57sRWaRZ+vwQJlUkSwxwvT8I48=; b=RqqZNrKKoBYtOB+eUMW5QYzuieG/4SQ4SxT7y3q+Ng1VrDPYnyqTGpHkQvpSHsoni5Woou LtsnhGLoaKKEP11G0tyY2fpWmyVd8+pmCVipnOpgOn0v5cX+d9jVt3o1Dj+phgpIDthRBu sDofLCEa4UKpmqi6gQAcz8ioKzxxhMoYdTTnsMkILahxewIHVjIOoDvDq7/3CamlMd3lUZ Pnh8cnn1kuk+wK2RKsJMsbY9KNS6wrnbDAJWLcc95PY/q8+eHjfXL1a41T75sCcE4y/8tb 0V5O7gqzpjTwHmqBnr3bQ1UgqRSV1LmgyHygKOMdjbk4flMy0dZCtveT/Oh5Xw== From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH] notmuch-mutt: replace shell pipeline with internal pipe processing Date: Mon, 27 Jul 2020 22:38:33 +0300 Message-Id: <20200727193833.4654-1-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.13.3 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1595878717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=elx9nSj2j4oWrJYmH57sRWaRZ+vwQJlUkSwxwvT8I48=; b=E5kXFmO+kjrwy5J8+FcR37KZKRbqi19VpS6UyNQHtfG3dwC5lknRQyS79qt3laW+5yGX0A IbvGsTnLXeNMpHmlAIp/grdBY+dYmkRXRIEJNRnXgA80KfNUwBjSiR1D0fTpjzpUIb7H0k 4i58TzRaCkfN1y35MdtB9kh4oufuR2qaC7OgbvxzwT00viI4yeclOFe0Uf5zVcBLNyuFSS gqcV3uI2F/hobkJ8fdleM9uM3emfsaWERRm9wTNZNmQR8ydaZj5jNt92OeYX6DLT15jgLP 0423cyrn+ozwNwmCBoXSCjA16FHzkUYJ91dPNP+K5rbkQk9oMozcUxNipoU3ng== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1595878717; a=rsa-sha256; cv=none; b=W4frzXTWeFOITOOF4JVzNvt4dgZaA5JclKeRscbuPqNBadk9jLWzWX0l9hSqcKFkMJAYgx u3l3OY6SytYOi/o69hBtZAjnyG2orOdvI8h0PFjgAn2k9Rc1YywNQ6zvduMmAJVcX4AhWh M23e0kfyA9ihWnQnalBLzV8NsOCHXODPxDBKlZEenQ2Wy6AdjW5/P2eLDvalfA210UBA0w fhT4PFaRc3nTFzY7y+88thrJ1hEnu+bGpDbREKCwFoW50vB9tjuvXeMkT8eXrZjQ4OpXe6 ZemIRgQtEU9/6VDmPpW1hw6PIo0s6Ce+4bE8A8Okgwqk5OOnQhkQelzKm5ysSw== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi Message-ID-Hash: IBJ4DASZ4RMYYMBJNWZWAMT5QY3NX4IN X-Message-ID-Hash: IBJ4DASZ4RMYYMBJNWZWAMT5QY3NX4IN X-MailFrom: tomi.ollila@iki.fi X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: tomi.ollila@iki.fi X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=iki.fi header.s=lahtoruutu header.b=RqqZNrKK; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 3.03 X-TUID: LLjB+BM7gsJP The shell pipeline used to symlink files based in search results to "cache" directory for mutt(1) to use was prone to portability problems (due to /bin/sh differences). The replacement executes `notmuch search` without intermediate shell (so shell_quote was removed in this case), reads the filenames from piped output and symlinks files internally. --- Now also tested a bit by me (remoteusage provides stale symlinks ;) contrib/notmuch-mutt/notmuch-mutt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt index d33223bd..d1e2c084 100755 --- a/contrib/notmuch-mutt/notmuch-mutt +++ b/contrib/notmuch-mutt/notmuch-mutt @@ -12,6 +12,7 @@ use strict; use warnings; use File::Path; +use File::Basename; use Getopt::Long qw(:config no_getopt_compat); use Mail::Header; use Mail::Box::Maildir; @@ -41,16 +42,17 @@ sub search($$$) { my ($maildir, $remove_dups, $query) = @_; my $dup_option = ""; - $query = shell_quote($query); - - if ($remove_dups) { - $dup_option = "--duplicate=1"; - } + my @args = qw/notmuch search --output=files/; + push @args, "--duplicate=1" if $remove_dups; + push @args, $query; empty_maildir($maildir); - system("notmuch search --output=files $dup_option $query" - . " | sed -e 's: :\\\\ :g'" - . " | while IFS= read -r searchoutput; do ln -s \$searchoutput $maildir/cur/; done"); + open my $pipe, '-|', @args or die "Running @args failed: $!\n"; + while (<$pipe>) { + chomp; + my $ln = "$maildir/cur/" . basename $_; + symlink $_, "$ln" or warn "Failed to symlink '$_', '$ln': $!\n"; + } } sub prompt($$) { -- 2.25.1