summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Murzov <e-mail@date.by>2012-01-12 19:54:06 +0400
committerIgor Murzov <e-mail@date.by>2012-01-13 00:20:45 +0400
commit33883145af5e3290105e2f784f84c7468617d5ee (patch)
tree8f00b8201276d1b674fa3f4d5f758381616d3ae5
parent32e8f3301801c9ff86f9620ca135f83f71590e29 (diff)
downloadbash-completion-33883145af5e3290105e2f784f84c7468617d5ee.tar.gz
sbopkg, slackpkg, slapt-{get,src}: Use shorter form of the check if file exists.
Also add information about corresponding man pages.
-rw-r--r--completions/sbopkg11
-rw-r--r--completions/slackpkg6
-rw-r--r--completions/slapt-get6
-rw-r--r--completions/slapt-src6
-rw-r--r--test/lib/completions/slapt-get.exp6
5 files changed, 15 insertions, 20 deletions
diff --git a/completions/sbopkg b/completions/sbopkg
index 9ccc997a..598cb8cf 100644
--- a/completions/sbopkg
+++ b/completions/sbopkg
@@ -1,4 +1,4 @@
-# bash completion for sbopkg tool -*- shell-script -*-
+# bash completion for sbopkg(8) -*- shell-script -*-
_sbopkg()
{
@@ -44,10 +44,7 @@ _sbopkg()
fi
done
- if [[ ! -r "$config" ]]; then
- return
- fi
-
+ [[ -r "$config" ]] || return
. $config
for (( i=1; i<${#words[@]}; i++ )); do
@@ -61,10 +58,8 @@ _sbopkg()
;;
esac
done
+ [[ -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]] || return
- if [[ ! -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]]; then
- return
- fi
COMPREPLY=( $( sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\
$REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT )
$( cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur" ) )
diff --git a/completions/slackpkg b/completions/slackpkg
index b4223e71..1be2f956 100644
--- a/completions/slackpkg
+++ b/completions/slackpkg
@@ -1,4 +1,4 @@
-# bash completion for slackpkg tool -*- shell-script -*-
+# bash completion for slackpkg(8) -*- shell-script -*-
# options list is based on `grep '\-.*\=.*)' /usr/sbin/slackpkg | cut -f1 -d\)`
_slackpkg()
@@ -43,9 +43,7 @@ _slackpkg()
local confdir="/etc/slackpkg"
local config="$confdir/slackpkg.conf"
- if [[ ! -r "$config" ]]; then
- return
- fi
+ [[ -r "$config" ]] || return
. "$config"
local i action
diff --git a/completions/slapt-get b/completions/slapt-get
index 02f007ec..ff42660a 100644
--- a/completions/slapt-get
+++ b/completions/slapt-get
@@ -1,4 +1,4 @@
-# slapt-get completion -*- shell-script -*-
+# slapt-get(8) completion -*- shell-script -*-
_slapt_get()
{
@@ -48,9 +48,7 @@ _slapt_get()
break
fi
done
- if [[ ! -r "$config" ]]; then
- return
- fi
+ [[ -r "$config" ]] || return
case $t in
all) # --show
diff --git a/completions/slapt-src b/completions/slapt-src
index 6234eaa8..94ddb892 100644
--- a/completions/slapt-src
+++ b/completions/slapt-src
@@ -1,4 +1,4 @@
-# slapt-src completion -*- shell-script -*-
+# slapt-src(8) completion -*- shell-script -*-
_slapt_src()
{
@@ -42,9 +42,7 @@ _slapt_src()
break
fi
done
- if [[ ! -r "$config" ]]; then
- return
- fi
+ [[ -r "$config" ]] || return
if [[ "$cur" == *:* ]]; then
local name=${cur%:*}
diff --git a/test/lib/completions/slapt-get.exp b/test/lib/completions/slapt-get.exp
index 70afc666..7f5375a4 100644
--- a/test/lib/completions/slapt-get.exp
+++ b/test/lib/completions/slapt-get.exp
@@ -24,6 +24,12 @@ assert_complete "--update --upgrade" "slapt-get --up" $test
sync_after_int
+set test "--install should not complete anything if config doesn't exist"
+assert_no_complete "slapt-get -c non-existent-file --install " $test
+
+
+sync_after_int
+
set test "--install should complete available packages"
set config $::srcdir/fixtures/slackware/etc/slapt-get/slapt-getrc