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

NOCLOBBER option: ">" to ">!" in history?



Hi List,

i stumbled upon an oddity regarding the "noclobber" option...

In http://zsh.sunsite.dk/Intro/intro_16.html it reads:

--------------------------------------------------------------------------------
NOCLOBBER prevents you from accidentally overwriting an existing file. 
% setopt noclobber
% cat /dev/null >~/.zshrc
zsh: file exists: /u/pfalstad/.zshrc

If you really do want to clobber a file, you can use the >! operator. To make things easier in this case, the > is stored in the history list as a >!: 
% cat /dev/null >! ~/.zshrc
% cat /etc/motd > ~/.zshrc
zsh: file exists: /u/pfalstad/.zshrc
% !!
cat /etc/motd >! ~/.zshrc
% ...
--------------------------------------------------------------------------------

So using the noclobber option, piping into an existing file should
raise an error, but the last command in the history should contain the
"override" command ">!".

Sad enough this does not work in my case:

        $ setopt noclobber
        $ cat /dev/null >! /tmp/testfile
        $ cat /etc/motd > /tmp/testfile
        zsh: file exists: /tmp/testfile
        $ !!
        cat /etc/motd > /tmp/testfile
        zsh: file exists: /tmp/testfile


i already tried this with an empty .zshrc in order to exclude any
cross-reaction with my other zsh-settings, but to no avail...

$zsh --version
zsh 4.2.5 (i686-pc-linux-gnu)


Does anyone know why this isn't working?
I like the noclobber idea a lot, because it prevents me from
accidentally overwriting files. Yet it would be beneficial if i did
not have to re-edit the last command each time i want to overwrite the
file...

Any idea highly appreciated!

Many thanks in advance,

Holger

Attachment: pgpv9tBhMKkqI.pgp
Description: PGP signature



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