From unknown Fri Jun 20 07:14:55 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#23324 <23324@debbugs.gnu.org> To: bug#23324 <23324@debbugs.gnu.org> Subject: Status: shell-resync-dirs does not handle dirs with whitespace Reply-To: bug#23324 <23324@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:14:55 +0000 retitle 23324 shell-resync-dirs does not handle dirs with whitespace reassign 23324 emacs submitter 23324 Noah Friedman severity 23324 minor tag 23324 confirmed patch fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 20 23:37:54 2016 Received: (at submit) by debbugs.gnu.org; 21 Apr 2016 03:37:54 +0000 Received: from localhost ([127.0.0.1]:41798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1at5RB-0008ES-Ku for submit@debbugs.gnu.org; Wed, 20 Apr 2016 23:37:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1at5RA-0008E9-Au for submit@debbugs.gnu.org; Wed, 20 Apr 2016 23:37:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1at5R3-0008FQ-VI for submit@debbugs.gnu.org; Wed, 20 Apr 2016 23:37:47 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1at5R3-0008FM-Rk for submit@debbugs.gnu.org; Wed, 20 Apr 2016 23:37:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1at5R2-00072h-Ek for bug-gnu-emacs@gnu.org; Wed, 20 Apr 2016 23:37:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1at5R0-0008Ej-5Y for bug-gnu-emacs@gnu.org; Wed, 20 Apr 2016 23:37:44 -0400 Received: from bacon-event-horizon.splode.com ([2600:3c01::f03c:91ff:fe96:f92b]:54172 helo=splode.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1at5Qz-0008EA-Tn for bug-gnu-emacs@gnu.org; Wed, 20 Apr 2016 23:37:42 -0400 Received: from unexploded-cow.prv.splode.com (prv.splode.com [173.8.128.9]) (authenticated bits=0) by splode.com (8.15.2/8.15.2) with ESMTPSA id u3L2chKH026519 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Wed, 20 Apr 2016 19:38:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=splode.com; s=splode-20130101; t=1461206324; bh=8j5sZbTnYbGEOSdsGZ8yDl6BNHAtMAFpCNsxQ3CP6SA=; h=From:To:Subject:Reply-To:Date:From; b=t4WqlZ6duX0ETLEi+v9WD9+bFww30WCSUbQuCAjTJzynvL9R0ZG/rWnoy+cny1Wzq zcwJ135xQHWcx16eg5gbUdRKRelubn9K5FmBPOBRtD+kQsTPUqxJycu3ZyfS0Q95we pCfjIvLF1D6Nsyc2cdJUPG7Xk/M58pjbchAk3Ufs= MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Bridge/POCSAG/South-Africa/Hamas/anarchy/Cohiba/QXdD9TUv7D" Content-Transfer-Encoding: 7bit From: Noah Friedman To: bug-gnu-emacs@gnu.org Subject: shell-resync-dirs does not handle dirs with whitespace Date: Wed, 20 Apr 2016 19:38:43 -0700 (PDT) Message-Id: <20160420193843.651480.FMU1050@unexploded-cow.prv.splode.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Noah Friedman Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) --Bridge/POCSAG/South-Africa/Hamas/anarchy/Cohiba/QXdD9TUv7D Content-Type: text/plain; charset=utf-8 Content-Description: message body text Content-Transfer-Encoding: quoted-printable I have a fix for this, but I'd like for someone else to look over it an= d perhaps sanity check it before I commit it. Volunteers=3F This is a very old limitation. Let's say I have three directories in my shell buffer directory stack: =09/s/software/wwwroot/Java Development Kit =09/s/software/wwwroot/Perl Compatible Regular Expressions =09~/src/build/depot/main/tools/build If I run M-x shell-resync-dirs, I simply get the error: =09Couldn=E2=80=99t cd: (error No such directory found via CDPATH envir= onment variable) because the directory "/s/software/wwwroot/Java" doesn't exist. The pa= rser considers whitespace to be a separator between directory tokens. This version handles that case. Diff and full function attached below. --Bridge/POCSAG/South-Africa/Hamas/anarchy/Cohiba/QXdD9TUv7D Content-Type: text/plain; name="ChangeLog" Content-Disposition: inline; filename="ChangeLog" Content-Transfer-Encoding: 7bit 2016-04-21 Noah Friedman * lisp/shell.el (shell-resync-dirs): Correctly handle whitespace in directory names. --Bridge/POCSAG/South-Africa/Hamas/anarchy/Cohiba/QXdD9TUv7D Content-Type: text/plain; name="shell.el.diff" Content-Disposition: inline; filename="shell.el.diff" Content-Transfer-Encoding: 7bit --- 2016-04-20--18-08-56--0c9f35a/lisp/shell.el.~1~ 2016-01-01 01:34:24.000000000 -0800 +++ 2016-04-20--18-08-56--0c9f35a/lisp/shell.el 2016-04-20 19:24:25.534756498 -0700 @@ -985,45 +985,62 @@ ;; If the process echoes commands, don't insert a fake command in ;; the buffer or it will appear twice. (unless comint-process-echoes - (insert shell-dirstack-query) (insert "\n")) + (insert shell-dirstack-query "\n")) (sit-for 0) ; force redisplay (comint-send-string proc shell-dirstack-query) (comint-send-string proc "\n") (set-marker pmark (point)) (let ((pt (point)) - (regexp - (concat - (if comint-process-echoes - ;; Skip command echo if the process echoes - (concat "\\(" (regexp-quote shell-dirstack-query) "\n\\)") - "\\(\\)") - "\\(.+\n\\)"))) + (regexp (concat + (if comint-process-echoes + ;; Skip command echo if the process echoes + (concat "\\(" (regexp-quote shell-dirstack-query) "\n\\)") + "\\(\\)") + "\\(.+\n\\)"))) ;; This extra newline prevents the user's pending input from spoofing us. - (insert "\n") (backward-char 1) + (insert "\n") + (backward-char 1) ;; Wait for one line. (while (not (looking-at regexp)) - (accept-process-output proc) + (accept-process-output proc 1) (goto-char pt))) - (goto-char pmark) (delete-char 1) ; remove the extra newline + (goto-char pmark) + (delete-char 1) ; remove the extra newline + ;; That's the dirlist. grab it & parse it. - (let* ((dl (buffer-substring (match-beginning 2) (1- (match-end 2)))) - (dl-len (length dl)) - (ds '()) ; new dir stack - (i 0)) - (while (< i dl-len) - ;; regexp = optional whitespace, (non-whitespace), optional whitespace - (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir - (setq ds (cons (concat comint-file-name-prefix - (substring dl (match-beginning 1) - (match-end 1))) - ds)) - (setq i (match-end 0))) - (let ((ds (nreverse ds))) - (with-demoted-errors "Couldn't cd: %s" - (shell-cd (car ds)) - (setq shell-dirstack (cdr ds) - shell-last-dir (car shell-dirstack)) - (shell-dirstack-message))))) + (let* ((dls (buffer-substring-no-properties (match-beginning 0) (1- (match-end 0)))) + (dlsl '()) + (pos 0) + (ds '())) + ;; Split the dirlist into whitespace and non-whitespace chunks. + ;; dlsl will be a reversed list of tokens. + (while (string-match "\\(\\S-+\\|\\s-+\\)" dls pos) + (push (match-string 1 dls) dlsl) + (setq pos (match-end 1))) + + ;; prepend trailing entries until they form an existing directory, + ;; whitespace and all. discard the next whitespace and repeat. + (while dlsl + (let ((newelt "") + tem1 tem2) + (while newelt + ;; We need tem1 because we don't want to prepend + ;; comint-file-name-prefix repeatedly into newelt via tem2. + (setq tem1 (pop dlsl) + tem2 (concat comint-file-name-prefix tem newelt)) + (cond ((file-directory-p tem2) + (push tem2 ds) + (when (string= " " (car dlsl)) + (pop dlsl)) + (setq newelt nil)) + (t + (setq newelt (concat tem1 newelt))))))) + + (with-demoted-errors "Couldn't cd: %s" + (shell-cd (car ds)) + (setq shell-dirstack (cdr ds) + shell-last-dir (car shell-dirstack)) + (shell-dirstack-message)))) (if started-at-pmark (goto-char (marker-position pmark))))) ;; For your typing convenience: --Bridge/POCSAG/South-Africa/Hamas/anarchy/Cohiba/QXdD9TUv7D Content-Type: text/plain; name="shell-resync-dirs.el" Content-Disposition: inline; filename="shell-resync-dirs.el" Content-Transfer-Encoding: 7bit (defun shell-resync-dirs () "Resync the buffer's idea of the current directory stack. This command queries the shell with the command bound to `shell-dirstack-query' (default \"dirs\"), reads the next line output and parses it to form the new directory stack. DON'T issue this command unless the buffer is at a shell prompt. Also, note that if some other subprocess decides to do output immediately after the query, its output will be taken as the new directory stack -- you lose. If this happens, just do the command again." (interactive) (let* ((proc (get-buffer-process (current-buffer))) (pmark (process-mark proc)) (started-at-pmark (= (point) (marker-position pmark)))) (save-excursion (goto-char pmark) ;; If the process echoes commands, don't insert a fake command in ;; the buffer or it will appear twice. (unless comint-process-echoes (insert shell-dirstack-query "\n")) (sit-for 0) ; force redisplay (comint-send-string proc shell-dirstack-query) (comint-send-string proc "\n") (set-marker pmark (point)) (let ((pt (point)) (regexp (concat (if comint-process-echoes ;; Skip command echo if the process echoes (concat "\\(" (regexp-quote shell-dirstack-query) "\n\\)") "\\(\\)") "\\(.+\n\\)"))) ;; This extra newline prevents the user's pending input from spoofing us. (insert "\n") (backward-char 1) ;; Wait for one line. (while (not (looking-at regexp)) (accept-process-output proc 1) (goto-char pt))) (goto-char pmark) (delete-char 1) ; remove the extra newline ;; That's the dirlist. grab it & parse it. (let* ((dls (buffer-substring-no-properties (match-beginning 0) (1- (match-end 0)))) (dlsl '()) (pos 0) (ds '())) ;; Split the dirlist into whitespace and non-whitespace chunks. ;; dlsl will be a reversed list of tokens. (while (string-match "\\(\\S-+\\|\\s-+\\)" dls pos) (push (match-string 1 dls) dlsl) (setq pos (match-end 1))) ;; prepend trailing entries until they form an existing directory, ;; whitespace and all. discard the next whitespace and repeat. (while dlsl (let ((newelt "") tem1 tem2) (while newelt ;; We need tem1 because we don't want to prepend ;; comint-file-name-prefix repeatedly into newelt via tem2. (setq tem1 (pop dlsl) tem2 (concat comint-file-name-prefix tem newelt)) (cond ((file-directory-p tem2) (push tem2 ds) (when (string= " " (car dlsl)) (pop dlsl)) (setq newelt nil)) (t (setq newelt (concat tem1 newelt))))))) (with-demoted-errors "Couldn't cd: %s" (shell-cd (car ds)) (setq shell-dirstack (cdr ds) shell-last-dir (car shell-dirstack)) (shell-dirstack-message)))) (if started-at-pmark (goto-char (marker-position pmark))))) --Bridge/POCSAG/South-Africa/Hamas/anarchy/Cohiba/QXdD9TUv7D-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 21 11:34:13 2016 Received: (at control) by debbugs.gnu.org; 21 Apr 2016 15:34:13 +0000 Received: from localhost ([127.0.0.1]:42476 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atGcP-00050Q-1c for submit@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:13 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56725) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atGcN-00050D-6M for control@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1atGcC-0007a6-Nh for control@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:06 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39673) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atGcC-0007a2-Kv for control@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:00 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1atGcC-0006FY-7i for control@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:00 -0400 Subject: control message for bug 23324 To: X-Mailer: mail (GNU Mailutils 2.99.98) Message-Id: From: Glenn Morris Date: Thu, 21 Apr 2016 11:34:00 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) merge 23326 23324 severity 23324 minor From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 25 19:19:38 2016 Received: (at control) by debbugs.gnu.org; 25 Apr 2016 23:19:39 +0000 Received: from localhost ([127.0.0.1]:47097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aupn0-0001kI-Pq for submit@debbugs.gnu.org; Mon, 25 Apr 2016 19:19:38 -0400 Received: from hermes.netfonds.no ([80.91.224.195]:49616) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aupmz-0001kA-7k for control@debbugs.gnu.org; Mon, 25 Apr 2016 19:19:37 -0400 Received: from cm-84.215.1.64.getinternet.no ([84.215.1.64] helo=stories) by hermes.netfonds.no with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1aupmx-0001Ji-3y for control@debbugs.gnu.org; Tue, 26 Apr 2016 01:19:36 +0200 Date: Tue, 26 Apr 2016 01:19:34 +0200 Message-Id: To: control@debbugs.gnu.org From: Lars Magne Ingebrigtsen Subject: control message for bug #23324 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) tags 23324 patch From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 13:08:59 2018 Received: (at control) by debbugs.gnu.org; 3 Sep 2018 17:08:59 +0000 Received: from localhost ([127.0.0.1]:44553 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fwsLT-000838-Gh for submit@debbugs.gnu.org; Mon, 03 Sep 2018 13:08:59 -0400 Received: from mail-io0-f174.google.com ([209.85.223.174]:43742) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fwsLS-00082p-0p; Mon, 03 Sep 2018 13:08:58 -0400 Received: by mail-io0-f174.google.com with SMTP id y10-v6so861007ioa.10; Mon, 03 Sep 2018 10:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=T6qj1C40tG4OdcLoUDc+gRpO48rv0znfcvT57bb+VxY=; b=TJI8MOTCX6bPAfUHldsuQBkI5CX9W6IztLQrBQ8nKDtNntVq57XjbgbRgLctHWr1x3 rBfFrxoSNDEsk0kAJaLzIGS/1dgqSfnPTtKH497jSq3zadTVbjVbMjKJWgXDVR2xHUev rbiOlFhKGK+fx8co7N8cLlnp7QF1ZL8pNejMfm/Ag6foc/vLP7OTrh3U2eXe9RSkeKlb OSi4b170NDIAyBtXMCuE20XUtwaOwoVs+gTuFDNuII9m5UCVSa3adkk3jABCOi5BguRJ LbxHT/opS6tFqMVOuiRFZBNWW4b7snS7ctcnYNGFMlU8TMpLsAk+fcr0p4FLTFUXsnUZ 9LMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=T6qj1C40tG4OdcLoUDc+gRpO48rv0znfcvT57bb+VxY=; b=QtgfoljrkFL3+6gMPOhy5joYk96H6LsEz0Q2Xl+ZE2kxVKmamhQUyALicListOteCb LT9fnL3McYiXbe/kFXOAYEQ6Ai1LdVICLxACx0YB316guFf4I4nhdrxFmp32qYU2/Ymg N0lX1HCbVZJXp5w5ry2SlbpgMJbVmljafa/NK8SXjhk63c32rPCtdjOjTGZuNlRdOTvd JBzhvXecnDavZEIq/hIxKl+LF72UBtDDTMacjxbOZEbpksFcT6+JSol9OKOvYNXsQeOq 36pbfNRW+AWJPEKQJYkWTHdcPyqB6LTBrq6MB0vi0ta9cEDRJ2Y1QhMxKpUnkgMI/RBB WbPw== X-Gm-Message-State: APzg51DXSYepRB5R/T1RS6iacOJ/lNoSkD/mNfY/BvRUjyhqv2i717Ro TXSKggtV3+1sr/i0Nibji5ILq11W X-Google-Smtp-Source: ANB0Vdbrq/+fVHnHIzeRx5WfwRaKY/akf1KQqWzffHtcz2d66MHwTPQNv/FnjgM3Mm7monp48C8WjQ== X-Received: by 2002:a5e:890f:: with SMTP id k15-v6mr5801343ioj.9.1535994532237; Mon, 03 Sep 2018 10:08:52 -0700 (PDT) Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id n140-v6sm6692198itb.37.2018.09.03.10.08.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Sep 2018 10:08:51 -0700 (PDT) From: Noam Postavsky To: Noah Friedman Subject: Re: bug#23324: shell-resync-dirs does not handle dirs with whitespace References: <20160420193843.651480.FMU1050@unexploded-cow.prv.splode.com> Date: Mon, 03 Sep 2018 13:08:42 -0400 In-Reply-To: <20160420193843.651480.FMU1050@unexploded-cow.prv.splode.com> (Noah Friedman's message of "Wed, 20 Apr 2016 19:38:43 -0700 (PDT)") Message-ID: <8736uqik4l.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control Cc: 23324@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) forcemerge 23324 11608 9379 quit Noah Friedman writes: > I have a fix for this, but I'd like for someone else to look over it and > perhaps sanity check it before I commit it. Volunteers? > This is a very old limitation. By now this is a fairly old patch, but still in need of review it seems. > + (let* ((dls (buffer-substring-no-properties (match-beginning 0) (1- (match-end 0)))) > + (dlsl '()) > + (pos 0) > + (ds '())) > + ;; Split the dirlist into whitespace and non-whitespace chunks. > + ;; dlsl will be a reversed list of tokens. > + (while (string-match "\\(\\S-+\\|\\s-+\\)" dls pos) > + (push (match-string 1 dls) dlsl) > + (setq pos (match-end 1))) > + > + ;; prepend trailing entries until they form an existing directory, > + ;; whitespace and all. discard the next whitespace and repeat. I think this loop is going in the wrong direction (i.e., it should rather be appending leading entries). Because of this, it can be fooled by subdirectories with a name matching a substring of a dirs entry: ~$ mkdir -p 'foo bar/bar/' ~$ cd 'foo bar/' ~/foo bar$ command dirs # M-x dirs # infloops... > + (let ((newelt "") > + tem1 tem2) I'm also not a fan of the somewhat inscrutable tem1 & tem2 names. From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 27 12:25:14 2019 Received: (at 23324) by debbugs.gnu.org; 27 Jun 2019 16:25:14 +0000 Received: from localhost ([127.0.0.1]:39385 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgXD0-00089W-A0 for submit@debbugs.gnu.org; Thu, 27 Jun 2019 12:25:14 -0400 Received: from quimby.gnus.org ([80.91.231.51]:44962) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgXCy-00089G-52; Thu, 27 Jun 2019 12:25:12 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hgXCt-0007YY-7b; Thu, 27 Jun 2019 18:25:09 +0200 From: Lars Ingebrigtsen To: Noah Friedman Subject: Re: bug#23324: shell-resync-dirs does not handle dirs with whitespace References: <20160420193843.651480.FMU1050@unexploded-cow.prv.splode.com> Date: Thu, 27 Jun 2019 18:25:07 +0200 In-Reply-To: <20160420193843.651480.FMU1050@unexploded-cow.prv.splode.com> (Noah Friedman's message of "Wed, 20 Apr 2016 19:38:43 -0700 (PDT)") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Noah Friedman writes: > 2016-04-21 Noah Friedman > > * lisp/shell.el (shell-resync-dirs): Correctly handle > whitespace in directory names. The patch doesn't seem to be correct: Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 23324 Cc: 23324@debbugs.gnu.org, 9379@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Noah Friedman writes: > 2016-04-21 Noah Friedman > > * lisp/shell.el (shell-resync-dirs): Correctly handle > whitespace in directory names. The patch doesn't seem to be correct: In shell-resync-dirs: shell.el:1044:58:Warning: reference to free variable =E2=80=98tem=E2=80=99 Should probably be either tem1 or tem2? --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 27 12:26:00 2019 Received: (at control) by debbugs.gnu.org; 27 Jun 2019 16:26:01 +0000 Received: from localhost ([127.0.0.1]:39388 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgXDk-0008Ax-Ms for submit@debbugs.gnu.org; Thu, 27 Jun 2019 12:26:00 -0400 Received: from quimby.gnus.org ([80.91.231.51]:44976) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgXDj-0008Aq-8c for control@debbugs.gnu.org; Thu, 27 Jun 2019 12:25:59 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hgXDg-0007av-Nv for control@debbugs.gnu.org; Thu, 27 Jun 2019 18:25:58 +0200 Date: Thu, 27 Jun 2019 18:25:56 +0200 Message-Id: To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #9379 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 9379 + confirmed quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 9379 + confirmed quit From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 12 07:45:10 2020 Received: (at 23324) by debbugs.gnu.org; 12 Aug 2020 11:45:10 +0000 Received: from localhost ([127.0.0.1]:43102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5pBu-0001xp-IT for submit@debbugs.gnu.org; Wed, 12 Aug 2020 07:45:10 -0400 Received: from quimby.gnus.org ([95.216.78.240]:44082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5pBq-0001ww-9D for 23324@debbugs.gnu.org; Wed, 12 Aug 2020 07:45:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YsSyjLy3fQJGRKITN5/bD/uzDvzqEnDDOXal1Hm6md4=; b=rCXjb34RDqrKb2y9Ynho7LZOl6 cN9ernL4C58vUjax0TugWqaw3Ic4uVGkN31a1hXxlD6RXRDIsQKEuOH3rh7VwlO2EvQcZ0Au/XJyM KDzzLeB7nQ58hhiegsqE4l9VywbEyvZ/QeDlHuURCsB/+TKz6TyQrLo5LLvyy31s8/Ww=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5pBg-0000Bz-Lv; Wed, 12 Aug 2020 13:44:59 +0200 From: Lars Ingebrigtsen To: Noam Postavsky Subject: Re: bug#23324: shell-resync-dirs does not handle dirs with whitespace References: <20160420193843.651480.FMU1050@unexploded-cow.prv.splode.com> <8736uqik4l.fsf@gmail.com> Date: Wed, 12 Aug 2020 13:44:51 +0200 In-Reply-To: <8736uqik4l.fsf@gmail.com> (Noam Postavsky's message of "Mon, 03 Sep 2018 13:08:42 -0400") Message-ID: <87eeocnl58.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Noam Postavsky writes: > I think this loop is going in the wrong direction (i.e., it should > rather be appending leading entries). Because of this, it can be fooled > by subdirectories with a name matching a substring of a [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 23324 Cc: 23324@debbugs.gnu.org, Noah Friedman X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Noam Postavsky writes: > I think this loop is going in the wrong direction (i.e., it should > rather be appending leading entries). Because of this, it can be fooled > by subdirectories with a name matching a substring of a dirs entry: > > ~$ mkdir -p 'foo bar/bar/' > ~$ cd 'foo bar/' > ~/foo bar$ command dirs # M-x dirs > # infloops... > >> + (let ((newelt "") >> + tem1 tem2) > > I'm also not a fan of the somewhat inscrutable tem1 & tem2 names. I've respun the patch so that it actually works (tem1 was mis-spelled in one place, and there was a bunch of unrelated white space fix-ups that I've remove), but haven't done anything else to it. Noam, I tried your test case, but I couldn't get it to infloop. Is there some additional steps needed to make it infloop? diff --git a/lisp/shell.el b/lisp/shell.el index f5e18bbc72..ed4b1efde0 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -1039,24 +1039,40 @@ shell-resync-dirs (goto-char pt))) (goto-char pmark) (delete-char 1) ; remove the extra newline ;; That's the dirlist. grab it & parse it. - (let* ((dl (buffer-substring (match-beginning 2) (1- (match-end 2)))) - (dl-len (length dl)) - (ds '()) ; new dir stack - (i 0)) - (while (< i dl-len) - ;; regexp = optional whitespace, (non-whitespace), optional whitespace - (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir - (setq ds (cons (concat comint-file-name-prefix - (substring dl (match-beginning 1) - (match-end 1))) - ds)) - (setq i (match-end 0))) - (let ((ds (nreverse ds))) - (with-demoted-errors "Couldn't cd: %s" - (shell-cd (car ds)) - (setq shell-dirstack (cdr ds) - shell-last-dir (car shell-dirstack)) - (shell-dirstack-message))))) + (let* ((dls (buffer-substring-no-properties + (match-beginning 0) (1- (match-end 0)))) + (dlsl '()) + (pos 0) + (ds '())) + ;; Split the dirlist into whitespace and non-whitespace chunks. + ;; dlsl will be a reversed list of tokens. + (while (string-match "\\(\\S-+\\|\\s-+\\)" dls pos) + (push (match-string 1 dls) dlsl) + (setq pos (match-end 1))) + + ;; prepend trailing entries until they form an existing directory, + ;; whitespace and all. discard the next whitespace and repeat. + (while dlsl + (let ((newelt "") + tem1 tem2) + (while newelt + ;; We need tem1 because we don't want to prepend + ;; comint-file-name-prefix repeatedly into newelt via tem2. + (setq tem1 (pop dlsl) + tem2 (concat comint-file-name-prefix tem1 newelt)) + (cond ((file-directory-p tem2) + (push tem2 ds) + (when (string= " " (car dlsl)) + (pop dlsl)) + (setq newelt nil)) + (t + (setq newelt (concat tem1 newelt))))))) + + (with-demoted-errors "Couldn't cd: %s" + (shell-cd (car ds)) + (setq shell-dirstack (cdr ds) + shell-last-dir (car shell-dirstack)) + (shell-dirstack-message)))) (if started-at-pmark (goto-char (marker-position pmark))))) ;; For your typing convenience: -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 19 10:01:07 2020 Received: (at 23324) by debbugs.gnu.org; 19 Aug 2020 14:01:07 +0000 Received: from localhost ([127.0.0.1]:40572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k8OeJ-0007wM-6D for submit@debbugs.gnu.org; Wed, 19 Aug 2020 10:01:07 -0400 Received: from quimby.gnus.org ([95.216.78.240]:45672) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k8OeG-0007oo-W7; Wed, 19 Aug 2020 10:01:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=wsfcavqKLkYWp3DedYTRH0zISDrnF9AW/vjn9iE+knw=; b=EBS625F0mMy+uwAHxsW6ed7ewu yYlkCO8DxkFiHsQq3ESIYD4dhV2APVxrKJnYrDQUslLIaY/JfDJ7F3072ujc5167e2Zo+2vqbHRh8 xhbJCRF4m+rjtzfFQmRkForiBjiG+FPT08h8IASmZGhuKTJ7V6LOBn1rUkzj8/XgEPos=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k8Oe7-0005Rw-2i; Wed, 19 Aug 2020 16:00:57 +0200 From: Lars Ingebrigtsen To: Noam Postavsky Subject: Re: bug#23324: shell-resync-dirs does not handle dirs with whitespace References: <20160420193843.651480.FMU1050@unexploded-cow.prv.splode.com> <8736uqik4l.fsf@gmail.com> <87eeocnl58.fsf@gnus.org> X-Now-Playing: Pieter Nooten & Michael Brook's _Sleeps With The Fishes_: "Finally II" Date: Wed, 19 Aug 2020 16:00:54 +0200 In-Reply-To: <87eeocnl58.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 12 Aug 2020 13:44:51 +0200") Message-ID: <87o8n620rt.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lars Ingebrigtsen writes: > I've respun the patch so that it actually works (tem1 was mis-spelled in > one place, and there was a bunch of unrelated white space fix-ups that > I've remove), but haven't done anything else to it [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 23324 Cc: 23324@debbugs.gnu.org, Noah Friedman , 11608@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > I've respun the patch so that it actually works (tem1 was mis-spelled in > one place, and there was a bunch of unrelated white space fix-ups that > I've remove), but haven't done anything else to it. > > Noam, I tried your test case, but I couldn't get it to infloop. Is > there some additional steps needed to make it infloop? There wasn't any response in a week, so I went ahead and applied the patch to Emacs 28. If this leads to problems, please revert (or fix :-/) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 19 10:01:16 2020 Received: (at control) by debbugs.gnu.org; 19 Aug 2020 14:01:16 +0000 Received: from localhost ([127.0.0.1]:40577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k8OeS-00085c-G6 for submit@debbugs.gnu.org; Wed, 19 Aug 2020 10:01:16 -0400 Received: from quimby.gnus.org ([95.216.78.240]:45688) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k8OeP-0007x0-71 for control@debbugs.gnu.org; Wed, 19 Aug 2020 10:01:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tf+AitrA493OHDSwqNidCYTfIWZxcdl/O0KUziUXAXE=; b=qaoz4MvLymzKk7/kEKBgU4wgLq CMh48ctbEBVZJa+GXHUi6YzILMuITJxtyQ1TruP3gBRd7/if2mdwmOgM6M0jmix4vQwHK+h1nk5Tc 6DmOieverQA2rN9cNeJiP44Oc8pScmdYd21Ra1E8meno2f506qFrv+krHr8NkbpEOue4=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k8OeD-0005S3-HE for control@debbugs.gnu.org; Wed, 19 Aug 2020 16:01:07 +0200 Date: Wed, 19 Aug 2020 16:01:00 +0200 Message-Id: <87mu2q20rn.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #11608 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 11608 fixed close 11608 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 11608 fixed close 11608 28.1 quit From unknown Fri Jun 20 07:14:55 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 17 Sep 2020 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator