Re: Redirections and noclobber
On Wed, Oct 06, 2004 at 05:02:00PM +0200, Frank Küster wrote:
> in bug #275140, I was made aware of a problem with the handling of
> tempfiles in tetex's maintainer scripts, and it seems to be a general
> problem. Basically, we do
> echo something > $tempfile
> and this will fail if the noclobber option is set in the executing
> shell, because after mktemp the $tempfile exists.
> It is easy to fix this:
> echo something >| $tempfile
> but both I and the bug submitter were puzzled that we didn't find any
> previous discussions about the topic. Obviously, noclobber is only
> rarely used (otherwise we would have gotten bugreports earlier), but I
> see no reason, neither in Policy nor in "common sense", why root
> shouldn't use it. On the other hand, this usage of mktemp has been
> the result of discussions on firstname.lastname@example.org, and I'm quite
> sure to have seen it elsewhere.
In my opinion, noclobber should only be set for interactive shell, or
explicitely in a shell-script. The same for most others shell options.
Now, does POSIX sh support >| ?
Imagine a large red swirl here.