On Tue, 2005-08-16 at 17:10 -0400, Igor Pechtchanski wrote: Igor, please: Regardless of how my Reply-To is set, I prefer to have replies on the list only. I consider this to be the standard reply procedure on lists. (i.e. leaving the option to actually have the reply end up in a mailbox as an actually WORKING OPTION)
> On Tue, 16 Aug 2005, Hannu E K Nevalainen wrote: > > > On Mon, 2005-08-15 at 21:43 -0400, Igor Pechtchanski wrote: > > > On Wed, 10 Aug 2005, Christopher Faylor wrote: > > > > > > > On Wed, Aug 10, 2005 at 11:23:00AM -0700, Linda W wrote: > > > > >Is there a way to find out in a bash script the cygdrive prefix? > > > > >I thought something simple like > > > > > mount -p|tail -1|cut -f1 > > > > >but that incorrectly assumed the fields were tab delimited. > > > > >Since there can be spaces in the cygdrive prefix, I can't > > > > >use space a delimiter, example: > > > > ># mount -p > > > > >Prefix Type Flags > > > > >/cyg drive posix path system binmode > > > > >---- > > > > > > > > There may be a simpler way to do it, but this seems to work: > > > > > > > > mount -p | sed -n '2s/\([^ ]\) *[^ ][^ ]* *[^ ][^ ]*$/\1/p' > > > > > > The main question is: *why* would one want to programmatically find out > > > the cygdrive prefix? > > Hi, Hannu... Hi Igor, "I'm back" (Add the strong voice of mr Schwarzenegger(sp?)) ;-] (Actually I've been reading almost all of the time) > > You're making assumptions without insight, Igor. Please, don't assume! > > Be open minded and allow to extract the information in an easily > > accessible manner - PLEASE. > > Huh? I wasn't making any assumptions, I was asking for the actual problem > that programmatically accessing the cygdrive prefix was supposed to solve. > Knowing the intended usage would make it easier to write a custom > accessor, as opposed to something generic. Ah, sorry - I got the impression that you were questioning the sanity behind the reason of this whole thread. Hmmm, "custom accessor" - does that imply a change to mount or possibly cygpath? IMO this is necessary, trying to do this with scripting is slow and error prone, simply because the variable nature of the cygdrive prefix setting; user preferences varies a lot (along with ignorance ;-). > > In general, having a setting be "hidden" in the manner that the cygdrive > > prefix is - is a bad idea. Simply because you never know what other ppl > > might come up with, if it IS accessible. > > > > Allowing RE-Reading the value of a parameter, that can be set, should > > IMO never be restricted, unless maybe the restricting is based on > > security... (passwords comes to mind) > > > > Check my local example "cygdrive" use below. Not perfect, but works - as > > it is - in my very static cygwin setup (e.g. has problems w spaces under > > certain conditions, a condition NOT present on my computers; I'm rabid > > on this) > > The whole idea was to address cygdrive prefixes that may have spaces. Ooops, it was? =-) 'Programatically finding value of "cygdrive" prefix' indicates a need for sensibly handling DOS drives in cygwin scripting to me. > > > If all you want is access '/cygdrive/c' via a POSIX path, wouldn't > > > "cygpath -u c:" do the right thing? In fact, barring special mounts, > > > "cygpath -u c:|sed 's#/c$##'" should do what the OP asked. > > > > Are you sure there is a C: drive on every Windows computer, I wouldn't > > wager on that. > > There may not be a C: drive, but "cygpath -u c:" will do the right thing > -- try it with a drive you don't have. Yet another oddity of cygwin tools obviously. > > > Alternatively, one could actually use the quotes that "mount -m" > > > produces, via something like > > > > > > mount -m | grep -- --change-cygdrive-prefix | \ > > > xargs bash -c 'while [ $# != 1 ]; do shift; done; echo "$@"' -- > > > > IMO, something like > > $ mount -m | grep 'cygdrive-prefix' | sed -rne 's/.*"(.*)".*/\1/p' > > > > should work ; UNTESTED (I'm on Linux right now) > > This won't always work. The cygdrive prefix may not be the only thing in > quotes. Yet another reason to add an easy way to retrive the cygdrive prefix, regardless of its contents. > > ---8<--- example use --- > > [snip] > > [EMAIL PROTECTED] scripts]$ cat cygdrives > > #!/bin/bash > > # show paths to all mounted DOS/WINDOWS devices. > > mount | grep -E "$(cygprefix)[a-z] " | cut -d" " -f3 > > Hmm, why not simply 'echo "$(cygprefix)[a-z]"'? Hmm? Does that expand to the AVAILABLE, currently MOUNTED drives? > > [EMAIL PROTECTED] scripts]$ cat cygprefix > > #!/bin/bash > > # grep out the cygwin prefix for DOS/WINDOWS devices > > > > mount -p | > > tail -1 | > > ( > > read p z; > > if [ ! "${p: -1}" == "/" ] ;then > > p="$p/"; > > fi; > > echo "$p" > > ) > > Again, not space-friendly. And much longer than most scripts proposed in > this thread. > Igor And as I wrote, this is the actual in-use script that I provided as *example* on _why_, based on your statenent: >>> The main question is: *why* would one want to programmatically find >>> out the cygdrive prefix? ...additionally I explicitly stated that it was; - used in a static (i.e. nonchanging environment) and that it had - problems with space-littered stuff. I also added that I'm _rabid_ about using spaces within names on any fs, i.e. I almost yell at people who use them - and then come to me asking why they have problems. So, to sum it up - we both read what selected parts of the text ;-) and skip the rest. Now, a parallell case - just as problematic - is $ cygpath -ua / / IMO supplying "-a" should print e.g. /cygdrive/c/cygwin/fsroot/ - not just "/". As it is right now it is hard to _programmatically_[3] locate .. of / i.e. where I keep cygwin.bat and loads of other stuff related to cygwin; i.e. /cygdrive/c/cygwin/ from the example here. [2] WRT if this thread will ever die; that reminds me of Ray Petersons "Tell Laura I love Her" a beatiful little tune from the past. ;-) [1] Is this thread from the past? ;-P /Hannu E K Nevalainen [1] I spend 1.5-3 hrs/day travelling to/from work, many times listening to this kind of music. [2] Idea; keep all files related to one "thing" in _one_ folder/directory [3] [EMAIL PROTECTED] ~]$ cat cygroot #!/bin/bash # (C) 2003-11-03 by Hannu E K Nevalainen, Mariefred, Sweden # "Free" under GPL - version 2 or later at your choice p="$(mount | sed -ne 's,^\(.*\) on / .*,\1,p')" if [ ! -z "$p" ] ; then # cygpath -ua "${p:0:2}${p:3}" echo "$(cygpath -ua "${p:0:2}")/${p:3}" | tr '\\' '/' # cygpath -ua "$p" fi -- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/