haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.63k stars 696 forks source link

fix « cabal »'s bash-completion #5927

Open sboosali opened 5 years ago

sboosali commented 5 years ago
  1. lint with shellcheck:
$ shellcheck ./cabal/cabal-install/bash-completion/cabal

^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang.

In cabal line 108:
    cmd=( ${COMP_WORDS[@]} )
          ^--------------^ SC2206: Quote to prevent word splitting, or split robustly with mapfile or read -a.

In cabal line 114:
    COMPREPLY=( $( compgen -W "$( eval "${cmd[@]}" 2>/dev/null ) $( _cabal_targets "${cmd[@]}" ) $( _cabal_subcommands "${COMP_WORDS[@]}" )" -- "$cur" ) )
                ^-- SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting, ...
  https://www.shellcheck.net/wiki/SC2207 -- Prefer mapfile or read -a to spli...
  1. silence warnings:

e.g.:

$ cabal new-build<TAB>

$ cabal new-build grep: ./*.cabal: No such file or directory

without nullglob, if a glob-pattern fails, it becomes a literal (i.e. the string with an asterix, rather than an empty string; e.g. is "./*.cabal", should be "") ).

this is important because cabal.project both supports and encourages a "megarepo" style where packages are in subdirectories.

sboosali commented 5 years ago

cleanup commit: https://github.com/haskell/cabal/pull/6023

(just wanted to get this in before the 3.0 release)