|
View:
New views
17 Messages
—
Rating Filter:
Alert me
|
|
|
1.7] Can you have multipe cygdrive path prefixes active at onceThe mount manpage says:
-p, --show-cygdrive-prefix show user and/or system cygdrive path prefix The and/or would suggest you could have different user and system cygdrive path prefixes active at once, which would potentially be a bit confusing.... Also, is there a better way to extract the prefix directly than to do some bash grepping/cutting on the readable text output of mount -p? I need to know the cygdrive prefix to make my scripts that call Windoze executables work independent of what it might be set to. |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceIn particular, I can't use "mount -p" to distinguish between prefixes that might have (variable) number of trailing spaces (which is allowed).
|
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceaputerguy wrote:
> In particular, I can't use "mount -p" to distinguish between prefixes that > might have (variable) number of trailing spaces (which is allowed). I believe that you want to use the cygpath program if you want to convert POSIX paths to Windows paths reliably. Assuming the default cygdrive prefix is in use: $ cygpath -w /cygdrive/c/an/example/posix/path C:\an\example\posix\path I'm at a Linux system right now, so I typed that from what I remember. It should be pretty close though. -Jeremy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceJeremy Bopp wrote:
>aputerguy wrote: >> In particular, I can't use "mount -p" to distinguish between prefixes that >> might have (variable) number of trailing spaces (which is allowed). > > I believe that you want to use the cygpath program if you want to > convert POSIX paths to Windows paths reliably. Assuming the default > cygdrive prefix is in use: > > $ cygpath -w /cygdrive/c/an/example/posix/path > C:\an\example\posix\path All true and known. BUT I want to know the cygdrive prefix in general for use in future constructions rather than just making a single path. Say if I want to find all files, I want to do something like "find <cygdrive-prefix> |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceOn Nov 5 22:53, aputerguy wrote:
> > The mount manpage says: > -p, --show-cygdrive-prefix > show user and/or system cygdrive path prefix > > The and/or would suggest you could have different user and system cygdrive > path prefixes active at once, which would potentially be a bit confusing.... Wrong assumption. There's only one valid cygdrive prefix at any given time within the same user session. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceaputerguy wrote:
> Jeremy Bopp wrote: >> aputerguy wrote: >>> In particular, I can't use "mount -p" to distinguish between prefixes >>> that >>> might have (variable) number of trailing spaces (which is allowed). >> I believe that you want to use the cygpath program if you want to >> convert POSIX paths to Windows paths reliably. Assuming the default >> cygdrive prefix is in use: >> >> $ cygpath -w /cygdrive/c/an/example/posix/path >> C:\an\example\posix\path > > All true and known. BUT I want to know the cygdrive prefix in general for > use in future constructions rather than just making a single path. Say if I > want to find all files, I want to do something like "find <cygdrive-prefix> Well, it's a bit of a hack, but you could try something like the following: $ dirname $(cygpath -u C:/) This assumes that there is always a C: drive and converts the path to the root of that drive into a POSIX path which will include the cygdrive prefix. Then dirname is used to effectively chop off the drive letter leaving you with the cygdrive prefix. If you're thinking that you can run something like ls or find the cygdrive prefix and enumerate all of the drives on the system, you should know that it won't work in some cases, such as when someone sets their cygdrive prefix to "/". In this case, the drives are still available explicitly as /c, /d, etc. but they will not be enumerated by "ls /" or "find /". -Jeremy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
RE: 1.7] Can you have multipe cygdrive path prefixes active at onceJeremy Bopp wrote on Friday, November 06, 2009 3:31 PM:
> Well, it's a bit of a hack, but you could try something like the following: > > $ dirname $(cygpath -u C:/) > > This assumes that there is always a C: drive and converts the path to > the root of that drive into a POSIX path which will include the cygdrive > prefix. Then dirname is used to effectively chop off the drive letter > leaving you with the cygdrive prefix. Actually: $ ls /cygdrive c e f h j p t z $ cygpath -u x:/ /cygdrive/x Seems like you aren't assuming the drive exists :) -- Bryan Thrall FlightSafety International bryan.thrall@... -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceThrall, Bryan wrote:
> Jeremy Bopp wrote on Friday, November 06, 2009 3:31 PM: >> Well, it's a bit of a hack, but you could try something like the > following: >> $ dirname $(cygpath -u C:/) >> >> This assumes that there is always a C: drive and converts the path to >> the root of that drive into a POSIX path which will include the > cygdrive >> prefix. Then dirname is used to effectively chop off the drive letter >> leaving you with the cygdrive prefix. > > Actually: > > $ ls /cygdrive > c e f h j p t z > $ cygpath -u x:/ > /cygdrive/x > > Seems like you aren't assuming the drive exists :) That's pretty sweet, but that feature seems to be fairly fortuitous rather than by design. Maybe someone could speak on this point with more authority. -Jeremy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceOn 11/06/2009 05:35 PM, Jeremy Bopp wrote:
> Thrall, Bryan wrote: >> Jeremy Bopp wrote on Friday, November 06, 2009 3:31 PM: >>> Well, it's a bit of a hack, but you could try something like the >> following: >>> $ dirname $(cygpath -u C:/) >>> >>> This assumes that there is always a C: drive and converts the path to >>> the root of that drive into a POSIX path which will include the >> cygdrive >>> prefix. Then dirname is used to effectively chop off the drive letter >>> leaving you with the cygdrive prefix. >> >> Actually: >> >> $ ls /cygdrive >> c e f h j p t z >> $ cygpath -u x:/ >> /cygdrive/x >> >> Seems like you aren't assuming the drive exists :) > > That's pretty sweet, but that feature seems to be fairly fortuitous > rather than by design. Maybe someone could speak on this point with > more authority. If you need to know what the cygdrive prefix is, you're much better off asking 'mount' directly. I know it's a little more parsing but getting it directly rather than trying back doors is far more reliable. -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 216 Dalton Rd. (508) 893-9889 - FAX Holliston, MA 01746 _____________________________________________________________________ A: Yes. > Q: Are you sure? >> A: Because it reverses the logical flow of conversation. >>> Q: Why is top posting annoying in email? -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceLarry Hall (Cygwin) wrote:
> On 11/06/2009 05:35 PM, Jeremy Bopp wrote: >> Thrall, Bryan wrote: >>> Jeremy Bopp wrote on Friday, November 06, 2009 3:31 PM: >>>> Well, it's a bit of a hack, but you could try something like the >>> following: >>>> $ dirname $(cygpath -u C:/) >>>> >>>> This assumes that there is always a C: drive and converts the path to >>>> the root of that drive into a POSIX path which will include the >>> cygdrive >>>> prefix. Then dirname is used to effectively chop off the drive letter >>>> leaving you with the cygdrive prefix. >>> >>> Actually: >>> >>> $ ls /cygdrive >>> c e f h j p t z >>> $ cygpath -u x:/ >>> /cygdrive/x >>> >>> Seems like you aren't assuming the drive exists :) >> >> That's pretty sweet, but that feature seems to be fairly fortuitous >> rather than by design. Maybe someone could speak on this point with >> more authority. > > If you need to know what the cygdrive prefix is, you're much better off > asking 'mount' directly. I know it's a little more parsing but getting it > directly rather than trying back doors is far more reliable. The concern posed by the instigator of this thread is that it can't be known from the output of "mount -p" whether or not the spaces which follow the listed cygdrive prefix are part of the prefix or padding for the outputted columns. It should be pretty rare that someone intentionally uses trailing spaces in their cygdrive prefix, but I can understand the desire for robustness. I suppose parsing the output of "mount -m" could yield a definitive result, but there the risk is that the output could change subtly and break simple parsing. -Jeremy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceJeremy Bopp writes: > The concern posed by the instigator of this thread is that it can't be > known from the output of "mount -p" whether or not the spaces which > follow the listed cygdrive prefix are part of the prefix or padding for > the outputted columns. It should be pretty rare that someone > intentionally uses trailing spaces in their cygdrive prefix, but I can > understand the desire for robustness. Yes - that was precisely my point. I am updating scripts that are used on an open source project so I want them to be robust. If it were just for my own use, I wouldn't even need to use "mount -p" since I know what *my* cygdrive prefix is. But if you are writing general scripts, I think it is pretty reasonable and basic to have a clear, easy, and robust way to know what the root of the system is. As an analogy, imagine if in Linux root were not always "/" and that there were no good way to robustly determine what your particular value of root was -- certainly that would break (or at least potentially break) many scripts. |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceJeremy Bopp writes:
> Well, it's a bit of a hack, but you could try something like the following: > > $ dirname $(cygpath -u C:/) > This assumes that there is always a C: drive and converts the path to > the root of that drive into a POSIX path which will include the cygdrive > prefix. Then dirname is used to effectively chop off the drive letter > leaving you with the cygdrive prefix. This doesn't seem to work in the case where you have mounted the C: drive. For example I mount C: on /c And the above returns: $ dirname $(cygpath -u c:/) / which doesn't tell me what the cygdrive prefix is -- only where 'c' is mounted. Of course, as pointed out in a later reply, one can use an unused disk drive letter like 'x' but that is hardly robust since who knows what drive letters will be unused and/or unmounted. |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceaputerguy wrote:
> Jeremy Bopp writes: >> Well, it's a bit of a hack, but you could try something like the >> following: >> >> $ dirname $(cygpath -u C:/) > >> This assumes that there is always a C: drive and converts the path to >> the root of that drive into a POSIX path which will include the cygdrive >> prefix. Then dirname is used to effectively chop off the drive letter >> leaving you with the cygdrive prefix. > > This doesn't seem to work in the case where you have mounted the C: drive. > For example I mount C: on /c > > And the above returns: > $ dirname $(cygpath -u c:/) > / > which doesn't tell me what the cygdrive prefix is -- only where 'c' is > mounted. > > Of course, as pointed out in a later reply, one can use an unused disk drive > letter like 'x' but that is hardly robust since who knows what drive letters > will be unused and/or unmounted. Assuming you do find a reliable way to discover the cygdrive prefix, how do you plan to handle mapped drives for remote shares? I ask because you mentioned that you might want to be able to run something like find on the cygdrive prefix itself, and of course scanning a remote share like that may not be desirable. Also, how do you handle the mounted C: case as well? Even if you mount it to /c as you have done, I think /cygdrive/c will also have it. -Jeremy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceBopp wrote:
> aputerguy wrote: >> Jeremy Bopp writes: >>> Well, it's a bit of a hack, but you could try something like the >>> following: >>> $ dirname $(cygpath -u C:/) >>> This assumes that there is always a C: drive and converts the path to >>> the root of that drive into a POSIX path which will include the cygdrive >>> prefix. Then dirname is used to effectively chop off the drive letter >>> leaving you with the cygdrive prefix. >> This doesn't seem to work in the case where you have mounted the C: drive. >> For example I mount C: on /c >> And the above returns: >> $ dirname $(cygpath -u c:/) >> / >> which doesn't tell me what the cygdrive prefix is -- only where 'c' is >> mounted. >> Of course, as pointed out in a later reply, one can use an unused disk drive >> letter like 'x' but that is hardly robust since who knows what drive letters >> will be unused and/or unmounted. > Assuming you do find a reliable way to discover the cygdrive prefix, how > do you plan to handle mapped drives for remote shares? I ask because > you mentioned that you might want to be able to run something like find > on the cygdrive prefix itself, and of course scanning a remote share > like that may not be desirable. Also, how do you handle the mounted C: > case as well? Even if you mount it to /c as you have done, I think > /cygdrive/c will also have it. > -Jeremy Does this not do what's required (barring spaces in the "Cygdrive" alternative prefix): -- #!/bin/bash # drives_root: Show the root prefix of the Windows drives # (perhaps 'Cygdrive', if the installation default # was selected) of the current installation of Cygwin # By Lee Rothstein, 2009-11-06 11:58:53 #PName=$(basename $0) #PVersion="0.01.00.001" #PUpDate="2009-11-07" mount -p | gawk 'NR==2 { print $1 }' -- WRT embedded spaces in the drive prefix: UNIX, GNU, Linux and to a large extent Perl, et al, are powerful because they demand of users a lack of abject stupidity. If stupidity is enforced by OS conventions and style, the results cannot be good. Similar approaches to the above can be used with other mounting artifice, and could even be adapted to embedded spaces. Shares at depths of more than one directory are another story, but probably could also be dealt with. Or, perhaps I don't understand the issues? Lee -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceOn 11/06/2009 06:16 PM, Jeremy Bopp wrote:
> Larry Hall (Cygwin) wrote: >> On 11/06/2009 05:35 PM, Jeremy Bopp wrote: >>> Thrall, Bryan wrote: >>>> Jeremy Bopp wrote on Friday, November 06, 2009 3:31 PM: >>>>> Well, it's a bit of a hack, but you could try something like the >>>> following: >>>>> $ dirname $(cygpath -u C:/) >>>>> >>>>> This assumes that there is always a C: drive and converts the path to >>>>> the root of that drive into a POSIX path which will include the >>>> cygdrive >>>>> prefix. Then dirname is used to effectively chop off the drive letter >>>>> leaving you with the cygdrive prefix. >>>> >>>> Actually: >>>> >>>> $ ls /cygdrive >>>> c e f h j p t z >>>> $ cygpath -u x:/ >>>> /cygdrive/x >>>> >>>> Seems like you aren't assuming the drive exists :) >>> >>> That's pretty sweet, but that feature seems to be fairly fortuitous >>> rather than by design. Maybe someone could speak on this point with >>> more authority. >> >> If you need to know what the cygdrive prefix is, you're much better off >> asking 'mount' directly. I know it's a little more parsing but getting it >> directly rather than trying back doors is far more reliable. > > The concern posed by the instigator of this thread is that it can't be > known from the output of "mount -p" whether or not the spaces which > follow the listed cygdrive prefix are part of the prefix or padding for > the outputted columns. It should be pretty rare that someone > intentionally uses trailing spaces in their cygdrive prefix, but I can > understand the desire for robustness. > > I suppose parsing the output of "mount -m" could yield a definitive > result, but there the risk is that the output could change subtly and > break simple parsing. Yeah, that's one way. Still some parsing going on there but I agree that's better and is certainly more direct. I was going to suggest skipping all that and instead just using "mount -m >somefile; mount -c /foo; script; cp somefile /etc/fstab; mount -a" but that doesn't seem to work for me right now. Perhaps you're better off abandoning work-arounds and instead just submitting a patch to 'mount' that provides a solution that's easy to work with. -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 216 Dalton Rd. (508) 893-9889 - FAX Holliston, MA 01746 _____________________________________________________________________ A: Yes. > Q: Are you sure? >> A: Because it reverses the logical flow of conversation. >>> Q: Why is top posting annoying in email? -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceLee Rothstein wrote:
> Does this not do what's required (barring spaces in the > "Cygdrive" alternative prefix): > > mount -p | gawk 'NR==2 { print $1 }' Unfortunately, your method would fail if there were *any* spaces in the pathname. Since regardless of what you say about the lack of "abject stupidity" internal spaces are quite common in Windows (think 'Documents and Settings', 'My Documents', 'Program Files', etc.) this would be a big and potentially common miss. I really think that mount should have a flag that lets you get the 'exact' cygdrive rather than trying to parse some human readable version back into a precise machine version. More generally, it seems to go against the grain of the general *nix philosophy to have a way of setting a parameter (in this case cygdrive prefix) but not having a way to reliably read back that same prefix. And regarding abject stupidity... *nix allows you to have some very weird filenames (spaces, tabs, newlines, etc.) -- but there always seems to be a reliable (though perhaps obscure) way to make sure you can recover or act on the file name. Most importantly, in no case are you left with unresolvable ambiguity. |
|
|
Re: 1.7] Can you have multipe cygdrive path prefixes active at onceI am currently using the following 'sed' one liner.
It should work except in the case where your cygdrive prefix has two or more spaces in a row followed by the word 'system' or user' followed again by 2 or more spaces. Pretty unlikely but not impossible of course... mount -p | sed -ne "s/\(.*\S\) \+\(user\|system\) \+.*/\\1/p" |
| Free embeddable forum powered by Nabble | Forum Help |