Tha*_*you 6 unix zsh command-line
这按预期工作
$ echo "foo" > foo
$ cat foo # foo
$ echo "updated" > foo
$ cat foo # updated
Run Code Online (Sandbox Code Playgroud)
从 man set
-C If set, bash does not overwrite an existing file with the
>, >&, and <> redirection operators. This may be overridden
when creating output files by using the redirection operator
>| instead of >.
Run Code Online (Sandbox Code Playgroud)
好的,让我们 set -C
$ set -C
$ echo "bar" > bar
$ cat bar # bar
$ echo "updated" > bar
file exists: bar
Run Code Online (Sandbox Code Playgroud)
这一切都很好,但现在是时候关闭了set -C
。
set -C
开启后如何关闭?
我试过了:
$ unset -C
zsh: bad option: -C
Run Code Online (Sandbox Code Playgroud)
Tha*_*you 11
废话。就这么简单
$ set +C
Run Code Online (Sandbox Code Playgroud)
当然,我在发布问题后立即找到了答案。
该名男子的网页并不真正提的区别+
和-
。