Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: '>>' does not create file if set -C (noclobber) is active



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



Messages sorted by: Reverse Date, Date, Thread, Author