delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/06/09/09:42:34

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <F76C9B2DA2FC4C4CA0A18E288BBCBCF708217A0D@nihexchange24.nih.gov>
From: "Buchbinder, Barry (NIH/NIAID)" <BBuchbinder AT niaid DOT nih DOT gov>
To: "'Karr, David'" <david DOT karr AT wamu DOT net>, Cygwin <cygwin AT cygwin DOT com>
Subject: RE: Strategy to process all tokens on a line through "cygpath -w" , ignoring non-path tokens
Date: Wed, 9 Jun 2004 09:41:40 -0400
MIME-Version: 1.0
X-IsSubscribed: yes

Here is a start.  "t" is the parser, "tt" tests how it works.  Depending on
exactly what you are doing, you may have to play with the quotes, or it may
be impossible to handle quotes correctly in the shell alone.

/c> cat t
#!/bin/sh
for Arg in "$@"
do
        if test -f "${Arg}" -o -d "${Arg}"
        then
                NewArgs="${NewArgs} '$(cygpath -w "${Arg}")'"
        else
                NewArgs="${NewArgs} '${Arg}'"
        fi
done
echo NewArgs="${NewArgs}"
echo no eval, no quote
tt ${NewArgs}
echo no eval, quote
tt "${NewArgs}"
echo eval, no quote
eval tt ${NewArgs}
echo eval, quote
eval tt "${NewArgs}"
/c> cat tt
#!/bin/sh
for A in "$@"
do
        echo "$A"
done | cat -n
/c> t 123 /c/cygwin/bin/ls.exe '45 67' /c/Program\
Files/Mozilla/Firefox/firefox.exe /c/Program\ Files
NewArgs= '123' 'c:\cygwin\bin\ls.exe' '45 67' 'c:\Program
Files\Mozilla\Firefox\firefox.exe' 'c:\Program Files'
no eval, no quote
     1  '123'
     2  'c:\cygwin\bin\ls.exe'
     3  '45
     4  67'
     5  'c:\Program
     6  Files\Mozilla\Firefox\firefox.exe'
     7  'c:\Program
     8  Files'
no eval, quote
     1   '123' 'c:\cygwin\bin\ls.exe' '45 67' 'c:\Program
Files\Mozilla\Firefox\firefox.exe' 'c:\Program Files'
eval, no quote
     1  123
     2  c:\cygwin\bin\ls.exe
     3  45 67
     4  c:\Program Files\Mozilla\Firefox\firefox.exe
     5  c:\Program Files
eval, quote
     1  123
     2  c:\cygwin\bin\ls.exe
     3  45 67
     4  c:\Program Files\Mozilla\Firefox\firefox.exe
     5  c:\Program Files
-----Original Message-----
From: Karr, David
Sent: Friday, June 04, 2004 11:41 AM
To: Cygwin
Subject: Strategy to process all tokens on a line through "cygpath -w",
ignoring non-path tokens

I have a situation where I have a command line that I need to preprocess
with "cygpath -w", changing all tokens which represent paths to convert
them to their windows equivalent.  All other tokens should pass through
unchanged.  Is there already a canned solution for this?  What would be
a reasonable strategy to get this done?

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019