Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cabal
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Haskell
Cabal
Commits
6ad43eed
Commit
6ad43eed
authored
9 years ago
by
Mikhail Glushenkov
Browse files
Options
Downloads
Plain Diff
Merge pull request #3384 from kolmodin/pr/bash-completion
Fix bugs with bash completion
parents
a20290cb
0122e821
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cabal-install/bash-completion/cabal
+15
-15
15 additions, 15 deletions
cabal-install/bash-completion/cabal
with
15 additions
and
15 deletions
cabal-install/bash-completion/cabal
+
15
−
15
View file @
6ad43eed
...
...
@@ -10,9 +10,10 @@
# - executable|test-suite|benchmark for the three
_cabal_list()
{
cat *.cabal |
grep -Ei "^[[:space:]]*($1)[[:space:]]" |
sed -e "s/.* \([^ ]*\).*/\1/"
for f in ./*.cabal; do
grep -Ei "^[[:space:]]*($1)[[:space:]]" "$f" |
sed -e "s/.* \([^ ]*\).*/\1/"
done
}
# List possible targets depending on the command supplied as parameter. The
...
...
@@ -20,17 +21,16 @@ _cabal_list()
# This is a temporary workaround.
_cabal_targets()
{
# If command ($*) contains build, repl, test or bench completes with
# targets of according type.
[ -f *.cabal ] || return 0
local comp
for comp in $*; do
[ $comp == build ] && _cabal_list "executable|test-suite|benchmark" && break
[ $comp == repl ] && _cabal_list "executable|test-suite|benchmark" && break
[ $comp == run ] && _cabal_list "executable" && break
[ $comp == test ] && _cabal_list "test-suite" && break
[ $comp == bench ] && _cabal_list "benchmark" && break
done
# If command ($*) contains build, repl, test or bench completes with
# targets of according type.
local comp
for comp in "$@"; do
[ "$comp" == build ] && _cabal_list "executable|test-suite|benchmark" && break
[ "$comp" == repl ] && _cabal_list "executable|test-suite|benchmark" && break
[ "$comp" == run ] && _cabal_list "executable" && break
[ "$comp" == test ] && _cabal_list "test-suite" && break
[ "$comp" == bench ] && _cabal_list "benchmark" && break
done
}
# List possible subcommands of a cabal subcommand.
...
...
@@ -87,7 +87,7 @@ _cabal()
cmd[${COMP_CWORD}]="--list-options"
# the resulting completions should be put into this array
COMPREPLY=( $( compgen -W "$( ${cmd[@]} ) $( _cabal_targets ${cmd[@]} ) $( _cabal_subcommands ${COMP_WORDS[@]} )" -- $cur ) )
COMPREPLY=( $( compgen -W "$(
eval "
${cmd[@]}
" 2>/dev/null
) $( _cabal_targets
"
${cmd[@]}
"
) $( _cabal_subcommands
"
${COMP_WORDS[@]}
"
)" --
"
$cur
"
) )
}
complete -F _cabal -o default cabal
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment