zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@zsh.org
Subject: Re: '>>' does not create file if set -C (noclobber) is active
Date: Sun, 28 Jun 2015 11:15:53 +0200	[thread overview]
Message-ID: <16434.1435482953@thecus.kiddle.eu> (raw)
In-Reply-To: <20150628074837.GB4818@chaz.gmail.com>

Stephane Chazelas wrote:
> I agree it's a potentially useful feature to prevent >> from
> creating files, but it shouldn't be done upon a "noclobber"
> option as it's the opposite meaning that noclobber conveys.

If we're preserving backward compatibility for both states of the
clobber option, it has to be linked to the noclobber option.

I'm not so bothered about the name but perhaps a CSH_ prefix on it would
make sense.

> BTW, slightly related, I think it would be nice for the shell to
> have access to some of the other open() flags. I often found
> myself wishing I could use O_NOFOLLOW for instance.
> 
> How about a <(flags)> operator

O_NOFOLLOW is fairly easily emulated, either with a condition or, if you
really want succinct, a glob qualifier: > file(^@)
But for other flags like O_CLOEXEC or O_SYNC, you can't do much.
We'd also have to worry about how portable each of the open flags are.

New syntax has additional costs such as making scripts less readable. An
alternative would be to add a sysopen builtin to the zsh/system module.
Or perhaps a -o option to exec, e.g. exec -o nofollow 3>file

> That could even be extended to do lseeks(), dups(), (3<(>+20)>
> to lseek(3, 20, SEEK_CUR))...

Recent ksh has <#((offset)) and <##pattern for seeking.
Along with (( fd<# )) to get the current position.
I'm not sure how useful that would really be, especially as byte offsets
are less meaningful when you have multibyte encodings.

Oliver


  reply	other threads:[~2015-06-28  9:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25  1:02 Martijn Dekker
2015-06-25  1:49 ` Bart Schaefer
2015-06-25  2:22   ` Martijn Dekker
2015-06-25  7:30     ` Bart Schaefer
2015-06-25 14:04       ` Stephane Chazelas
2015-06-25 16:00         ` Bart Schaefer
2015-06-25 19:20           ` Chet Ramey
2015-06-26 14:14       ` Martijn Dekker
2015-06-26 20:15         ` Bart Schaefer
2015-06-27  1:54           ` Martijn Dekker
2015-06-27  3:38             ` Bart Schaefer
2015-06-27 17:02         ` Peter Stephenson
2015-06-28  0:02           ` Martijn Dekker
2015-06-28  0:46             ` Martijn Dekker
2015-06-28  7:48             ` Stephane Chazelas
2015-06-28  9:15               ` Oliver Kiddle [this message]
2015-06-28 14:00                 ` Stephane Chazelas
2015-06-28 18:38                   ` Bart Schaefer
2015-06-28 19:30                     ` Stephane Chazelas
2015-07-23  2:56                     ` PATCH: sysopen (was Re: '>>' does not create file if set -C (noclobber) is active) Oliver Kiddle
2015-07-24 10:57                       ` Peter Stephenson
2015-07-24 11:55                         ` Peter Stephenson
2015-07-30 11:05                           ` Mikael Magnusson
2015-07-31 12:41                         ` Oliver Kiddle
2015-07-31 14:02                           ` Mikael Magnusson
2015-06-28 17:19             ` '>>' does not create file if set -C (noclobber) is active Peter Stephenson

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=16434.1435482953@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --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).