From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Martin Tournoij <martin@arp242.net>, <zsh-workers@zsh.org>
Subject: Re: Any way to allow clobbering empty files when noclobber is set?
Date: Thu, 4 Jun 2020 01:48:50 +0000 [thread overview]
Message-ID: <20200604014850.52d241bd@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <94e73ebcf39d4d3f9c7ae257b1d75d16@CAMSVWEXC01.scsc.local>
Peter Stephenson wrote on Wed, 03 Jun 2020 12:04 +0000:
> Martin Tournoij wrote:
> > I switched from tcsh to zsh a while ago (many years too late, I know),
> > and found zsh can do pretty much everything better. There's one thing
> > I rather miss though: the 'notempty' option in 'noclobber'.
>
> This isn't actually hard to implement. What does everyone else think?
I certainly have several cases in my $HISTFILE where I repeated
a command with «>» changed to «>!»,¹ in the pattern Martin described.
I suppose that pattern is common enough to offset the standard "Not
another option!" concern.
However, I wonder whether there are other ways to peel this orange. For
example, I don't recall _other_ cases where I might have found the
proposed behaviour useful — that is, cases where I used «>» to create
a file, got an error because the file had been created as empty before
I executed my command, and would have preferred for shell to just
proceed without flagging an error — so, thinking out loud, how about an
option that does the following:
Given «foo > bar», if «foo» was run and exited non-zero and
NO_CLOBBER in effect [which implies that «bar» didn't exist before
foo was run], check whether «bar» is zero-size and, if so, unlink it.
?
[To be clear, no objection to CLOBBER_EMPTY as posted; just brainstorming
alternatives.]
Peter Stephenson wrote on Wed, 03 Jun 2020 12:04 +0000:
> +++ b/Doc/Zsh/options.yo
> @@ -1168,6 +1168,19 @@ If the option is not set, and the option tt(APPEND_CREATE) is also
> +item(tt(CLOBBER_EMPTY))(
> +This option is only used if the option tt(CLOBBER) is not set: note that
> +it is set by default.
The referent of the pronoun "it" is ambiguous.
Cheers,
Daniel
¹ The first five of them [I didn't check further] are a pretty varied
bunch: some of them are a single simple command with an output
redirection; some of them have the redirection inside a function [or
a «strace zsh -c»]; and one of them uses the $NULLCMD syntax with
literally nothing on the line other than the redirection operator and
its file target.
next prev parent reply other threads:[~2020-06-04 1:49 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200603020919eucas1p13e26ebcbb335784d14bfb97b137f385a@eucas1p1.samsung.com>
2020-06-03 2:08 ` Martin Tournoij
2020-06-03 12:04 ` Peter Stephenson
2020-06-04 1:48 ` Daniel Shahaf [this message]
2020-06-04 2:43 ` Bart Schaefer
2020-06-04 4:06 ` Daniel Shahaf
2020-06-04 5:00 ` Bart Schaefer
2020-06-05 3:10 ` Daniel Shahaf
2020-06-05 3:18 ` Daniel Shahaf
2020-06-06 1:07 ` Bart Schaefer
2020-06-06 4:48 ` Daniel Shahaf
2020-06-06 7:04 ` Bart Schaefer
2020-06-04 6:31 ` Martin Tournoij
2020-06-05 2:22 ` Daniel Shahaf
2020-06-04 2:13 ` Vin Shelton
2020-06-04 2:35 ` Bart Schaefer
2020-06-04 2:36 ` Daniel Shahaf
2020-06-04 11:57 ` Vin Shelton
2020-06-04 5:06 ` Bart Schaefer
2020-06-04 5:41 ` Roman Perepelitsa
2020-06-05 2:07 ` Daniel Shahaf
2020-06-05 4:38 ` Roman Perepelitsa
2020-06-06 1:41 ` Bart Schaefer
2020-06-06 4:55 ` Daniel Shahaf
2020-06-06 6:25 ` Roman Perepelitsa
2020-06-06 7:08 ` Bart Schaefer
2020-06-06 8:03 ` Daniel Shahaf
[not found] ` <1941572212.466119.1591360860372@mail2.virginmedia.com>
[not found] ` <e7f7dfe2-eb4a-457b-85fb-091935a74c0e@www.fastmail.com>
2020-06-06 11:57 ` Peter Stephenson
2020-06-06 12:48 ` Roman Perepelitsa
2020-06-06 15:24 ` Bart Schaefer
2020-06-06 16:24 ` Peter Stephenson
2020-06-07 11:55 ` Daniel Shahaf
2020-06-07 17:00 ` Peter Stephenson
2020-06-08 3:27 ` Daniel Shahaf
2020-06-08 9:30 ` Peter Stephenson
2020-06-07 17:20 ` Bart Schaefer
2020-06-06 15:09 ` Bart Schaefer
2020-06-04 6:47 ` Martin Tournoij
2020-06-04 9:42 ` Peter Stephenson
2020-06-04 12:20 ` Roman Perepelitsa
2020-06-04 12:26 ` Peter Stephenson
2020-06-04 12:15 ` Peter Stephenson
2020-06-04 20:35 ` Bart Schaefer
2020-06-05 1:59 ` Daniel Shahaf
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=20200604014850.52d241bd@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=martin@arp242.net \
--cc=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/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).