3 ms·
> and the fact that `> somefile.txt` will silently truncate the file Bash has the "set -C" option to toggle on "no-overwrite" mode for redirection operators.
by pwg 14y ago
> and the fact that `> somefile.txt` will silently truncate the file
Bash has the "set -C" option to toggle on "no-overwrite" mode for redirection operators.
- Evbn 14y agoBut it's obnoxiously not set by default.
- deleted 14y ago[deleted]
- sequoia 14y agoThis might screw up some POSIX shell scripts if they expect to be able to write a tmp file or overwrite one if it already exists.
- gnosis 14y agozsh also has a "setopt NO_CLOBBER", but it's also not the default (unfortunately). Default behavior: % touch foo % echo bar > foo % cat foo bar % rm foo No clobber mode: % setopt NO_CLOBBER % touch foo % echo bar > foo zsh: file exists: foo Manual override: % echo bar >| foo % cat foo bar