1

I am in the bash shell, BSD unix, under macos, but I think this would apply to many other unix shells. The noclobber option can be useful at times:

> find . -name z
> set -o noclobber
> echo "dog" > z
> echo "dog" > z
-bash: z: cannot overwrite existing file

But how do I un-set it, without launching a new shell? Curiously, bash undo set noclobber, unix un-do set noclobber, and similar searches did not quickly bring up an answer.

None of the following work:

> unset -o noclobber
-bash: unset: -o: invalid option
unset: usage: unset [-f] [-v] [name ...]
> unset noclobber
> echo "dog" > z
-bash: z: cannot overwrite existing file
> set -o clobber
-bash: set: clobber: invalid option name

1 Answers1

1

One finds the answer at How to undo `set -x`?, so that we have

> set +o noclobber
> echo "dog" > z
> 

It is a bit counterintuitive: + turns something off; - turns it on.

And of course unset noclobber would just delete any variable I might have created which was named noclobber. That would have no effect on unix options.