zsh-users
 help / color / mirror / code / Atom feed
From: Michael Wardle <michael@endbracket.net>
To: zsh-users@sunsite.dk
Subject: nomatch/cshnullglob problems
Date: Fri, 31 Mar 2006 10:02:09 +1100	[thread overview]
Message-ID: <1143759729.5240.19.camel@pepper.endbracket.net.endbracket.net> (raw)

Hi

There's a couple of things about the NO_MATCH and CSH_NULL_GLOB options
that have surprised me.

It seems that sometimes, CSH_NULL_GLOB causes an error even if some of
the file names in the list match.  It also seems that such an error is
fatal when using "source" or "." (dot).

If I create a script called "globtest" with the following contents,
-----
#!/bin/zsh

setopt cshnullglob
unsetopt nomatch
echo start
for dir
in /opt/*/bin /usr/X11R6/bin /usr/kerberos/bin /usr/posix/bin /usr/gnu/bin /usr/local/bin "$HOME"/bin
do
    test -d "$dir" && echo "$dir"
done
echo finish
-----

set it executable, then run "./globtest", I get the following output:
-----
start
globtest:6: no match
finish
-----

According to the manual:
	CSH_NULL_GLOB <C>
		If a pattern for filename generation has no matches, delete the
pattern
		from the argument list; do not report an error unless all the patterns
in
		a command have no matches.  Overrides NOMATCH.

I this case, I would expect the output to be the same as when the third
line is changed to "unsetopt cshnullglob":
-----
start
/usr/X11R6/bin
/usr/local/bin
/home/michael/bin
finish
-----

since the non-matching "/opt/*/bin" should be removed from the list,
leaving /usr/X11R6/bin /usr/kerberos/bin, etc., and no error should be
reported.

The same directory list containing the /opt/*/bin wildcard seems to work
fine in tcsh, which the CSH_NULL_GLOB option should be emulating.

If the option only comes into effect if there are multiple wildcards
(globbing characters) in the same list, then what is its use, and how
can I get the result I want?

Further, if I run ". globtest", I get the following output:
-----
start
globtest:6: no match
-----

which suggests that the "." command terminates as soon as an error is
encountered.

If I add a "set -o | grep err", I can see that neither ERR_EXIT nor
ERR_RETURN are set, so I would have expected the sourcing of the script
to complete and print "finish" like when it's run as a script.  (The
same script does complete and print "finish" when sourcing the script in
bash.)

I'm running zsh 4.2.5 on Ubuntu Linux.

Is this a bug or the expected behavior?

Thanks

Michael


             reply	other threads:[~2006-03-30 23:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-30 23:02 Michael Wardle [this message]
2006-03-31  9:52 Bart Schaefer
2006-03-31 11:23 Michael Wardle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1143759729.5240.19.camel@pepper.endbracket.net.endbracket.net \
    --to=michael@endbracket.net \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).