zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: zsh blocks at file truncation
Date: Wed, 25 Sep 2013 07:54:17 -0700	[thread overview]
Message-ID: <130925075417.ZM22228@torch.brasslantern.com> (raw)
In-Reply-To: <ECE6FF52-38C6-4334-90FF-BD5791B27DA9@pp1.inet.fi>

On Sep 25, 12:23pm, Marko Vihoma wrote:
}
} $ > file.txt
} 
} creates a new empty file if it does not exist and complains:
} 
} zsh: file exists: file.txt
} 
} if it exists...

16.2.6 Input/Output
-------------------
...

CLOBBER (+C, ksh: +C) <D>
     Allows `>' redirection to truncate existing files, and `>>' to
     create files.  Otherwise `>!' or `>|' must be used to truncate a
     file, and `>>!' or `>>|' to create a file.

} I must have something setup in my ~/.zshrc for this to work that way

You have not.  NO_CLOBBER (+C) is the default, so setup is needed to
make it NOT work that way.

} And if I pull what i wrote
} from history it will give me
} 
} $ >| file.txt

That's a convenience feature.  The assumption is that if you failed to
create the file because of NO_CLOBBER, but then you go to the trouble
of recalling the history and trying it again, you probably really meant
to clobber the file, so the history fixes that part for you in advance.

This all derives from zsh's distant past as a shell for college students
who had a tendency to accidentally destroy their homework.  Zsh's special
default treatment of "rm *" can be traced to the same thing.  (And I'm
only partly kidding here.)


      reply	other threads:[~2013-09-25 14:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-21  7:10 chandan
2013-09-21  7:46 ` Bart Schaefer
2013-09-21  7:53 ` Phil Pennock
2013-09-25  8:49 ` zzapper
2013-09-25  9:23 ` Marko Vihoma
2013-09-25 14:54   ` Bart Schaefer [this message]

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=130925075417.ZM22228@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).