zsh-users
 help / color / mirror / code / Atom feed
* NOCLOBBER option: ">" to ">!" in history?
@ 2006-11-16  8:46 holger.dinkel
  2006-11-16 10:27 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: holger.dinkel @ 2006-11-16  8:46 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1720 bytes --]


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 #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: NOCLOBBER option: ">" to ">!" in history?
  2006-11-16  8:46 NOCLOBBER option: ">" to ">!" in history? holger.dinkel
@ 2006-11-16 10:27 ` Peter Stephenson
  2006-11-16 17:11   ` NOCLOBBER option: ">" to ">!" in history? [SOLVED] holger.dinkel
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2006-11-16 10:27 UTC (permalink / raw)
  To: zsh-users

holger.dinkel@gmail.com wrote:
> 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
> % ...

You actually need to have the HIST_ALLOW_CLOBBER option set for that.
The introduction needs updating.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: NOCLOBBER option: ">" to ">!" in history? [SOLVED]
  2006-11-16 10:27 ` Peter Stephenson
@ 2006-11-16 17:11   ` holger.dinkel
  0 siblings, 0 replies; 3+ messages in thread
From: holger.dinkel @ 2006-11-16 17:11 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

Hello Peter,


> Peter Stephenson schrieb am 16/11/06 10:27 +0000:
> 
> You actually need to have the HIST_ALLOW_CLOBBER option set for that.
> The introduction needs updating.

That did the trick! Thank you very much!

Best wishes,

Holger

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-16 17:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-16  8:46 NOCLOBBER option: ">" to ">!" in history? holger.dinkel
2006-11-16 10:27 ` Peter Stephenson
2006-11-16 17:11   ` NOCLOBBER option: ">" to ">!" in history? [SOLVED] holger.dinkel

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).