bug-bash@gnu.org

2013-10-28 Thread Linda Walsh

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!








bug-bash@gnu.org

2013-10-28 Thread Linda Walsh

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-)*))



bug-bash@gnu.org

2013-10-28 Thread Eric Blake
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


bug-bash@gnu.org

2013-10-28 Thread Eric Blake
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


bug-bash@gnu.org

2013-10-28 Thread Chris F.A. Johnson

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, 



bug-bash@gnu.org

2013-10-28 Thread Linda Walsh

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!




bug-bash@gnu.org

2013-10-28 Thread Linda Walsh



On 10/28/2013 3:47 PM, Eric Blake wrote:

What's wrong with:

!(*-IGN-*)



-- Thanks 2!



bug-bash@gnu.org

2013-10-28 Thread Bob Proulx
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()

2013-10-28 Thread Yong Zhang
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 
---
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