FAQ
# New Ticket Created by Achim Gratz
# Please include the string: [perl #126834]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=126834 >



The test for the cygdrive prefix can be simplified by using the cygpath
executable instead of parsing the output from df or mount. An
alternative for modern Cygwin would be to use

my $prefix2 = readlink "/proc/cygdrive"

if a fork and some parsing should be avoided and supporting older Cygwin
versions is not considered important.

Search Discussions

  • Tony Cook via RT at Dec 6, 2015 at 10:27 pm

    On Sun Dec 06 09:57:49 2015, stromeko@nexgo.de wrote:

    The test for the cygdrive prefix can be simplified by using the cygpath
    executable instead of parsing the output from df or mount. An
    alternative for modern Cygwin would be to use

    my $prefix2 = readlink "/proc/cygdrive"

    if a fork and some parsing should be avoided and supporting older Cygwin
    versions is not considered important.
    The change looks sane, though I'm not sure why you renamed $prefix.

    Can you supply this patch as a "git format-patch" style patch?

    Tony

    ---
    via perlbug: queue: perl5 status: new
    https://rt.perl.org/Ticket/Display.html?id=126834
  • Achim Gratz at Dec 7, 2015 at 7:06 am

    Tony Cook via RT writes:
    The change looks sane, though I'm not sure why you renamed $prefix.
    Just for symmetry reasons, but I have no problem with keeping it named
    just $prefix.
    Can you supply this patch as a "git format-patch" style patch?
    Can do.


    Regards,
    Achim.
    --
    +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

    Samples for the Waldorf Blofeld:
    http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra
  • Achim Gratz at Dec 7, 2015 at 6:48 pm

    Tony Cook via RT writes:
    Can you supply this patch as a "git format-patch" style patch?
    Attached.
  • Ivan Pozdeev at Dec 7, 2015 at 7:59 pm
    `cygpath C:\' isn't completely fool-proof as C:\ might be mounted independently.
    (you decide if it's fool-proof enough for the case at hand)

    `readlink /proc/cygdrive' does look like the best solution.

    So, the best way I see is to use it and fall back to the heuristics if it's
    missing.

    "Shelling out" can't be avoided unless you wish to check the registry by hand:
    initially (in 2000), there was no dedicated utility to read the prefix at all,
    the docs pointed directly to the registry
    (http://web.archive.org/web/20001213205800/http://www.cygwin.com/cygwin-ug-net/using.html;
    http://web.archive.org/web/20001213195700/http://www.cygwin.com/cygwin-ug-net/using-utils.html#MOUNT).

    I'll now check the Cygwin repo for /proc/cygdrive addition time vs. registry
    setting elimination time to see if one can avoid the heuristics entirely and
    skip from the former directly to the latter.

    --
    Best regards,
      Ivan mailto:vano@mail.mipt.ru
  • Achim Gratz at Dec 7, 2015 at 8:36 pm

    Ivan Pozdeev via perl5-porters writes:
    `cygpath C:\' isn't completely fool-proof as C:\ might be mounted independently.
    (you decide if it's fool-proof enough for the case at hand)
    In which case the former code would fail just the same. If you wanted,
    you could loop through all 26 drive letters and see which prefix comes
    up the most often and pick that as the cygdrive prefix, but it could
    still fail in some contrived situations.
    `readlink /proc/cygdrive' does look like the best solution.

    So, the best way I see is to use it and fall back to the heuristics if it's
    missing.
    Well, I can get behind that idea; thanks for mentioning. How about the
    attached?
  • Achim Gratz at Dec 7, 2015 at 8:44 pm

    Achim Gratz writes:
    Well, I can get behind that idea; thanks for mentioning. How about the
    attached?
    Sorry, the patch still had a change in I made to test the fallback…
    Here's the correct one.
  • Tony Cook via RT at Dec 9, 2015 at 4:29 am

    On Mon Dec 07 12:44:47 2015, stromeko@nexgo.de wrote:
    Achim Gratz writes:
    Well, I can get behind that idea; thanks for mentioning. How about the
    attached?
    Sorry, the patch still had a change in I made to test the fallback…
    Here's the correct one.
    This patch doesn't seem to be against blead perl.

    Tony




    ---
    via perlbug: queue: perl5 status: open
    https://rt.perl.org/Ticket/Display.html?id=126834

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedDec 6, '15 at 5:58p
activeDec 9, '15 at 4:29a
posts8
users3
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase