From: dumser AT ti DOT com (James Dumser) Subject: Re: `find' command broken. 14 Jul 1997 12:48:24 -0700 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: Reply-To: James Dumser Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Mailer: BeyondMail for Windows/Professional 2.3 Original-To: GNU-Win32 AT cygnus DOT com X-BeyondMail-Priority: 1 Conversation-ID: <33C76150 DOT A2F58F7F AT prairienet DOT org> In-Reply-To: <33C76150.A2F58F7F@prairienet.org> X-Receipt-From-Agent: true Original-Sender: owner-gnu-win32 AT cygnus DOT com $Bill Luebkert wrote: > command.com works (does a globbed find) if I leave the quotes off, > tcsh and bash work if I put the quotes on, which is what you would > expect, except for the gotcha. It only works if there > are no files matching the glob in the current dir (the one you're > sitting in, not the effective starting dir). Strange problem! Cygwin knows if programs are executed by bash (or possibly some other cygwin-compiled program) or not. If not, the startup code will glob the arguments. CMD/COMMAND.COM does no globbing whatsoever. tcsh and zsh apparently glob -- but they are not cygwin-compiled programs. For what you want, find needs to see argv[] = {"find", ".", "-name", "*.c", "-print"} For CMD, you can type exactly that (find . -name *.c -print) if there are only 1 or fewer *.c files in the current directory; if there are more, when cygwin globs for you, you'll get something like {"find", ".", "-name", "file1.c", "file2.c", "-print"} If there is exactly 1 *.c file in the current directory, globbing will leave the command syntactically correct (e.g., find . -name file1.c -print); but this is still not what you want. If you have a globbing, non-cygwin-compiled shell (tcsh, zsh, etc.), the command line will get globbed *TWICE* (once by the shell, once by cygwin). Say you type find . -name '*.c' -print zsh (for example) will expand that to argv[] = {"find", ".", "-name", "*.c", "-print"} ('*.c' wasn't "globbed" exactly, but the single quotes were removed) -- so far, you're still okay. When the startup code for find sees that it wasn't spawned by a cygwin-compiled program, it assumes it has to do it. Because *.c is no longer quoted, cygwin will try to glob it. At this point, you in the same situation as with CMD above. For things to work correctly with zsh, you'd have to start with find . -name '\'*.c\'' -print V which zsh would expand to find . -name '*.c' -print V which cygwin would expand to find . -name *.c -print which is what we want find to see So what's the solution? I can think of several: - don't use non-cygwin, globbing shells - use non-cygwin utilities - be very meticulous when you mix non-cygwin shells and cygwin programs - port your non-cygwin, globbing shell to cygwin (which should be easier now with Sergery's latest cygwin.dll) -- James Dumser 972.462.5335 dumser AT ti DOT com - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".