This file is indexed.

/etc/bash_completion.d/ocamlfind is in ocaml-findlib 1.2.7+debian-1build3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Debian GNU/Linux ocamlfind(1) completion
# Copyright 2005
#  Stefano Zacchiroli <zack@debian.org>
# License: GNU GPL v2 or later

# inter function communication is achieved via the $_ocamlfind_reply environment
# variable, it will be unset each time the completion is used

have ocamlfind &&
_ocamlfind_add()
{
  _ocamlfind_reply="$_ocamlfind_reply $1"
}

[ "$have" ] &&
_ocamlfind_flags()
{
  local cmd res
  cmd="$1"
  res="$( ocamlfind $cmd --help 2>/dev/null | \
    grep '^  -' | sed 's/ *//;s/ .*//' )"
  _ocamlfind_add "$res"
}

[ "$have" ] &&
_ocamlfind_packages()
{
  local pkglist oldpkglist res
  oldpkglist="$1"
  pkglist=$( ocamlfind list | cut -f 1 -d' ' )
  if echo "$oldpkglist" | grep -q ','; then
    oldpkglist=$(echo $oldpkglist | sed 's/\(.*,\).*/\1/')
    res=""
    for pkg in $pkglist; do
      res="$res $oldpkglist$pkg"
    done
  else
    res="$pkglist"
  fi
  _ocamlfind_add "$res"
}

[ "$have" ] &&
_ocamlfind()
{
  local cmd cur prev

  COMPREPLY=()
  cmd=${COMP_WORDS[1]}
  cur=${COMP_WORDS[COMP_CWORD]}
  prev=${COMP_WORDS[COMP_CWORD-1]}
  _ocamlfind_reply=""

  if [ $COMP_CWORD -eq 1 ]; then
    _ocamlfind_add "query ocamlc ocamlcp ocamlmktop ocamlopt ocamldep \
      ocamlbrowser ocamldoc install remove printconf list opt --help"
    # TODO missing "pkg/cmd arg ..." completion
  elif [ $COMP_CWORD -gt 1 ]; then
    [ "$prev" = "-package" ] || _ocamlfind_flags "$cmd"
    case "$cmd" in
      ocamlc|ocamlcp|ocamlmktop|ocamlopt|ocamldep|ocamldoc|opt)
	if [ "$prev" = "-package" ]; then
	  _ocamlfind_packages "$cur"
	fi
	;;
    esac
    case "$cmd" in
      ocamlc|ocamlcp)
	_ocamlfind_add "$( ls *.mli *.ml *.cmo *.cma *.c *.o *.a 2> /dev/null )"
	;;
      ocamlopt|opt)
	_ocamlfind_add "$( ls *.mli *.ml *.cmx *.cmxa *.c *.o *.a 2> /dev/null )"
	;;
      ocamlmktop)
	_ocamlfind_add "$( ls *.cmo *.cma *.o *.a 2> /dev/null )"
	;;
    esac
    if [ "$cmd" = "query" ]; then _ocamlfind_packages ""; fi
    if [ "$cmd" = "printconf" -a $COMP_CWORD -eq 2 ]; then
      _ocamlfind_add "$( ocamlfind printconf --help | grep '|' | \
	sed 's/.*(//;s/)//;s/|/ /g' )"
    fi
  fi
  COMPREPLY=( $(compgen -W "$_ocamlfind_reply" -- $cur) )
  unset _ocamlfind_reply
  return 0
}

[ "$have" ] &&
complete -F _ocamlfind ocamlfind

# vim:set ft=sh: