* Recursive globbing @ 2004-05-14 10:25 Vincent Lefevre 2004-05-14 10:54 ` Peter Stephenson 2004-05-16 21:34 ` parameter type differences? S. Cowles 0 siblings, 2 replies; 8+ messages in thread From: Vincent Lefevre @ 2004-05-14 10:25 UTC (permalink / raw) To: zsh-users Hi, Is there any difference between *.tex and **.tex ? If there's none, how about having improved recursive globbing, where ** not followed by a slash would mean **/* (ditto for *** -> ***/*)? -- Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> 100% validated (X)HTML - Acorn / RISC OS / ARM, free software, YP17, Championnat International des Jeux Mathématiques et Logiques, etc. Work: CR INRIA - computer arithmetic / SPACES project at LORIA ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Recursive globbing 2004-05-14 10:25 Recursive globbing Vincent Lefevre @ 2004-05-14 10:54 ` Peter Stephenson 2004-05-14 16:10 ` Bart Schaefer 2004-05-16 21:34 ` parameter type differences? S. Cowles 1 sibling, 1 reply; 8+ messages in thread From: Peter Stephenson @ 2004-05-14 10:54 UTC (permalink / raw) To: zsh-users Vincent Lefevre wrote: > Hi, > > Is there any difference between *.tex and **.tex ? No, and in fact they are documented to be the same. Hence... > If there's none, > how about having improved recursive globbing, where ** not followed > by a slash would mean **/* (ditto for *** -> ***/*)? I can't see any problem with this, unless people are habitually using double stars in the place of single stars, for example to avoid having to prune patterns. I doubt it, but are they? Index: Src/glob.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/glob.c,v retrieving revision 1.33 diff -u -r1.33 glob.c --- Src/glob.c 6 Apr 2004 17:45:47 -0000 1.33 +++ Src/glob.c 14 May 2004 10:50:20 -0000 @@ -639,14 +639,21 @@ char *str; int compflags = gf_noglobdots ? (PAT_FILE|PAT_NOGLD) : PAT_FILE; - if (instr[0] == Star && instr[1] == Star && - (instr[2] == '/' || (instr[2] == Star && instr[3] == '/'))) { + if (instr[0] == Star && instr[1] == Star) { /* Match any number of directories. */ int follow; /* with three stars, follow symbolic links */ follow = (instr[2] == Star); - instr += (3 + follow); + if (instr[2] == '/' || (instr[2] == Star && instr[3] == '/')) { + instr += (3 + follow); + } else { + /* + * Make **(|[^/\*]*) or ***(|[^/]) equivalent to + * **[/]*(...) or ***[/]*(...), respectively. + */ + instr += 1 + follow; + } /* Now get the next path component if there is one. */ l1 = (Complist) zhalloc(sizeof *l1); Index: Doc/Zsh/expn.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v retrieving revision 1.49 diff -u -r1.49 expn.yo --- Doc/Zsh/expn.yo 6 Apr 2004 09:26:50 -0000 1.49 +++ Doc/Zsh/expn.yo 14 May 2004 10:50:21 -0000 @@ -1590,9 +1590,12 @@ does a recursive directory search for files named `tt(bar)' (potentially including the file `tt(bar)' in the current directory). This form does not follow symbolic links; the alternative form `tt(***/)' does, but is -otherwise identical. Neither of these can be combined with other forms of -globbing within the same path segment; in that case, the `tt(*)' -operators revert to their usual effect. +otherwise identical. + +As a further shorthand, `tt(**)' or `tt(***)' followed by anything other +than a `tt(/)' are treated the same way as `tt(**/*)' and `tt(***/*)', +respectively. Hence `tt(**.c)' is equivalent to `tt(**/*.c)' and so to +`tt((*/)#*.c)'. subsect(Glob Qualifiers) cindex(globbing, qualifiers) cindex(qualifiers, globbing) -- Peter Stephenson <pws@csr.com> Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Recursive globbing 2004-05-14 10:54 ` Peter Stephenson @ 2004-05-14 16:10 ` Bart Schaefer 2004-05-14 16:22 ` Peter Stephenson 2004-05-17 15:06 ` Vincent Lefevre 0 siblings, 2 replies; 8+ messages in thread From: Bart Schaefer @ 2004-05-14 16:10 UTC (permalink / raw) To: Peter Stephenson; +Cc: zsh-users On Fri, 14 May 2004, Peter Stephenson wrote: > > Is there any difference between *.tex and **.tex ? > > No, and in fact they are documented to be the same. Hence... > > > how about having improved recursive globbing, where ** not followed > > by a slash would mean **/* (ditto for *** -> ***/*)? > > I can't see any problem with this No; please please don't do this. Consider: foo='x*' print ${~foo}* Or bar="$foo*" print $~bar Completely unexpected results. Also it seriously breaks sh compatibility, so at the very least it should be disabled when SH_GLOB or similar options are in effect. There's a reason that only **/ and not blather**/ is special. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Recursive globbing 2004-05-14 16:10 ` Bart Schaefer @ 2004-05-14 16:22 ` Peter Stephenson 2004-05-14 16:35 ` Peter Stephenson 2004-05-17 15:06 ` Vincent Lefevre 1 sibling, 1 reply; 8+ messages in thread From: Peter Stephenson @ 2004-05-14 16:22 UTC (permalink / raw) To: zsh-users Bart Schaefer wrote: > There's a reason that only **/ and not blather**/ is special. % print -l tmp**/*.c tmp/gtk_hello_world.c tmp/gtk_hello_world2.c tmp/hal_set_txbb_trim.c tmp/ptemtst.c tmp/rx_dynamic_lvl.c -- Peter Stephenson <pws@csr.com> Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Recursive globbing 2004-05-14 16:22 ` Peter Stephenson @ 2004-05-14 16:35 ` Peter Stephenson 0 siblings, 0 replies; 8+ messages in thread From: Peter Stephenson @ 2004-05-14 16:35 UTC (permalink / raw) Cc: zsh-users Peter Stephenson wrote: > Bart Schaefer wrote: > > There's a reason that only **/ and not blather**/ is special. > > % print -l tmp**/*.c > tmp/gtk_hello_world.c > tmp/gtk_hello_world2.c > tmp/hal_set_txbb_trim.c > tmp/ptemtst.c > tmp/rx_dynamic_lvl.c Ah, wait, I see... it's not printing tmp/subdir/*.c. That's the effect you meant. -- Peter Stephenson <pws@csr.com> Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Recursive globbing 2004-05-14 16:10 ` Bart Schaefer 2004-05-14 16:22 ` Peter Stephenson @ 2004-05-17 15:06 ` Vincent Lefevre 1 sibling, 0 replies; 8+ messages in thread From: Vincent Lefevre @ 2004-05-17 15:06 UTC (permalink / raw) To: zsh-users On 2004-05-14 09:10:13 -0700, Bart Schaefer wrote: > No; please please don't do this. Consider: > > foo='x*' > > print ${~foo}* > > Or > > bar="$foo*" > print $~bar > > Completely unexpected results. > > Also it seriously breaks sh compatibility, so at the very least it should > be disabled when SH_GLOB or similar options are in effect. > > There's a reason that only **/ and not blather**/ is special. Then there's a problem with **/ : foo='*' print ${~foo}*/ -- Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> 100% validated (X)HTML - Acorn / RISC OS / ARM, free software, YP17, Championnat International des Jeux Mathématiques et Logiques, etc. Work: CR INRIA - computer arithmetic / SPACES project at LORIA ^ permalink raw reply [flat|nested] 8+ messages in thread
* parameter type differences? 2004-05-14 10:25 Recursive globbing Vincent Lefevre 2004-05-14 10:54 ` Peter Stephenson @ 2004-05-16 21:34 ` S. Cowles 2004-05-16 22:02 ` Wayne Davison 1 sibling, 1 reply; 8+ messages in thread From: S. Cowles @ 2004-05-16 21:34 UTC (permalink / raw) To: zsh-users I have the following script, with appended output. There are 3 cases tested, comparing a reference value for parameter "bref" with 3 values of parameter "b". The utility od is used to verify the values of the "bref" and "b" parameters. My question is: why are the values of "b" not equal to "bref" in cases 1 and 2? If the issue is parameter type, is there any way to display the parameter type for "b"? Thank you. ================the script============= #!/bin/zsh emulate -R zsh bref=' ' echo "case 1." b='\012' [[ ${bref} == ${b} ]] && echo same || echo diff echo -n "${bref}" | od -b ; echo -n "${b}" | od -b echo "case 2." b='\n' [[ ${bref} == ${b} ]] && echo same || echo diff echo -n "${bref}" | od -b ; echo -n "${b}" | od -b echo "case 3." b=' ' [[ ${bref} == ${b} ]] && echo same || echo diff echo -n "${bref}" | od -b ; echo -n "${b}" | od -b exit 0 ================the output============ case 1. diff 0000000 012 0000001 0000000 012 0000001 case 2. diff 0000000 012 0000001 0000000 012 0000001 case 3. same 0000000 012 0000001 0000000 012 0000001 ================================== ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: parameter type differences? 2004-05-16 21:34 ` parameter type differences? S. Cowles @ 2004-05-16 22:02 ` Wayne Davison 0 siblings, 0 replies; 8+ messages in thread From: Wayne Davison @ 2004-05-16 22:02 UTC (permalink / raw) To: S. Cowles; +Cc: zsh-users On Sun, May 16, 2004 at 02:34:06PM -0700, S. Cowles wrote: > The utility od is used to verify the values of the "bref" and "b" > parameters. Except that you used echo to output the value of the variables, and it interprets escape sequences by default. If you change all the "echo -n" calls to "echo -nE", it will show you how the values differ. Here's the output of such a modified script: case 1. diff 0000000 012 0000001 0000000 134 060 061 062 0000004 case 2. diff 0000000 012 0000001 0000000 134 156 0000002 case 3. same 0000000 012 0000001 0000000 012 0000001 To get rid of this discrepancy, put a $ in front of the string literals you assign to $b, like this: b=$'\012' That will put a single character into $b instead of 4. ..wayne.. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-05-17 19:14 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-05-14 10:25 Recursive globbing Vincent Lefevre 2004-05-14 10:54 ` Peter Stephenson 2004-05-14 16:10 ` Bart Schaefer 2004-05-14 16:22 ` Peter Stephenson 2004-05-14 16:35 ` Peter Stephenson 2004-05-17 15:06 ` Vincent Lefevre 2004-05-16 21:34 ` parameter type differences? S. Cowles 2004-05-16 22:02 ` Wayne Davison
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).