Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-Id: <5.1.0.14.2.20020311093954.00abb770@pop3.cris.com> X-Sender: rrschulz AT pop3 DOT cris DOT com X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Mon, 11 Mar 2002 09:54:46 -0800 To: Lynn Wilson , cygwin AT cygwin DOT com From: Randall R Schulz Subject: Re: bash expansion question In-Reply-To: <3C8CE652.2050208@swcp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Lynn, [ This is almost entirely a non-Cygwin issue. ] You have the option of telling BASH to treat a glob pattern such as *.pl that matches no files to yield an empty string ("shopt -s nullglob") or the pattern itself ("shopt -u nullglob"). The default, as you now know, is to have "nullglob" unset (disabled). I believe csh / tcsh has an option to treat non-matching glob patterns as an error, but I see nothing in the BASH documentation suggesting that's a possibility for that shell. If you put a glob pattern within either hard (single) or soft (double) quotes, you will inhibit any interpretation / expansion / special treatment of the pattern. The primary difference between hard and soft quotes is in the expansion of variables, $( ... ) or ` ... ` command substitutions occurs within double quotes but not within single quotes. As long as you're not mixing Windows and Cygwin commands or crossing between Windows and Cygwin boundaries, the expansion of shell glob patterns always happens in the invoking shell, not in the command that is invoked. That's true regardless of whether the command invoked is a binary or a shell script. Thus, the choice of which (if any) quote marks are used within the invoked script is irrelevant to the globbing. However, if the result of the glob expansion is a file name with special characters or spaces in it, then the choice of quoting style, if any, will matter, since the expanded file name is just another string to the invoked script. If you use CMD.exe to invoke a Cygwin program, then the glob expansion happens within the invoked command. See the Cygwin user docs and FAQ for details. Good luck. Randall Schulz Mountain View, CA USA At 09:16 2002-03-11, Lynn Wilson wrote: >The man page for bash says: Enclosing characters in single quotes >preserves the lit- eral value of each character within the >quotes. A single quote may not occur between single quotes, even when >pre- ceded by a backslash. > >If I write the following bash script( test.bash ): >#!/usr/bin/bash >echo Argument is $1 > >If I execute this script in a directory that does NOT constain any perl >(*.pl) files: > >test.bash '*.pl' >I get as expected: Argument is *.pl > >However if there IS a perl file present I get: >Argument is filename.pl > >BTW, I get exactly the same behavior if I use double quotes. Am I missing >something here? I need to pass a literal pattern that may contain >wildcard characters into a bash script and not have the shell expandit. > >Thanks. >Lynn -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/