Subject: bug#15417: (compile "cd /u*r && ... cd: No such directory found via CDPATH environment variable

From: Kevin Rodgers <[email-masked]>
Date: Wed, 2 Oct 2013 07:41:04 -0600

> > Seems like after extracting the <blabla> arg and substituting the values
> > of any referenced environment variables (already implemented by the
> > current hack), you could pass the result to file-expand-wildcards.  Then
> > check that there is only a single directory in the result, and pass that
> > directory to `cd'.
>
> Indeed.  Could you take care of it?

Sure, sorry for the delay:

**** compile.el~    Fri Jan 21 18:08:13 2011
--- compile.el    Wed Oct  2 07:25:47 2013
***************
*** 1217,1223 ****
      ;; sh -c "cd ..; make"
      (cd (if (string-match "^\\s *cd\\(?:\\s +\\(\\S +?\\)\\)?\\s *[;&\n]"
command)
          (if (match-end 1)
!             (substitute-env-vars (match-string 1 command))
            "~")
            default-directory))
      (erase-buffer)
--- 1217,1229 ----
      ;; sh -c "cd ..; make"
      (cd (if (string-match "^\\s *cd\\(?:\\s +\\(\\S +?\\)\\)?\\s *[;&\n]"
command)
          (if (match-end 1)
!             (let* ((substituted-dir
!                 (substitute-env-vars (match-string 1 command)))
!                (expanded-dir
!                 (file-expand-wildcards substituted-dir)))
!               (if (= (length expanded-dir) 1)
!               (car expanded-dir)
!             substituted-dir))
            "~")
            default-directory))
      (erase-buffer)

-- 
Kevin Rodgers
Denver, Colorado

>         Stefan

On Thu, Sep 26, 2013 at 7:56 AM, Stefan Monnier <[email-masked]>wrote:

> > Seems like after extracting the <blabla> arg and substituting the values
> > of any referenced environment variables (already implemented by the
> > current hack), you could pass the result to file-expand-wildcards.  Then
> > check that there is only a single directory in the result, and pass that
> > directory to `cd'.
>
> Indeed.  Could you take care of it?
>
>
>         Stefan
>