Skip to content

Commit d8c113e

Browse files
committed
cabal's bash-cmpl: handling execs and improvements
Now handling executables: - completing run target - completing executables on build target Improvements: - removed false positives on completion
1 parent c3d6d61 commit d8c113e

File tree

1 file changed

+10
-8
lines changed
  • cabal-install/bash-completion

1 file changed

+10
-8
lines changed

cabal-install/bash-completion/cabal

+10-8
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
#
55

66
# List cabal targets by type, pass:
7-
# - Test-Suite for test suites
8-
# - Benchmark for benchmarks
9-
# - Test-Suite|Benchmark for both
7+
# - test-suite for test suites
8+
# - benchmark for benchmarks
9+
# - executable for executables
10+
# - executable|test-suite|benchmark for the three
1011
_cabal_list()
1112
{
1213
cat *.cabal |
13-
grep -E "$1" |
14+
grep -Ei "^[[:space:]]*($1)[[:space:]]" |
1415
sed -e "s/.* \([^ ]*\).*/\1/"
1516
}
1617

@@ -24,10 +25,11 @@ _cabal_targets()
2425
[ -f *.cabal ] || return 0
2526
local comp
2627
for comp in $*; do
27-
[ $comp == build ] && _cabal_list "Test-Suite|Benchmark" && break
28-
[ $comp == repl ] && _cabal_list "Test-Suite|Benchmark" && break
29-
[ $comp == test ] && _cabal_list "Test-Suite" && break
30-
[ $comp == bench ] && _cabal_list "Benchmark" && break
28+
[ $comp == build ] && _cabal_list "executable|test-suite|benchmark" && break
29+
[ $comp == repl ] && _cabal_list "executable|test-suite|benchmark" && break
30+
[ $comp == run ] && _cabal_list "executable" && break
31+
[ $comp == test ] && _cabal_list "test-suite" && break
32+
[ $comp == bench ] && _cabal_list "benchmark" && break
3133
done
3234
}
3335

0 commit comments

Comments
 (0)