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

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

Peter Stephenson schreef op 27-06-15 om 19:02:
> This isn't very elegant, but nor is it obviously problematic, and it
> does at least draw attention to a potential issue.

I've tested this patch against the current git version and noticed the

- The new clobberappend option is on by default, but 'set -C' (-o
noclobber) turns clobberappend off. Conversely, 'set +C' (+o noclobber)
turns it back on. This applies even when noclobber is already on or off.

- Contrary to the documentation, unsetting clobberappend has effect even
when noclobber is not active. IOW, this currently provides a way to keep
'>>' from creating files even when noclobber is off.

- 'emulate sh' and 'emulate ksh' do not make any difference to the above.

While it's good to be able to modify this behaviour, this does not
achieve POSIX compatibility for 'set -C': even in the emulation modes,
'>>' still won't create nonexistent files, and enabling this ability
requires a zsh-specific 'set -o clobberappend' command.

At the risk of pedantry, I also wonder if 'createappend' or
'appendcreate' would be a better name, since "clobbering" is commonly
understood to mean overwriting pre-existing files, not creating new ones.

Hope this helps,

- M.

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