zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: nomatch/cshnullglob problems
Date: Fri, 31 Mar 2006 01:52:18 -0800	[thread overview]
Message-ID: <060331015218.ZM6582@torch.brasslantern.com> (raw)

On Mar 31, 10:02am, Michael Wardle wrote:
}
} It seems that sometimes, CSH_NULL_GLOB causes an error even if some of
} the file names in the list match.
[...]
} 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.

Right:  Do not report an error unless all the PATTERNS have no matches.
There is exactly one pattern in your sample command (/opt/*/bin), and
it has no matches.  Any other argument strings with no wildcards in them
are not patterns; the shell doesn't test, or care, whether they "match"
anything.  

} It also seems that such an error is fatal when using "source" or "."
} (dot).

It's not "fatal" or the whole shell would exit ...

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

This is another case where zsh behaves like csh. If you try this same
thing in tcsh, you'll find a "source"d file stops at the same point.
This behavior is considered more useful because, e.g., it prevents
unexepcted commands from being executed from startup files in the event
of an error in setting up a conditional.

Apparently this never made it into the zsh manual because (at the time,
when 4.x BSD and csh were widely in use and zsh users were more often 
switch form csh than from a Bourne-like shell) it's such a well-known
csh behavior.  

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

Really?  Here's tcsh on my system:

[schaefer@torch ~]$ foreach x (/opt/*/bin /usr/X11R6/bin /usr/kerberos/bin
/usr/posix/bin /usr/gnu/bin /usr/local/bin "$HOME"/bin)
foreach: No match.
[schaefer@torch ~]$ foreach x ( /opt/*/bin /usr/X*6/bin /usr/kerberos/bin
/usr/posix/bin /usr/gnu/bin /usr/local/bin "$HOME"/bin )
foreach? end
[schaefer@torch ~]$ 

Note it works if there are two patterns, one of which doesn't match.

} 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?

In your specific example, you probably want just plain NULL_GLOB, which
you can turn on for a single pattern thusly:

for dir
in /opt/*/bin(N) /usr/X11R6/bin /usr/kerberos/bin \
   /usr/posix/bin /usr/gnu/bin /usr/local/bin "$HOME"/bin


             reply	other threads:[~2006-03-31  9:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-31  9:52 Bart Schaefer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-03-31 11:23 Michael Wardle
2006-03-30 23:02 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=060331015218.ZM6582@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).