How to create bash-pattern to exclude a matching param in param expansionmatching?
I am missing how to create a bash-pattern that excludes a specific pattern. I.e. to ignore any file with '-IGN-' somewhere in the filename. The best I've come up with so far has been to use shell to build a pattern, but I know it is limited in functionality. I.e.: ls !($(echo *+(-IGN-)*|tr |)) I tried the above in a dir that has 2 files w/the pattern, and 532 w/o, and it worked, but how much of that was 'luck'? Is there a better bash-pattern that doesn't use tr and such? Thanks!
Re: How to create bash-pattern to exclude a matching param in param expansionmatching?
On 10/28/2013 3:35 PM, Linda Walsh wrote: ls !($(echo *+(-IGN-)*|tr |)) I tried the above in a dir that has 2 files w/the pattern, and 532 w/o, and it worked, but how much of that was 'luck'? --- Slight improvement -- but still not a direct bash pattern: !($(printf %s| *+(-IGN-)*))
Re: How to create bash-pattern to exclude a matching param in param expansionmatching?
On 10/28/2013 04:35 PM, Linda Walsh wrote: I am missing how to create a bash-pattern that excludes a specific pattern. I.e. to ignore any file with '-IGN-' somewhere in the filename. The best I've come up with so far has been to use shell to build a pattern, but I know it is limited in functionality. I.e.: ls !($(echo *+(-IGN-)*|tr |)) for $var in *; do case $var in *-IGN-*) ;; *) # whatever you wanted on the remaining files ;; esac done -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: How to create bash-pattern to exclude a matching param in param expansionmatching?
On 10/28/2013 04:41 PM, Linda Walsh wrote: On 10/28/2013 3:35 PM, Linda Walsh wrote: ls !($(echo *+(-IGN-)*|tr |)) I tried the above in a dir that has 2 files w/the pattern, and 532 w/o, and it worked, but how much of that was 'luck'? --- Slight improvement -- but still not a direct bash pattern: !($(printf %s| *+(-IGN-)*)) What's wrong with: !(*-IGN-*) -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: How to create bash-pattern to exclude a matching param in param expansionmatching?
On Mon, 28 Oct 2013, Linda Walsh wrote: I am missing how to create a bash-pattern that excludes a specific pattern. I.e. to ignore any file with '-IGN-' somewhere in the filename. The best I've come up with so far has been to use shell to build a pattern, but I know it is limited in functionality. I.e.: ls !($(echo *+(-IGN-)*|tr |)) I tried the above in a dir that has 2 files w/the pattern, and 532 w/o, and it worked, but how much of that was 'luck'? Is there a better bash-pattern that doesn't use tr and such? ls !(*-IGN-*) -- Chris F.A. Johnson, http://cfajohnson.com/
Re: How to create bash-pattern to exclude a matching param in param expansionmatching?
On 10/28/2013 3:47 PM, Chris F.A. Johnson wrote: Is there a better bash-pattern that doesn't use tr and such? ls !(*-IGN-*) --- Seems perfect... Had a slightly more complex usage (filtering MS packages) but it seems to work: ls !(*_@(en-us|none)*) Thanks!
Re: How to create bash-pattern to exclude a matching param in param expansionmatching?
On 10/28/2013 3:47 PM, Eric Blake wrote: What's wrong with: !(*-IGN-*) -- Thanks 2!
Re: How to create bash-pattern to exclude a matching param in param expansionmatching?
Eric Blake wrote: for $var in *; do case $var in *-IGN-*) ;; *) # whatever you wanted on the remaining files ;; esac done A couple of minor syntax errors in the above. But we know it is simply that perl influence that dragged you that way. :-) This is a typical pattern for me. But I optimize it a little bit when possible by doing it this way. for var in *; do case $var in *-IGN-*) continue ;; esac whatever you wanted on the remaining files done Bob
[PATCH] bash: fix error path of getc_with_restart()
When read() returns with ERROR, local_bufused will be set to -1; and if we return with local_bufused == -1 left, the next time we call getc_with_restart(), the condition (local_index == local_bufused || local_bufused == 0) will not match, thus we get random data from localbuf[] with local_index increased each time, eventually we may access data beyond array localbuf[]. Fix it by resetting local_index and local_bufused in case of read failure. Signed-off-by: Yong Zhang yong.zh...@windriver.com --- Please Cc me because I'm not subscribing this list. input.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/input.c b/input.c index 2731e29..8362068 100644 --- a/input.c +++ b/input.c @@ -92,6 +92,8 @@ getc_with_restart (stream) if (sh_unset_nodelay_mode (fileno (stream)) 0) { sys_error (_(cannot reset nodelay mode for fd %d), fileno (stream)); + local_index = 0; + local_bufused = 0; return EOF; } continue; @@ -99,6 +101,7 @@ getc_with_restart (stream) else if (local_bufused == 0 || errno != EINTR) { local_index = 0; + local_bufused = 0; return EOF; } } -- 1.8.2.1