* make "for x in *$1*" case insensitive? @ 2004-03-04 14:11 zzapper 2004-03-04 14:20 ` Peter Stephenson 0 siblings, 1 reply; 11+ messages in thread From: zzapper @ 2004-03-04 14:11 UTC (permalink / raw) To: zsh-users Hi Y'All for x in *$1* How can I make above case insensitive I guess I could transform where $1 = say main to $1 = [Mn][Aa][Ii][Nn] How would I do above or is there a better way? zzapper (vim & cygwin & zsh) -- vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: make "for x in *$1*" case insensitive? 2004-03-04 14:11 make "for x in *$1*" case insensitive? zzapper @ 2004-03-04 14:20 ` Peter Stephenson 2004-03-04 16:08 ` zzapper 0 siblings, 1 reply; 11+ messages in thread From: Peter Stephenson @ 2004-03-04 14:20 UTC (permalink / raw) To: Zsh users list zzapper wrote: > Hi Y'All > > for x in *$1* > > How can I make above case insensitive I guess I could transform Make what case insensitive? There's no test. If you have a test, you can turn on extended_glob and use the (#i) flag: setopt extended_glob [[ MAIN = (#i)main ]] && print yes Works in case statements, too, but remember the balanced parentheses: case $1 in ((#i)main) print yes ;; esac -- 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] 11+ messages in thread
* Re: make "for x in *$1*" case insensitive? 2004-03-04 14:20 ` Peter Stephenson @ 2004-03-04 16:08 ` zzapper 2004-03-04 16:46 ` Peter Stephenson 0 siblings, 1 reply; 11+ messages in thread From: zzapper @ 2004-03-04 16:08 UTC (permalink / raw) To: zsh-users On Thu, 04 Mar 2004 14:20:27 +0000, Peter Stephenson <pws@csr.com> wrote: >zzapper wrote: >> Hi Y'All >> >> for x in *$1* >> >> How can I make above case insensitive I guess I could transform > >Make what case insensitive? There's no test. If I call the following script with >vvv me It will not list a file say READ.ME but will list READ.me function vvv () { for x in *$1* do echo $x done } zzapper (vim & cygwin & zsh) -- vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: make "for x in *$1*" case insensitive? 2004-03-04 16:08 ` zzapper @ 2004-03-04 16:46 ` Peter Stephenson 2004-03-04 18:26 ` zzapper 2004-03-05 13:05 ` Michael Schaap 0 siblings, 2 replies; 11+ messages in thread From: Peter Stephenson @ 2004-03-04 16:46 UTC (permalink / raw) To: zsh-users zzapper wrote: > If I call the following script with > > >vvv me > > It will not list a file say READ.ME but will list READ.me > > function vvv () { > for x in *$1* > do > echo $x > done > } function vvv() { setopt localoptions extended_glob local x for x in (#i)*$1* do echo $x done } -- 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] 11+ messages in thread
* Re: make "for x in *$1*" case insensitive? 2004-03-04 16:46 ` Peter Stephenson @ 2004-03-04 18:26 ` zzapper 2004-03-05 13:05 ` Michael Schaap 1 sibling, 0 replies; 11+ messages in thread From: zzapper @ 2004-03-04 18:26 UTC (permalink / raw) To: zsh-users On Thu, 04 Mar 2004 16:46:34 +0000, Peter Stephenson wrote: > >function vvv() { > setopt localoptions extended_glob > local x > > for x in (#i)*$1* > do > echo $x > done >} That works perfectly!! Thanx zzapper (vim & cygwin & zsh) -- vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: make "for x in *$1*" case insensitive? 2004-03-04 16:46 ` Peter Stephenson 2004-03-04 18:26 ` zzapper @ 2004-03-05 13:05 ` Michael Schaap 2004-03-06 0:18 ` PATCH: case-insensitive globbing Peter Stephenson 1 sibling, 1 reply; 11+ messages in thread From: Michael Schaap @ 2004-03-05 13:05 UTC (permalink / raw) To: zsh-users On 4-Mar-2004 17:46, Peter Stephenson wrote: >zzapper wrote: > > >>If I call the following script with >> >> >> >>>vvv me >>> >>> >>It will not list a file say READ.ME but will list READ.me >> >>function vvv () { >>for x in *$1* >>do >> echo $x >>done >>} >> >> > >function vvv() { > setopt localoptions extended_glob > local x > > for x in (#i)*$1* > do > echo $x > done >} > > It would be nice, though, if zsh had an option to make file globbing case insensitive. I'd enable than on my Cygwin machine, since the Windows file systems basically *are* case insensitive... (Bash has such an option: nocaseglob...) – Michael ^ permalink raw reply [flat|nested] 11+ messages in thread
* PATCH: case-insensitive globbing 2004-03-05 13:05 ` Michael Schaap @ 2004-03-06 0:18 ` Peter Stephenson 2004-03-06 6:15 ` Bart Schaefer 0 siblings, 1 reply; 11+ messages in thread From: Peter Stephenson @ 2004-03-06 0:18 UTC (permalink / raw) To: zsh-users Michael Schaap wrote: > It would be nice, though, if zsh had an option to make file globbing > case insensitive. I'd enable than on my Cygwin machine, since the > Windows file systems basically *are* case insensitive... > > (Bash has such an option: nocaseglob...) This has been on the wish list for ages, but I just realised it's completely trivial to implement... so trivial it might as well be in 4.2.0. It's just the existing code for (#i) turn on at the start of all file globs. (Follow-ups to zsh-workers, please, I just thought I'd advertise it...) `setopt nocaseglob' (or `unsetopt caseglob') to activate. Index: Doc/Zsh/options.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v retrieving revision 1.29 diff -u -r1.29 options.yo --- Doc/Zsh/options.yo 10 Feb 2004 19:19:02 -0000 1.29 +++ Doc/Zsh/options.yo 6 Mar 2004 00:04:29 -0000 @@ -219,6 +219,16 @@ This disables backslashed escape sequences in echo strings unless the tt(-e) option is specified. ) +pindex(CASE_GLOB) +cindex(case-insensitive globbing, option) +item(tt(CASE_GLOB) <D>)( +Make globbing (filename generation) sensitive to case. Note that other +uses of patterns are always sensitive to case. If the option is unset, +the presence of any character which is special to filename generation +will cause case-insensitive matching. For example, tt(cvs(/)) can +match the directory tt(CVS) owing to the presence of the globbing flag +(unless the option tt(BARE_GLOB_QUAL) is unset). +) pindex(C_BASES) cindex(bases, output in C format) cindex(hexadecimal, output in C format) Index: Src/options.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/options.c,v retrieving revision 1.16 diff -u -r1.16 options.c --- Src/options.c 15 May 2003 09:39:57 -0000 1.16 +++ Src/options.c 6 Mar 2004 00:04:38 -0000 @@ -92,6 +92,7 @@ {NULL, "bgnice", OPT_EMULATE|OPT_NONBOURNE, BGNICE}, {NULL, "braceccl", OPT_EMULATE, BRACECCL}, {NULL, "bsdecho", OPT_EMULATE|OPT_SH, BSDECHO}, +{NULL, "caseglob", OPT_ALL, CASEGLOB}, {NULL, "cbases", 0, CBASES}, {NULL, "cdablevars", OPT_EMULATE, CDABLEVARS}, {NULL, "chasedots", OPT_EMULATE, CHASEDOTS}, Index: Src/pattern.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/pattern.c,v retrieving revision 1.16 diff -u -r1.16 pattern.c --- Src/pattern.c 3 Dec 2003 10:54:36 -0000 1.16 +++ Src/pattern.c 6 Mar 2004 00:04:46 -0000 @@ -289,7 +289,10 @@ void patcompstart(void) { - patglobflags = 0; + if (isset(CASEGLOB)) + patglobflags = 0; + else + patglobflags = GF_IGNCASE; } /* Top level pattern compilation subroutine */ Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.52 diff -u -r1.52 zsh.h --- Src/zsh.h 15 Dec 2003 22:45:29 -0000 1.52 +++ Src/zsh.h 6 Mar 2004 00:04:53 -0000 @@ -1412,6 +1412,7 @@ BGNICE, BRACECCL, BSDECHO, + CASEGLOB, CBASES, CDABLEVARS, CHASEDOTS, -- Peter Stephenson <pws@pwstephenson.fsnet.co.uk> Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PATCH: case-insensitive globbing 2004-03-06 0:18 ` PATCH: case-insensitive globbing Peter Stephenson @ 2004-03-06 6:15 ` Bart Schaefer 2004-03-08 10:33 ` Peter Stephenson 0 siblings, 1 reply; 11+ messages in thread From: Bart Schaefer @ 2004-03-06 6:15 UTC (permalink / raw) To: zsh-users On Mar 6, 12:18am, Peter Stephenson wrote: } Subject: PATCH: case-insensitive globbing } } > (Bash has such an option: nocaseglob...) } } This has been on the wish list for ages, but I just realised it's } completely trivial to implement... so trivial it might as well be in } 4.2.0. It's just the existing code for (#i) turn on at the start } of all file globs. Does that mean that (#I) selectively restores case sensitivity? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PATCH: case-insensitive globbing 2004-03-06 6:15 ` Bart Schaefer @ 2004-03-08 10:33 ` Peter Stephenson 2004-03-08 11:15 ` Oliver Kiddle 0 siblings, 1 reply; 11+ messages in thread From: Peter Stephenson @ 2004-03-08 10:33 UTC (permalink / raw) To: zsh-users Bart Schaefer wrote: > On Mar 6, 12:18am, Peter Stephenson wrote: > } Subject: PATCH: case-insensitive globbing > } > } > (Bash has such an option: nocaseglob...) > } > } This has been on the wish list for ages, but I just realised it's > } completely trivial to implement... so trivial it might as well be in > } 4.2.0. It's just the existing code for (#i) turn on at the start > } of all file globs. > > Does that mean that (#I) selectively restores case sensitivity? Correct. There's one patch I need to get in to improve efficiency on Cygwin (currently the shell will try to search the entire directory for files since it doesn't know the OS treats all files case insensitively) which I'll try and do later. -- 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] 11+ messages in thread
* Re: PATCH: case-insensitive globbing 2004-03-08 10:33 ` Peter Stephenson @ 2004-03-08 11:15 ` Oliver Kiddle 2004-03-08 12:22 ` James Devenish 0 siblings, 1 reply; 11+ messages in thread From: Oliver Kiddle @ 2004-03-08 11:15 UTC (permalink / raw) To: zsh-users Peter wrote: > > There's one patch I need to get in to improve efficiency on Cygwin > (currently the shell will try to search the entire directory for files > since it doesn't know the OS treats all files case insensitively) > which I'll try and do later. It's just a thought but would it be somehow possible to detect the filesystem type and allow the efficency gain to be of use where, for example, a windows partition is mounted from linux. It seems that there is a getmntent library function and we can get the name of the filesystem. Presumably this is how find's -fstype option works. I can't see any way of determining a filesystem's case-sensitive/case-preserving properties but we can always have a special array so the user just needs casefs=( vfat ) Oliver ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PATCH: case-insensitive globbing 2004-03-08 11:15 ` Oliver Kiddle @ 2004-03-08 12:22 ` James Devenish 0 siblings, 0 replies; 11+ messages in thread From: James Devenish @ 2004-03-08 12:22 UTC (permalink / raw) To: zsh-users In message <19603.1078744528@trentino.logica.co.uk> on Mon, Mar 08, 2004 at 12:15:28PM +0100, Oliver Kiddle wrote: > It's just a thought but would it be somehow possible to detect the > filesystem type and allow the efficency gain to be of use where, for > example, a windows partition is mounted from linux. Mac OS X has the same problem -- mixtures of case-sensitive and case-insensitive filesystems all at once. > It seems that there is a getmntent library function and we can get the > name of the filesystem. Note that this varies between SysV and BSD systems, at least (cf. getmntent vs statfs). > Presumably this is how find's -fstype option works. I can't see any > way of determining a filesystem's case-sensitive/case-preserving > properties but we can always have a special array so the user just > needs casefs=( vfat ) Also: HFS ? Also, what about the following phenomenon (which is not usual amongst shells) -- is it the same under Cygwin? % mkdir blah % cp -p =date blah/DATE % export PATH=$PWD/blah:$PATH % ls /tmp/blah DATE % rehash % where date /tmp/blah/date /bin/date (not /tmp/blah/DATE) In this case, /tmp is on an HFS volume. Of course, it might be different if /tmp/blah were on a UFS volume. Might be awkward to calculate all this. ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-03-08 12:23 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-03-04 14:11 make "for x in *$1*" case insensitive? zzapper 2004-03-04 14:20 ` Peter Stephenson 2004-03-04 16:08 ` zzapper 2004-03-04 16:46 ` Peter Stephenson 2004-03-04 18:26 ` zzapper 2004-03-05 13:05 ` Michael Schaap 2004-03-06 0:18 ` PATCH: case-insensitive globbing Peter Stephenson 2004-03-06 6:15 ` Bart Schaefer 2004-03-08 10:33 ` Peter Stephenson 2004-03-08 11:15 ` Oliver Kiddle 2004-03-08 12:22 ` James Devenish
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).