* list all except @ 2005-02-04 11:30 Eric Smith 2005-02-04 16:16 ` Christian Schneider ` (3 more replies) 0 siblings, 4 replies; 13+ messages in thread From: Eric Smith @ 2005-02-04 11:30 UTC (permalink / raw) To: Zsh Users What is the zsh way to select all files except those matching a regex? -- Eric Smith ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-04 11:30 list all except Eric Smith @ 2005-02-04 16:16 ` Christian Schneider 2005-02-04 16:30 ` Peter Stephenson ` (2 subsequent siblings) 3 siblings, 0 replies; 13+ messages in thread From: Christian Schneider @ 2005-02-04 16:16 UTC (permalink / raw) To: Zsh Users * Eric Smith <es@fruitcom.com> typed: > What is the zsh way to select all files except > those matching a regex? `^foo' matches anything except the pattern `foo' (require extendedglob). See man zshexpn | less -p "Glob Operators" for more details. -- /* Christian 'strcat' Schneider <strcat@gmx.net> */ float o=0.075,h=1.5,T,r,O,l,I;int _,L=80,s=3200;main(){for(;s%L|| (h-=o,T= -2),s;4 -(r=O*O)<(l=I*I)|++ _==L&&write(1,(--s%L?_<L?--_ %6:6:7)+"World! \n",1)&&(O=I=l=_=r=0,T+=o /2))O=I*2*O+h,I=l+T-r;} ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-04 11:30 list all except Eric Smith 2005-02-04 16:16 ` Christian Schneider @ 2005-02-04 16:30 ` Peter Stephenson 2005-02-04 16:55 ` J 2005-02-04 17:44 ` Bart Schaefer 3 siblings, 0 replies; 13+ messages in thread From: Peter Stephenson @ 2005-02-04 16:30 UTC (permalink / raw) To: Zsh Users Eric Smith wrote: > What is the zsh way to select all files except > those matching a regex? (You mean globbing pattern, not regular expression, right?) Use ^pat, which excludes everything matching pat, or pat1~pat2, which selects based on pat1, then excludes based on pat2. These require extendedglob. For example, setopt extendedglob print -l ^*.o You can also "setopt kshglob" and use the ksh forms that bash now understands. These tend to be clumsier. See the list of "Glob Operators" in the zshexpn manual page. -- Peter Stephenson <pws@csr.com> Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, 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. ********************************************************************** ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-04 11:30 list all except Eric Smith 2005-02-04 16:16 ` Christian Schneider 2005-02-04 16:30 ` Peter Stephenson @ 2005-02-04 16:55 ` J 2005-02-04 17:44 ` Bart Schaefer 3 siblings, 0 replies; 13+ messages in thread From: J @ 2005-02-04 16:55 UTC (permalink / raw) To: Eric Smith; +Cc: Zsh Users > What is the zsh way to select all files except > those matching a regex? For a regex, I don't know, but you can select the files that don't match a glob pattern. The natural way is to follow the pattern with ~ and the pattern that represent the files you don't want. Suppose you want to match all files except those matching *.pdf : *~*.pdf Suppose you want to match *.pdf except t*.pdf, just write *.pdf~t*.pdf And that's it. -- J "- Wakai ya na... - Anata yori mo na !" -- Kunisaki Yukito ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-04 11:30 list all except Eric Smith ` (2 preceding siblings ...) 2005-02-04 16:55 ` J @ 2005-02-04 17:44 ` Bart Schaefer 2005-02-05 21:50 ` zzapper 3 siblings, 1 reply; 13+ messages in thread From: Bart Schaefer @ 2005-02-04 17:44 UTC (permalink / raw) To: Eric Smith, Zsh Users On Feb 4, 12:30pm, Eric Smith wrote: } } What is the zsh way to select all files except } those matching a regex? Careful with the term "regex". Although zsh extendedglob patterns are semantically equivalent to regular expressions, they don't follow the usual regular expression syntax. Which do you really mean? If you literally mean a perl-like regular expression, and you have the pcre module available, it'd be something like: zmodload zsh/pcre setopt extendedglob pcre_compile "negpat" echo *(e:'pcre_match "$REPLY" && reply=() || reply=($REPLY)':) (replacing "negpat" with your desired regex, obviously). The more usual way would be to write it as one of two forms of glob pattern: ^negpat (requires extendedglob) pospat~negpat The differences are subtle, and get two whole pages [*] in "From Bash to Zsh". The first matches any file name other than "negpat". The second matches file names with "pospat", then removes those strings that match "negpat". The first matches files within a single level of directory hierarchy. The negpat part of the second can match across directories, if the pospat part contains slashes. These differences are especially important if you combine the ^negpat form with other patterns, e.g., as in xyz(^PDQ)*, which will match xyzPDQzyx because the empty substring between xyz and PDQ is a match for (^PDQ) and PDQzyx is matched by "*". The pcre_match example above works mostly like the pospat~negpat form, because files are first found by globbing and then discarded by pattern matching; but pcre_match is invoked as each file is examined, whereas in pospat~negpat the string removal is done at the end after globbing has finished. This could be important if the pospat uses **/ for tree searching. [*] But not two consecutive pages. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-04 17:44 ` Bart Schaefer @ 2005-02-05 21:50 ` zzapper 2005-02-06 0:23 ` Bart Schaefer 0 siblings, 1 reply; 13+ messages in thread From: zzapper @ 2005-02-05 21:50 UTC (permalink / raw) To: zsh-users On Fri, 4 Feb 2005 17:44:26 +0000, wrote: pmi, I don't seem to be able to get setopt extended_glob to work (CygWin) >ls *.csv xx.csv yy.csv DIR: /home/davidr >ls *.csv~yy.csv zsh: no matches found: *.csv~yy.csv print $ZSH_VERSION 4.2.0 q1) Can I view what is setopted? zzapper (vim, cygwin, wiki & zsh) -- vim -c ":%s%s*%CyrnfrTfcbafbeROenzSZbbyranne%|:%s)[R-T]) )Ig|:norm G1VGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-05 21:50 ` zzapper @ 2005-02-06 0:23 ` Bart Schaefer [not found] ` <ce7c01ph81j1tgrmtplb3hqj8lajgsvsr4@4ax.com> 0 siblings, 1 reply; 13+ messages in thread From: Bart Schaefer @ 2005-02-06 0:23 UTC (permalink / raw) To: zzapper, zsh-users On Feb 5, 9:50pm, zzapper wrote: } } q1) Can I view what is setopted? Sure. Just run "setopt" with no arguments. For a more detailed list, first run "setopt ksh_option_print" and then "setopt". } >ls *.csv } xx.csv yy.csv Try "print *.csv" as well, just to see what you get. It may be that "ls" is hiding something from you. ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <ce7c01ph81j1tgrmtplb3hqj8lajgsvsr4@4ax.com>]
* Re: list all except [not found] ` <ce7c01ph81j1tgrmtplb3hqj8lajgsvsr4@4ax.com> @ 2005-02-06 18:06 ` Bart Schaefer 2005-02-06 19:02 ` zzapper 1 sibling, 0 replies; 13+ messages in thread From: Bart Schaefer @ 2005-02-06 18:06 UTC (permalink / raw) To: zzapper; +Cc: zsh-users [Please choose just one of zsh-users and zsh-workers, because zsh-users is copied to recipients of zsh-workers. I've stuck with -users for now.] On Feb 6, 1:49pm, zzapper wrote: } Subject: Re: list all except } } Bart, } Tried all that. } >setopt } returns nothing Hm. That would mean that it believes it has all the default settings. (The normal behavior is to print only the options that have changed.) However, that should be impossible, because "interactive" is not a default and if that's not set then you wouldn't even have a prompt. You should see at least: interactive shinstdin And probably also "zle", and given how you're starting the shell you should also see "login". } It's as thought setopt isn't functionning } I start with cygwin.bat } zsh --login -i It'd be helpful if you started up "zsh -fx" to be reasonbly sure that there isn't some kind of alias or function wrapper for setopt. (The -x will cause trace output if there's an /etc/zshenv or equivalent being loaded.) } BTW in the doc I find both } } setopt extended_glob } and } setopt extendedglob Yes, and in "man zshoptions" you'll find the first two paragraphs are: Options are primarily referred to by name. These names are case insensitive and underscores are ignored. For example, `allexport' is equivalent to `A__lleXP_ort'. The sense of an option name may be inverted by preceding it with `no', so `setopt No_Beep' is equivalent to `unsetopt beep'. This inversion can only be done once, so `nonobeep' is not a synonym for `beep'. Similarly, `tify' is not a synonym for `nonotify' (the inversion of `notify'). ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except [not found] ` <ce7c01ph81j1tgrmtplb3hqj8lajgsvsr4@4ax.com> 2005-02-06 18:06 ` Bart Schaefer @ 2005-02-06 19:02 ` zzapper 2005-02-07 12:37 ` zzapper 1 sibling, 1 reply; 13+ messages in thread From: zzapper @ 2005-02-06 19:02 UTC (permalink / raw) To: zsh-users On Sun, 06 Feb 2005 13:49:43 +0000, wrote: >On Sun, 6 Feb 2005 00:23:42 +0000, wrote: > >>On Feb 5, 9:50pm, zzapper wrote: >>} >>} q1) Can I view what is setopted? >> Thanx Bart, replying to your post which hasn't appeared yet! zsh -fx solved all my problems setopt returned a list of options I was able to setopt extendedglob and ls *.csv~yy.csv now works, >>>Try to run zsh -fx and see what happens. The option -f (NO_RCS) tells zsh to ignore all initialization files except /etc/zshenv; -x turns on XTRACE, which tells zsh to print everything what is done. so now to work out what is frigomatic with my existing settings! zzapper (vim, cygwin, wiki & zsh) -- vim -c ":%s%s*%CyrnfrTfcbafbeROenzSZbbyranne%|:%s)[R-T]) )Ig|:norm G1VGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-06 19:02 ` zzapper @ 2005-02-07 12:37 ` zzapper 2005-02-07 15:46 ` Bart Schaefer 0 siblings, 1 reply; 13+ messages in thread From: zzapper @ 2005-02-07 12:37 UTC (permalink / raw) To: zsh-users On Sun, 06 Feb 2005 19:02:48 +0000, wrote: >On Sun, 06 Feb 2005 13:49:43 +0000, wrote: > >>On Sun, 6 Feb 2005 00:23:42 +0000, wrote: >> >>>On Feb 5, 9:50pm, zzapper wrote: >>>} >>>} q1) Can I view what is setopted? >>> >Thanx Bart, >replying to your post which hasn't appeared yet! > >zsh -fx > >solved all my problems > But what sort of thing could be wrong with my current setup? How can I start debugging that? my /etc/zshenv just has a return 0 (which I was supposed to remove but I don't pick up my ~/.zshenv if I do) zzapper (vim, cygwin, wiki & zsh) -- vim -c ":%s%s*%CyrnfrTfcbafbeROenzSZbbyranne%|:%s)[R-T]) )Ig|:norm G1VGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-07 12:37 ` zzapper @ 2005-02-07 15:46 ` Bart Schaefer 2005-02-07 16:14 ` zzapper 2005-02-11 8:34 ` zzapper 0 siblings, 2 replies; 13+ messages in thread From: Bart Schaefer @ 2005-02-07 15:46 UTC (permalink / raw) To: zzapper, zsh-users On Feb 7, 12:37pm, zzapper wrote: } Subject: Re: list all except } } On Sun, 06 Feb 2005 19:02:48 +0000, wrote: ^^ Curiosity: Is the blank attribution there because gmane obscures the sender identity for spam-prevention reasons? } But what sort of thing could be wrong with my current setup? } How can I start debugging that? I suggest first renaming all your ~/.z* files (so that zsh won't find them on startup), then run zsh normally. If the problem persists, it's with one of the /etc/z* files. If the problem goes away when you've renamed your ~/.z* files, then start renaming them back to their original names one at a time, starting a new zsh after each rename until the problem reappears. Then you'll know what file you have to look at. Once you know what file, start chopping it up by inserting "return 0" about half way through that file. If the problem persists, it's in the top half, so move the "return 0" to 1/4 of the way through; if not, move the "return 0" to 3/4 of the way through. Continue bisecting the problem portion of the file until you isolate the problem. You might also run zsh with -x (but without -f) to see all the commands it's executing during startup. } /etc/zshenv just has a return 0 (which I was supposed to remove but I } don't pick up my ~/.zshenv if I do) That's odd in and of itself. Do you mean that if you "rm /etc/zshenv" then your ~/.zshenv is not read, or do you mean that if you delete the "return 0" then ...? If the latter, is there really nothing else in /etc/zshenv, that is, it's empty except for "return 0"? You're sure there's not, for example, an assignment to ZDOTDIR or HOME in /etc/zshenv? What other /etc/z* files do yo have? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-07 15:46 ` Bart Schaefer @ 2005-02-07 16:14 ` zzapper 2005-02-11 8:34 ` zzapper 1 sibling, 0 replies; 13+ messages in thread From: zzapper @ 2005-02-07 16:14 UTC (permalink / raw) To: zsh-users On Mon, 7 Feb 2005 15:46:39 +0000, wrote: >On Feb 7, 12:37pm, zzapper wrote: >} Subject: Re: list all except >} >} On Sun, 06 Feb 2005 19:02:48 +0000, wrote: > ^^ >Curiosity: Is the blank attribution there because gmane obscures the >sender identity for spam-prevention reasons? > >} But what sort of thing could be wrong with my current setup? >} How can I start debugging that? > >I suggest first renaming all your ~/.z* files (so that zsh won't find >them on startup), then run zsh normally. If the problem persists, it's >with one of the /etc/z* files. > >If the problem goes away when you've renamed your ~/.z* files, then start >renaming them back to their original names one at a time, starting a new >zsh after each rename until the problem reappears. Then you'll know what >file you have to look at. > >Once you know what file, start chopping it up by inserting "return 0" >about half way through that file. If the problem persists, it's in the >top half, so move the "return 0" to 1/4 of the way through; if not, >move the "return 0" to 3/4 of the way through. Continue bisecting the >problem portion of the file until you isolate the problem. > >You might also run zsh with -x (but without -f) to see all the commands >it's executing during startup. > >} /etc/zshenv just has a return 0 (which I was supposed to remove but I >} don't pick up my ~/.zshenv if I do) > >That's odd in and of itself. Do you mean that if you "rm /etc/zshenv" >then your ~/.zshenv is not read, or do you mean that if you delete the >"return 0" then ...? If the latter, is there really nothing else in >/etc/zshenv, that is, it's empty except for "return 0"? > >You're sure there's not, for example, an assignment to ZDOTDIR or HOME >in /etc/zshenv? > Bart, Thanx that's given me something to get started with zzapper (vim, cygwin, wiki & zsh) -- vim -c ":%s%s*%CyrnfrTfcbafbeROenzSZbbyranne%|:%s)[R-T]) )Ig|:norm G1VGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: list all except 2005-02-07 15:46 ` Bart Schaefer 2005-02-07 16:14 ` zzapper @ 2005-02-11 8:34 ` zzapper 1 sibling, 0 replies; 13+ messages in thread From: zzapper @ 2005-02-11 8:34 UTC (permalink / raw) To: zsh-users On Mon, 7 Feb 2005 15:46:39 +0000, wrote: Bart > >You're sure there's not, for example, an assignment to ZDOTDIR or HOME >in /etc/zshenv? > >What other /etc/z* files do yo have? What killed my setopt (was in my .zshenv) # complete man pages setopt SH_WORD_SPLIT function man_var () { man_pages=( $^manpath/man*/*(N:t:r:r) ) compctl -k man_pages man reply=( $man_pages ) } compctl -K man_var man; man_pages=() zzapper (vim, cygwin, wiki & zsh) -- vim -c ":%s%s*%CyrnfrTfcbafbeROenzSZbbyranne%|:%s)[R-T]) )Ig|:norm G1VGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2005-02-11 20:56 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-02-04 11:30 list all except Eric Smith 2005-02-04 16:16 ` Christian Schneider 2005-02-04 16:30 ` Peter Stephenson 2005-02-04 16:55 ` J 2005-02-04 17:44 ` Bart Schaefer 2005-02-05 21:50 ` zzapper 2005-02-06 0:23 ` Bart Schaefer [not found] ` <ce7c01ph81j1tgrmtplb3hqj8lajgsvsr4@4ax.com> 2005-02-06 18:06 ` Bart Schaefer 2005-02-06 19:02 ` zzapper 2005-02-07 12:37 ` zzapper 2005-02-07 15:46 ` Bart Schaefer 2005-02-07 16:14 ` zzapper 2005-02-11 8:34 ` zzapper
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).