zsh-users
 help / color / mirror / code / Atom feed
* Filename Expansion
@ 1995-10-20  0:52 Toshi Isogai
  1995-10-20  1:52 ` Zefram
  1995-10-20  1:57 ` Richard Coleman
  0 siblings, 2 replies; 4+ messages in thread
From: Toshi Isogai @ 1995-10-20  0:52 UTC (permalink / raw)
  To: zsh-users


I am writing a script to search files in a certain pattern
and manipulate them. Something like:

	for i in *.vhd; do
 		# do some operation on $i here
	done
	# do other stuff


This works fine if there is at least one file matches the
pattern. Otherwise, it exits with an error and 'other stuff'
never gets done.

How can I make it so that it will just skip 'for' loop if
there aren't any files matches the pattern?


Toshi Isogai   ^[$@0k3-MxL@^[(J



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Filename Expansion
  1995-10-20  0:52 Filename Expansion Toshi Isogai
@ 1995-10-20  1:52 ` Zefram
  1995-10-20  2:04   ` Vincent Lefevre
  1995-10-20  1:57 ` Richard Coleman
  1 sibling, 1 reply; 4+ messages in thread
From: Zefram @ 1995-10-20  1:52 UTC (permalink / raw)
  To: Toshi Isogai; +Cc: zsh-users

>Toshi Isogai wrote:
>This works fine if there is at least one file matches the
>pattern. Otherwise, it exits with an error and 'other stuff'
>never gets done.
>
>How can I make it so that it will just skip 'for' loop if
>there aren't any files matches the pattern?

setopt nullglob

-zefram


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Filename Expansion
  1995-10-20  0:52 Filename Expansion Toshi Isogai
  1995-10-20  1:52 ` Zefram
@ 1995-10-20  1:57 ` Richard Coleman
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Coleman @ 1995-10-20  1:57 UTC (permalink / raw)
  To: Toshi Isogai; +Cc: zsh-users

> I am writing a script to search files in a certain pattern
> and manipulate them. Something like:
> 
> 	for i in *.vhd; do
>  		# do some operation on $i here
> 	done
> 	# do other stuff
> 
> 
> This works fine if there is at least one file matches the
> pattern. Otherwise, it exits with an error and 'other stuff'
> never gets done.
> 
> How can I make it so that it will just skip 'for' loop if
> there aren't any files matches the pattern?


for i in *.vhd(N); do
   # do some stuff
done

The (N) says to use the nullglob option for this particular
glob pattern.

Richard Coleman
coleman@math.gatech.edu


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Filename Expansion
  1995-10-20  1:52 ` Zefram
@ 1995-10-20  2:04   ` Vincent Lefevre
  0 siblings, 0 replies; 4+ messages in thread
From: Vincent Lefevre @ 1995-10-20  2:04 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-users

> setopt nullglob

Writing
        for i in *.vhd(N); do
is better since it does not change the options (the setopt nullglob
is "local").

Vincent Lefevre.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1995-10-20  2:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-10-20  0:52 Filename Expansion Toshi Isogai
1995-10-20  1:52 ` Zefram
1995-10-20  2:04   ` Vincent Lefevre
1995-10-20  1:57 ` Richard Coleman

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