I was trying to test for noclobber option using: if [ -o noclobber ]
but it turned nothing.
I set the noclobber option on using: set +o noclobber
.
prompt> cat checkoption.sh
#!/bin/bash
if [ -o noclobber ]
then
echo "Option is on."
fi
prompt>
prompt> set +o noclobber
prompt> set -o | grep noglobber
noclobber on
prompt> ./checkoption.sh
prompt>
Any idea why I am not getting a message here?
noclobber
option is not inherited by the script's shell. Try sourcing it:. ./checkoption.sh
– muru Jan 28 '18 at 06:47source
and.
are commands for running a script in the current shell. See https://unix.stackexchange.com/q/182282/70524 – muru Jan 28 '18 at 07:56