1 _dmd_opts="$(dmd --help 2>&1 | sed -n 's/^\s*\(-\+\w*=*-*\).*/\1/p' | \
2 sed 's/filename\|docdir\|directory\|path\|linkerflag\|objdir//g')"
3 _ld_opts_dmd="$(ld --help 2>&1 | sed -n 's/.*\(--[-a-z0-9]\{1,\}\).*/-L\1/p')"
4 _env_vars_dmd="$(printenv | cut -d = -f 1 | sort -u)"
9 cur=$(echo "${cur}" | sed 's:^'${1}'::')
10 if test "${2}" == "(*)" ;then
18 for I in ${COMPREPLY[@]}
21 COMPREPLY[${J}]="${1}${I}/"
23 COMPREPLY[${J}]="${1}${I}"
28 if test ${F} -eq 1 -a ${J} -eq 1 ;then
38 _get_comp_words_by_ref -n = cur
42 -L-L*) # match linker paths
44 _filedir_dmd "-L-L" "(/)"
46 -L--*) # match linker options
47 COMPREPLY=( $( compgen -W "${_ld_opts_dmd}" -- ${cur} ) )
49 -L*) # match linker options
50 local opts=$(echo -e "-L-L\n-L--")
51 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
53 -*) # match dmd options
55 if [[ "${cur}" == "-Dd"* ]] ;then
56 _filedir_dmd "-Dd" "(/)"
57 elif [[ "${cur}" == "-Df"* ]] ;then
58 _filedir_dmd "-Df" "(*)"
59 elif [[ "${cur}" == "-debug="* ]] ;then
61 elif [[ "${cur}" == "-debuglib="* ]] ;then
64 if [ ${#COMPREPLY[@]} -eq 1 ] && [ -f ${COMPREPLY[@]} ] ;then
67 elif [[ "${cur}" == "-defaultlib="* ]] ;then
70 if [ ${#COMPREPLY[@]} -eq 1 ] && [ -f ${COMPREPLY[@]} ] ;then
73 elif [[ "${cur}" == "-deps="* ]] ;then
76 if [ ${#COMPREPLY[@]} -eq 1 ] && [ -f ${COMPREPLY[@]} ] ;then
79 elif [[ "${cur}" == "-Hd"* ]] ;then
80 _filedir_dmd "-Hd" "(/)"
81 elif [[ "${cur}" == "-Hf"* ]] ;then
82 _filedir_dmd "-Hf" "(*)"
83 elif [[ "${cur}" == "-I"* ]] ;then
84 _filedir_dmd "-I" "(/)"
85 elif [[ "${cur}" == "-J"* ]] ;then
86 _filedir_dmd "-J" "(/)"
87 elif [[ "${cur}" == "-od"* ]] ;then
88 _filedir_dmd "-od" "(/)"
89 elif [[ "${cur}" == "-of"* ]] ;then
90 _filedir_dmd "-of" "(*)"
91 elif [[ "${cur}" == "-version="* ]] ;then
93 elif [[ "${cur}" == "-Xf"* ]] ;then
94 _filedir_dmd "-Xf" "(*)"
96 COMPREPLY=( $(compgen -W "${_dmd_opts}" -- ${cur}) )
98 L=$(echo -e "-cov${C}-fPIC${C}-gc${C}--help${C}-ignore\
99 ${C}-inline${C}-lib${C}-m32${C}-m64${C}-man${C}-map\
100 ${C}-noboundscheck${C}-nofloat${C}-O${C}-o-${C}-op\
101 ${C}-profile${C}-property${C}-quiet${C}-release\
102 ${C}-run${C}-unittest${C}-vtls${C}-wi" | sed 's: ::g')
103 if test ${#COMPREPLY[@]} -eq 1 ;then
106 if test "${COMPREPLY[@]}" == "$I" ; then
113 @*) # match arguments variable/file
115 TMP=( $(compgen -W "${_env_vars_dmd}" -P "@" -- ${cur#@}) )
116 _filedir_dmd "@" "(*)"
117 COMPREPLY=( "${TMP[@]}" "${COMPREPLY[@]}" )
118 if test ${#COMPREPLY[@]} -eq 1 ;then compopt +o nospace ; fi
121 _filedir '@(d|dd|di|o|a|/)'