Zsh Mailing List Archive
Messages sorted by:
Re: Any way to allow clobbering empty files when noclobber is set?
- X-seq: zsh-workers 45960
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>, "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: Any way to allow clobbering empty files when noclobber is set?
- Date: Thu, 04 Jun 2020 04:06:32 +0000
- Cc: "Martin Tournoij" <martin@xxxxxxxxxx>
- In-reply-to: <CAH+w=7a0s5BhBWRHReD1oGkKLkxVt8rs+kZQu9Dg0-efaKuYtg@mail.gmail.com>
- List-help: <mailto:email@example.com>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- List-unsubscribe: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20200603020919eucas1p13e26ebcbb335784d14bfb97b137f385a@eucas1p1.samsung.com> <firstname.lastname@example.org> <94e73ebcf39d4d3f9c7ae257b1d75d16@CAMSVWEXC01.scsc.local> <email@example.com> <CAH+w=7a0s5BhBWRHReD1oGkKLkxVt8rs+kZQu9Dg0-efaKuYtg@mail.gmail.com>
Bart Schaefer wrote on Thu, 04 Jun 2020 02:43 +00:00:
> On Wed, Jun 3, 2020 at 6:49 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> > I certainly have several cases in my $HISTFILE where I repeated
> > a command with «>» changed to «>!»,¹ in the pattern Martin described.
> Are you sure you haven't set the HIST_ALLOW_CLOBBER option?
I am. I really do have consecutive pairs of lines where the second line
is equal to the first one with s/>/>!/.
> > ... 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.
[ Let's call this UNLINK_EMPTY_AFTER_FAILURE for the sake of discussion. ]
> How does that user experience differ from HIST_ALLOW_CLOBBER? In
> either of those cases, you have to retrieve the command from history
> and execute it again ...
Well, for one, because that proposal only takes effect when foo exited
non-zero, created bar, and bar is zero-sized? HIST_ALLOW_CLOBBER
applies even when some of these conditions don't hold.
> and silently unlinking a file is not very friendly. The /etc/nologin
> example in your next message comes to mind.
Doesn't this argument also apply to anyone who might set CLOBBER_EMPTY
and then lose the timestamps on empty files, as in your next message?
That's why these options are opt-in.
Seriously, though, it's perfectly possible that CLOBBER_EMPTY is the
better solution here. I was only brainstorming.
Messages sorted by: