delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/28/12:09:18

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
Date: Tue, 28 Jun 2005 09:09:04 -0700 (PDT)
From: Kaz Kylheku <kaz AT ashi DOT footprints DOT net>
To: Andreas Eibach <ae_cygwin1 AT web DOT de>
cc: cygwin AT cygwin DOT com
Subject: Re: LS and spaces in path names (the xth)
In-Reply-To: <1478765723@web.de>
Message-ID: <Pine.LNX.4.44.0506280904070.19500-100000@ashi.FootPrints.net>
MIME-Version: 1.0

On Tue, 28 Jun 2005, Andreas Eibach wrote:

> Needless to say that scripts containing
> 
> for i in `ls *.dat*`; do .... 

Ouch!!!

> will NOT work, because Cygwin will interpret each sub-string between the \ ' s separately, making parsing files a nuisance.

That script won't work anywhere.  Who ever writes braindamaged shell
code like that? It takes the output of a command and re-tokenizes it,
so that files with spaces will turn into multiple tokens. You want:

  for i in *.dat* ; do some-command "$i" ; done

The quotes around $i are important too. Or, to be properly paranoid,
you have to watch for "$i" expanding into something that looks like a
command option to some-command. If some-command is properly designed,
it takes the -- option to indicate ``no more options'':

  for i in *.dat* ; do some-command -- "$i" ; done

-- 
Meta-CVS: the working replacement for CVS that has been stable since
2002.  It versions the directory structure, symbolic links and execute
permissions. It figures out renaming on import. Plus it babysits the kids
and does light housekeeping! http://freshmeat.net/projects/mcvs


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