test existence, not symlink

it isn't safe to assume that symlinks created in the enabled/* dirs will
be symlinks later...

some users use tools like Dropbox to sync their files across systems,
and these may transform symlinks into regular files.  explicitly
checking for symlinks with tests like [ -h $file ] will break on these
systems.  these tests have been replaced with [ -e $file ] instead.
pull/134/head
Erich Smith 2012-05-16 13:00:22 -04:00
parent a825c5f16f
commit 758c4f3328
2 changed files with 4 additions and 4 deletions

View File

@ -39,7 +39,7 @@ bash-it-plugins ()
printf "%-20s%-10s%s\n" 'Plugin' 'Enabled?' 'Description' printf "%-20s%-10s%s\n" 'Plugin' 'Enabled?' 'Description'
for f in $BASH_IT/plugins/available/*.bash for f in $BASH_IT/plugins/available/*.bash
do do
if [ -h $BASH_IT/plugins/enabled/$(basename $f) ]; then if [ -e $BASH_IT/plugins/enabled/$(basename $f) ]; then
enabled='x' enabled='x'
else else
enabled=' ' enabled=' '
@ -69,7 +69,7 @@ disable-plugin ()
for f in $BASH_IT/plugins/available/*.bash for f in $BASH_IT/plugins/available/*.bash
do do
plugin=$(basename $f) plugin=$(basename $f)
if [ -h $BASH_IT/plugins/enabled/$plugin ]; then if [ -e $BASH_IT/plugins/enabled/$plugin ]; then
rm $BASH_IT/plugins/enabled/$(basename $plugin) rm $BASH_IT/plugins/enabled/$(basename $plugin)
fi fi
done done
@ -114,7 +114,7 @@ enable-plugin ()
fi fi
plugin=$(basename $plugin) plugin=$(basename $plugin)
if [ -h $BASH_IT/plugins/enabled/$plugin ]; then if [ -e $BASH_IT/plugins/enabled/$plugin ]; then
printf '%s\n' "$1 is already enabled." printf '%s\n' "$1 is already enabled."
return return
fi fi

View File

@ -15,7 +15,7 @@ about-plugin ' z is DEPRECATED, use fasd instead'
# * z -t foo # goes to most recently accessed dir matching foo # * z -t foo # goes to most recently accessed dir matching foo
# * z -l foo # list all dirs matching foo (by frecency) # * z -l foo # list all dirs matching foo (by frecency)
if [ -h $BASH_IT/plugins/enabled/fasd.plugin.bash ]; then if [ -e $BASH_IT/plugins/enabled/fasd.plugin.bash ]; then
printf '%s\n' 'sorry, the z plugin is incompatible with the fasd plugin. you may use either, but not both.' printf '%s\n' 'sorry, the z plugin is incompatible with the fasd plugin. you may use either, but not both.'
return return
fi fi