Loading ...
Sorry, an error occurred while loading the content.

globpath() doesn't like paths ending with \.

Expand Messages
  • Suresh Govindachar
    Hello, Some of the directories in my windows path end with and globpath() cannot find files in these directories. I found this out by executing the
    Message 1 of 6 , Jan 30, 2004
    • 0 Attachment
      Hello,

      Some of the directories in my windows path end with \ and
      globpath() cannot find files in these directories. I found
      this out by executing the following commands. (Although the
      two commands below are written in multiple lines, they are
      actually one line commands.)

      haveit.exe is not found by the next command:

      :let foo=substitute($path, ";", ",", "g") |
      let foo=globpath(foo, "haveit.exe") | echo(foo)

      but is found by the following command:

      :let foo=substitute($path, ";", ",", "g") |
      let foo=substitute(foo, "\\\\,", ",", "g") |
      let foo=globpath(foo, "haveit.exe") | echo(foo)

      Seems odd that things are this way with globpath().

      --Suresh
    • Benji Fisher
      ... I do not know what is going on here. I cannot even guess why you are replacing ; in $path with , . Can you tell us what is the output of the following
      Message 2 of 6 , Jan 31, 2004
      • 0 Attachment
        On Fri, Jan 30, 2004 at 11:52:30PM -0800, Suresh Govindachar wrote:
        > Hello,
        >
        > Some of the directories in my windows path end with \ and
        > globpath() cannot find files in these directories. I found
        > this out by executing the following commands. (Although the
        > two commands below are written in multiple lines, they are
        > actually one line commands.)
        >
        > haveit.exe is not found by the next command:
        >
        > :let foo=substitute($path, ";", ",", "g") |
        > let foo=globpath(foo, "haveit.exe") | echo(foo)
        >
        > but is found by the following command:
        >
        > :let foo=substitute($path, ";", ",", "g") |
        > let foo=substitute(foo, "\\\\,", ",", "g") |
        > let foo=globpath(foo, "haveit.exe") | echo(foo)
        >
        > Seems odd that things are this way with globpath().
        >
        > --Suresh

        I do not know what is going on here. I cannot even guess why you
        are replacing ";" in $path with ",". Can you tell us what is the output
        of the following :echo commands?

        echo $path
        let foo=substitute($path, ";", ",", "g")
        echo foo
        echo globpath(foo, "haveit.exe")
        let foo=substitute(foo, "\\\\,", ",", "g")
        echo globpath(foo, "haveit.exe")

        --Benji Fisher
      • Suresh Govindachar
        ... Here are the details: The following command (written in multiple lines but issued ... let foo=substitute($path, ; , , , g ) | echo(foo) | let
        Message 3 of 6 , Jan 31, 2004
        • 0 Attachment
          On Saturday, January 31, 2004 4:23 AM Benji Fisher wrote:
          >On Fri, Jan 30, 2004 at 11:52:30PM -0800, Suresh Govindachar wrote:
          >> Hello,
          >>
          >> Some of the directories in my windows path end with \ and
          >> globpath() cannot find files in these directories. I found
          >> this out by executing the following commands. (Although the
          >> two commands below are written in multiple lines, they are
          >> actually one line commands.)
          >>
          >> haveit.exe is not found by the next command:
          >>
          >> :let foo=substitute($path, ";", ",", "g") |
          >> let foo=globpath(foo, "haveit.exe") | echo(foo)
          >>
          >> but is found by the following command:
          >>
          >> :let foo=substitute($path, ";", ",", "g") |
          >> let foo=substitute(foo, "\\\\,", ",", "g") |
          >> let foo=globpath(foo, "haveit.exe") | echo(foo)
          >>
          >> Seems odd that things are this way with globpath().
          >>
          >> --Suresh
          >
          > I do not know what is going on here. I cannot even guess why you
          >are replacing ";" in $path with ",". Can you tell us what is the output
          >of the following :echo commands?
          >
          >echo $path
          >let foo=substitute($path, ";", ",", "g")
          >echo foo
          >echo globpath(foo, "haveit.exe")
          >let foo=substitute(foo, "\\\\,", ",", "g")
          >echo globpath(foo, "haveit.exe")
          >

          Here are the details:

          The following command (written in multiple lines but issued
          as a single line):

          :echo $path |
          let foo=substitute($path, ";", ",", "g") | echo(foo) |
          let foo=substitute(foo, "\\\\,", ",", "g") | echo(foo) |
          let foo=globpath(foo, "perl.exe") | echo(foo)

          resulted in the following 5 long-lines of output (wrapped by
          the mailer -- "microsoft office" is the only directory with space):
          ----------------------------------------------
          C:\opt\Microsoft
          Office\Office;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\OPT\PERL\BIN\;D:\OPT\TEXMF\MIKT
          EX\BIN;C:\OPT\MSYS\1.0\BIN;C:\OPT\UTILS
          C:\opt\Microsoft
          Office\Office,C:\WINDOWS,C:\WINDOWS\COMMAND,C:\OPT\PERL\BIN\,D:\OPT\TEXMF\MIKT
          EX\BIN,C:\OPT\MSYS\1.0\BIN,C:\OPT\UTILS
          C:\opt\Microsoft
          Office\Office,C:\WINDOWS,C:\WINDOWS\COMMAND,C:\OPT\PERL\BIN,D:\OPT\TEXMF\MIKTE
          X\BIN,C:\OPT\MSYS\1.0\BIN,C:\OPT\UTILS
          C:\OPT\PERL\BIN\perl.exe
          Hit ENTER or type command to continue
          ----------------------------------------------
          Doing nothing to path or only getting rid of the
          trailing "\" but not the ";" did not help; meaning both
          of the following failed:

          :let foo=globpath($path, "perl.exe") | echo(foo)

          :let foo=substitute($path, "\\\\,", ",", "g") |
          let foo=globpath(foo, "perl.exe") | echo(foo)

          --Suresh
        • Suresh Govindachar
          Here s a simpler example of globpath() not liking terminating back-slash: set rtp to various values and test with globpath. So doing this set ... followed by
          Message 4 of 6 , Jan 31, 2004
          • 0 Attachment
            Here's a simpler example of globpath() not liking
            terminating back-slash: set rtp to various values
            and test with globpath.

            So doing this set
            :set rtp=C:\opt\vim\vimfiles,C:\opt\vim\vim62
            followed by
            :echo globpath(&rtp, "syntax/c.vim")
            gives the expected result of
            C:\opt\vim\vimfiles\syntax\c.vim
            C:\opt\vim\vim62\syntax\c.vim

            The next two sets give the expected result.

            set rtp=C:\opt\vim\vimfiles,C:\opt\vim\vim62\
            set rtp=C:\opt\vim\vimfiles/,C:\opt\vim\vim62\

            But each of the following 4 sets fail to give the expected result.

            set rtp=C:\opt\vim\vimfiles\,C:\opt\vim\vim62\
            set rtp=C:\opt\vim\vimfiles\\,C:\opt\vim\vim62\
            set rtp=C:\opt\vim\vimfiles\\\,C:\opt\vim\vim62\
            set rtp=C:\opt\vim\vimfiles\\\\,C:\opt\vim\vim62\

            --Suresh
          • Jonathan D Johnston
            On Fri, 30 Jan 2004 23:52:30 -0800, ... Hi Suresh, The backslash ( ) is escaping the following comma (,). For example, if I create two directories I: x test
            Message 5 of 6 , Feb 1, 2004
            • 0 Attachment
              On Fri, 30 Jan 2004 23:52:30 -0800,
              "Suresh Govindachar" <sgovindachar@...> wrote:
              > Hello,
              >
              > Some of the directories in my windows path end with \ and
              > globpath() cannot find files in these directories. I found
              > this out by executing the following commands. (Although the
              > two commands below are written in multiple lines, they are
              > actually one line commands.)
              >
              > haveit.exe is not found by the next command:
              >
              > :let foo=substitute($path, ";", ",", "g") |
              > let foo=globpath(foo, "haveit.exe") | echo(foo)
              >
              > but is found by the following command:
              >
              > :let foo=substitute($path, ";", ",", "g") |
              > let foo=substitute(foo, "\\\\,", ",", "g") |
              > let foo=globpath(foo, "haveit.exe") | echo(foo)
              >
              > Seems odd that things are this way with globpath().
              >
              > --Suresh

              Hi Suresh,

              The backslash (\) is escaping the following comma (,).

              For example, if I create two directories "I:\x\test" & "I:\x\this,that"
              & drop a "nonesuch" file in each:

              :echo globpath('I:/x/test,I:/x/this\,that','nonesuch')

              displays:

              I:\x\test\nonesuch
              I:\x\this,that\nonesuch

              To do that (rather pathological :-) test, I needed to be able to give
              globpath() the directory "I:\x\this,that" without it being interpreted
              as "I:\x\this" & "that". Backslash is used, as usual, to escape the
              separator meaning of the comma. So, for me, the behavior of globpath()
              is very reasonable.

              Shame on M$ for picking \ as the separator in filename paths.
              Fortunately, Vim can use / on DOS & Windows. For your original example,
              I would s/;/,/g and s#\\#/#g .

              HTH,
              Jonathan D Johnston

              ________________________________________________________________
              The best thing to hit the Internet in years - Juno SpeedBand!
              Surf the Web up to FIVE TIMES FASTER!
              Only $14.95/ month - visit www.juno.com to sign up today!
            • Bram Moolenaar
              ... [...] ... Note that you have , in there. This is used to include a comma in a directory name, thus Vim sees C: OPT PERL BIN,D: OPT TEXMF MIKT as the
              Message 6 of 6 , Feb 1, 2004
              • 0 Attachment
                Suresh Govindachar wrote:

                > >> Some of the directories in my windows path end with \ and
                > >> globpath() cannot find files in these directories. I found
                > >> this out by executing the following commands. (Although the
                > >> two commands below are written in multiple lines, they are
                > >> actually one line commands.)

                [...]

                > Here are the details:
                >
                > The following command (written in multiple lines but issued
                > as a single line):
                >
                > :echo $path |
                > let foo=substitute($path, ";", ",", "g") | echo(foo) |
                > let foo=substitute(foo, "\\\\,", ",", "g") | echo(foo) |
                > let foo=globpath(foo, "perl.exe") | echo(foo)
                >
                > resulted in the following 5 long-lines of output (wrapped by
                > the mailer -- "microsoft office" is the only directory with space):
                > ----------------------------------------------
                > C:\opt\Microsoft
                > Office\Office;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\OPT\PERL\BIN\;D:\OPT\TEXMF\MIKT
                > EX\BIN;C:\OPT\MSYS\1.0\BIN;C:\OPT\UTILS
                > C:\opt\Microsoft
                > Office\Office,C:\WINDOWS,C:\WINDOWS\COMMAND,C:\OPT\PERL\BIN\,D:\OPT\TEXMF\MIKT

                Note that you have "\," in there. This is used to include a comma in a
                directory name, thus Vim sees "C:\OPT\PERL\BIN,D:\OPT\TEXMF\MIKT" as the
                directory to search in.

                --
                Often you're less important than your furniture. If you think about it, you
                can get fired but your furniture stays behind, gainfully employed at the
                company that didn't need _you_ anymore.
                (Scott Adams - The Dilbert principle)

                /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
                \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
              Your message has been successfully submitted and would be delivered to recipients shortly.