Bug#697207: ack-grep: Bash completion broken

Smylers Smylers at stripey.com
Wed Jan 2 16:05:43 UTC 2013


Package: ack-grep
Version: 1.96-2
Severity: normal
Tags: patch

The Bash completion for types doesn't work properly when the command is
called ack-grep rather than ack.

While the bug is upstream, it only affects Debian systems (since the
command is called ack-grep elsewhere). 

If the Bash failglob option is enabled, this bug causes Bash to display
an error message in every new shell (unless the current directory
happens to contain a file called O... or P... or similar).

There's a patch here:
https://github.com/Smylers/ack/commit/c0f8871ecb5baa533b8900d5b27b9eed041e660d

Hopefully an upstream release will be made including it, but since the
problem only crops up on Debian it would be nice to get the fix into
Debian ASAP anyway.

Cheers

Smylers

-- System Information:
Debian Release: wheezy/sid
  APT prefers quantal-updates
  APT policy: (500, 'quantal-updates'), (500, 'quantal-security'), (500, 'quantal-proposed'), (500, 'quantal'), (100, 'quantal-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.5.0-21-generic (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages ack-grep depends on:
ii  libfile-next-perl  1.10-1
ii  perl               5.14.2-13ubuntu0.1

ack-grep recommends no packages.

Versions of packages ack-grep suggests:
ii  bash-completion  1:2.0-1ubuntu2

-- Configuration Files:
/etc/bash_completion.d/ack-grep changed:
type ack &>/dev/null || type ack-grep &>/dev/null && {
__ack_types=$( (ack-grep --help=types 2>/dev/null || ack --help=types 2>/dev/null) | \
  perl -ne 'print "$1 no$1 " if /^\s+--\[no\](\S+)\s+/' 2>/dev/null)
__ack_typeopts=""
for type in $__ack_types ; do
  __ack_typeopts="${__ack_typeopts} --${type}"
done
_ack() {
  local lngopt shtopt clropt
  local cur prev
  COMPREPLY=()
  cur=$(_get_cword "=")
  prev="${COMP_WORDS[COMP_CWORD-1]}"
  _expand || return 0
  # these options are final
  if [[ ${COMP_WORDS[@]} == *+([[:space:]])--@(help|man|th+([pt])+(t)|version)+([[:space:]])* ]] ; then
    return 0
  fi
  lngopt='
    --after-context=
    --all-types
    --before-context=
    --break
    --nobreak
    --color
    --nocolor
    --colour
    --nocolour
    --color-filename=
    --color-match=
    --column
    --context=
    --count
    --env
    --noenv
    --files-with-matches
    --files-without-matches
    --flush
    --follow
    --nofollow
    --group
    --nogroup
    --heading
    --noheading
    --ignore-case
    --ignore-dir=
    --noignore-dir=
    --invert-match
    --line=
    --literal
    --match
    --max-count=
    --no-filename
    --output=
    --pager=
    --nopager
    --passthru
    --print0
    --recurse
    --norecurse
    --rc=
    --smart-case
    --nosmart-case
    --sort-files
    --type=
    --type-add
    --type-set
    --unrestricted
    --with-filename
    --word-regexp
  '
  fnlopt='
    --help
    --man
    --thpppt
    --version
  '
  shtopt='
    -a -A -B -C -c
    -f -G -g -H -h
    -i -l -L -m -n
    -o -Q -r -R -u
    -v -w -1
  '
  clropt='
    clear
    reset
    dark
    bold
    underline
    underscore
    blink
    reverse
    concealed
    black
    red
    green
    yellow
    blue
    magenta
    on_black
    on_red
    on_green
    on_yellow
    on_blue
    on_magenta
    on_cyan
    on_white
  '
  # these options require an argument
  if [[ "${prev}" == -@(A|B|C|G|g|-match) ]] ; then
    return 0
  fi
  case "${cur}" in
    --?*=*)
          _split_longopt || return 0
          case "${prev}" in
            --?(no)ignore-dir) # directory completion
                      _filedir -d
                      return 0;;
            --pager) # command completion
                      COMPREPLY=( $(compgen -c -- "${cur}") )
                      return 0;;
                      --rc) # file completion
                      _filedir
                      return 0;;
            --color-@(filename|match)) # color completion
                      COMPREPLY=( $(compgen -W "${clropt}" -- "${cur}") )
                      return 0;;
            --type) # type completion
                      COMPREPLY=( $(compgen -W "${__ack_types}" -- "${cur}") )
                      return 0;;
          esac;;
    -*)
          # -a and -u negate the use of type options
          if [[ " ${COMP_WORDS[@]} " == *" -a "* || " ${COMP_WORDS[@]} " == *" -u "* ]] ; then
            if [[ "${COMP_CWORD}" -eq 1 ]] ; then
              COMPREPLY=( $(compgen -W \
                "${lngopt} ${shtopt} ${fnlopt}" -- "${cur}") )
            else
              COMPREPLY=( $(compgen -W \
                "${lngopt} ${shtopt}" -- "${cur}") )
            fi
          else
            if [[ "${COMP_CWORD}" -eq 1 ]] ; then
              COMPREPLY=( $(compgen -W \
                "${lngopt} ${shtopt} ${fnlopt} ${__ack_typeopts}" -- "${cur}") )
            else
              COMPREPLY=( $(compgen -W \
                "${lngopt} ${shtopt} ${__ack_typeopts}" -- "${cur}") )
            fi
          fi
          return 0;;
    *)
          if [[ " ${COMP_WORDS[@]} " == *" -f "* ]] ; then
            _filedir -d
          elif [[ "${prev}" != -* ]] ; then
            _filedir
          fi
          return 0;;
  esac
}
complete -F _ack ${nospace} ack
complete -F _ack ${nospace} ack-grep
}


-- no debconf information



More information about the pkg-perl-maintainers mailing list