Issue
I have a path that is managed by update-alternatives. It seems this is confusing bash.
The following if should not print yes. But it does because bash thinks the directory does not exist - when in fact it does. This is all done as root, and I've tried the single bracket versions.
RUBY_ROOT=/usr/bin/ruby
CHK_DIR_PATH=`readlink -f "${RUBY_ROOT}"`
if [[ ! -d "${CHK_DIR_PATH}" ]] ; then echo yes; fi
The path does exist:
ls -la ${CHK_DIR_PATH}
-rwxr-xr-x 1 root root 6993617 2011-06-21 15:37 /usr/bin/ruby1.9.2-p180
Is there an alternative way to check if a directory does not exist?
Solution
The path exists, but it's not a directory; according to your ls -l
, it's a file. So test -d
correctly returns false, whereas test -e
and test -f
would return true. I suspect you have something installed incorrectly.
Answered By - geekosaur Answer Checked By - Mildred Charles (WPSolving Admin)