X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Eric Blake Subject: Re: problem with globs using curly brackets and ^ Date: Thu, 19 Apr 2007 14:30:08 +0000 (UTC) Lines: 72 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Jens Rasmussen diku.dk> writes: > I'm having a problem with globs using curly brackets and ^. > I've searched the web+forum with no luck, so I'm sorry if an answer > aleardy exists. I'm not sure what your problem is. You have to tell us what you were trying to accomplish, and the output you expected, rather than just telling us that what happened was wrong. Everything you listed is behaving as documented, such as in 'man bash'. > $ ls -d {Desk*,doc*} > Desktop.ini doc Bash expands this in two steps, first doing brace expansion to ls -d Desk* doc* then doing globbing to ls -d Desktop.ini doc > > BUT: (I assume that the following is because it normally makes no sense) > > $ ls -d {Desk*} Bash refuses to do brace expansion if there is no unquoted , between the {}, in which case it does not strip the {}. So bash then tries to glob "{Desk*}", and since there are no files that match that pattern and since you don't have the nullglob shopt turned on, bash then invokes ls as though by ls -d "{Desk*}" > ls: cannot access {Desk*}: No such file or directory and ls repeats the same thing that bash globbing discovered - there are no files in your current directory that match the glob pattern {Desk*}. > > AND: (my actual problem) > > $ ls ^doc > ls: cannot access ^doc: No such file or directory ^ is not a globbing character, and except on ancient shells (think Solaris /bin/sh) where it is a synonym for |, you are asking ls to find the file named "^doc" which does not exist. > > $ ls -d ^{Desk*,doc*} Bash brace expansion is invoked here, leaving: ls -d ^Desk* ^doc* followed by bash globbing (you have no files that match ^Desk* or ^doc*), so bash invokes ls as if by ls -d "^Desk*" "^doc*" > ls: cannot access ^Desk*: No such file or directory > ls: cannot access ^doc*: No such file or directory and once again, ls tells you what you did. > > - And yes, I'm a Linux/UNIX/Cygwin newb! And none of this post was cygwin-specific. -- Eric Blake volunteer cygwin bash maintainer -- 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/