This file is indexed.

/etc/bash_completion.d/condor is in htcondor 8.6.8~dfsg.1-2.

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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
__get_condor_pool_name()
{
  local pool_idx
  # Find the pool name.
  pool_idx=1
  while [ $pool_idx -le $prev_idx ]; do
    if [[ "${COMP_WORDS[$pool_idx]}" == -p* ]] ; then
      pool=${COMP_WORDS[$(($pool_idx+1))]}
      break
    fi
    pool_idx=$(( $pool_idx + 1 ))
  done
  if [ $pool_idx -ge $COMP_CWORD ]; then
    pool=`condor_config_val COLLECTOR_HOST 2>/dev/null`
  fi
  #echo "Detected pool name ${pool} at idx $pool_idx (comp cword $COMP_CWORD)"
}

__is_autoformat() {
  local idx arg in_af
  idx=1
  in_af=0
  while [ $idx -le $COMP_CWORD ]; do
      arg="${COMP_WORDS[$idx]}"
      if [ $in_af -eq 1 ]; then
        if [[ "${arg}" == -* ]]; then
          in_af=0
        fi
      fi
      if [ "${arg}" == "-af" ] ; then
        in_af=1
      fi
      if [ "${arg}" == "-autoformat" ] ; then
        in_af=1
      fi
      idx=$(( $idx + 1 ))
  done
  return $in_af
}

__contains() {
  local e
  for e in "${@:2}"; do [[ "$1" == $e ]] && return 0; done
  return 1
}

__get_status_query_type()
{
  local idx arg istype query_types
  query_types=( "-sta*" "-sc*" "-subm*" "-gr*" "-ge*" "-col*" "-def*" "-ma*" "-ne*" "-sto" "-an*" )
  idx=1
  query_type=-startd
  while [ $idx -lt $COMP_CWORD ]; do
      arg="${COMP_WORDS[$idx]}"
      __contains "${arg}" ${query_types[@]}
      istype=$?
      if [ $istype -eq 0 ] ; then
        query_type=${arg}
        #echo "Query type is ${arg}"
        return 0
      fi
      idx=$(( $idx + 1 ))
  done

  idx=1
  while [ $idx -le $prev_idx ]; do
    if [[ "${COMP_WORDS[$idx]}" == -subs* ]] ; then
      query_type="-subsystem ${COMP_WORDS[$(($idx+1))]}"
      #echo "Subsystem query type is $query_type"
      return 0
    fi
    idx=$(( $idx + 1 ))
  done

  #echo "Query type is ${query_type}"
}

_condor_submit()
{
  local cur prev_idx prev pool
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev_idx=$(( $COMP_CWORD - 1))
  prev="${COMP_WORDS[$prev_idx]}"

  __get_condor_pool_name
  
  case "${prev}" in
    -ap*|-q*|-b*|-m*|-ad*|-pa*)
      return 0
      ;;
    -d*)
      _filedir
      return 0
      ;;
    -n*|-r*)
      COMPREPLY=( $(compgen -W "$(condor_status -pool $pool -schedd -af Name 2>/dev/null)" -- "${cur}") )
      return 0
      ;;
    -po*)
      _known_hosts_real -- "${cur}"
      return 0
      ;;
    # I doubt this option is actually functional...
    -st*)
      COMPREPLY=( $(compgen -W "stm_use_schedd_only stm_use_transferd" -- "${cur}") )
      return 0
      ;;
  esac
  case "${cur}" in
    -*)
      COMPREPLY=( $(compgen -W "-terse -verbose -debug -help -append -queue -batch-name -disable -dry-run -maxjobs -single-cluster -unused -dump -interactive -name -remote -addr -spool -password -pool -stm" -- "${cur}") )
      ;;
  esac
  _filedir
}

_condor_config_val()
{
  local cur prev_idx prev pool
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev_idx=$(( $COMP_CWORD - 1))
  prev="${COMP_WORDS[$prev_idx]}"

  __get_condor_pool_name
  __get_status_query_type
  
  case "${prev}" in
    -po*)
      _known_hosts_real -- "${cur}"
      return 0
      ;;
    -n*)
      COMPREPLY=( $(compgen -W "$(condor_status -pool $pool $query_type -af Name 2>/dev/null)" -- "${cur}") )
      return 0
      ;;
    -w*)
      _filedir
      return 0
      ;;
    -su*)
      COMPREPLY=( $(compgen -W "TOOL SCHEDD NEGOTIATOR STARTD MASTER SHADOW STARTER GAHP DAGMAN SHARED_PORT SUBMIT JOB DAEMON" -- "${cur}") )
      return 0
      ;;
    -a*|-l*|-se*|-uns*|-rs*|-ru*)
      return 0
      ;;
  esac 
  case "${cur}" in
    -*)
      COMPREPLY=( $(compgen -W "-help -version -negotiator -collector -startd -master -schedd -name -pool -address -subsystem -local-name -mixedcase -writeconfig -config -unused -used -evaluate -debug -verbose -raw -expand -default -dump -runset -rset -unset -set" -- "${cur}") )
      ;;
    *)
      COMPREPLY=( $(compgen -W "$(condor_config_val -dump 2>/dev/null | grep -v '^#' | awk '{print $1;}')" -- "${cur}") )
      ;;
  esac
}

_condor_act()
{
  local cur prev_idx prev pool
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev_idx=$(( $COMP_CWORD - 1))
  prev="${COMP_WORDS[$prev_idx]}"

  __get_condor_pool_name

  case "${prev}" in
    -po*)
      _known_hosts_real -- "${cur}"
      return 0
      ;;
    -n*)
      # Suggest one of the available schedds
      COMPREPLY=( $(compgen -W "$(condor_status -pool $pool -schedd -af Name 2>/dev/null)" -- "${cur}") )
      return 0
      ;;
    -a*|-r*|-c*|-s*)
      return 0
      ;;
  esac
  case "${cur}" in
    -*)
      COMPREPLY=( $(compgen -W "-help -version -long -totals -name -pool -addr -constraint -all" -- "${cur}") )
      case "${COMP_WORDS[0]}" in
        condor_hold)
          COMPREPLY+=( $(compgen -W "-subcode -reason" -- "${cur}" ) )
          ;;
        condor_rm)
          COMPREPLY+=( $(compgen -W "-forcex -reason" -- "${cur}" ) )
          ;;
        condor_release)
          COMPREPLY+=( $(compgen -W "-reason" -- "${cur}" ) )
          ;;
      esac
      ;;
    *)
      COMPREPLY=( $(compgen -W "$(condor_status -pool $pool -const 'IdleJobs+RunningJobs+HeldJobs>0' -submitter -af Name 2>/dev/null | tr '@' ' ' | awk '{print $1;}' | tr '.' ' ' | awk '{print $NF;}' | sort | uniq)" -- "${cur}") )
      COMPREPLY+=( $(compgen -W "$(condor_q -format '%d.' ClusterId -format '%d\n' ProcId)" -- "${cur}" ) )
  esac
}

_condor_history()
{
  local cur prev_idx prev pool
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev_idx=$(( $COMP_CWORD - 1))
  prev="${COMP_WORDS[$prev_idx]}"

  __is_autoformat
  if [ $? -eq 1 ]; then
    return 0
  fi

  __get_condor_pool_name

  case "${prev}" in
    -po*)
      _known_hosts_real -- "${cur}"
      return 0
      ;;
    -n*)
      # Suggest one of the available schedds
      COMPREPLY=( $(compgen -W "$(condor_status -pool $pool -schedd -af Name 2>/dev/null)" -- "${cur}") )
      return 0
      ;;
    -fi*|-u*|-print-format)
      _filedir
      return 0
      ;;
    -li*|-m*|-f*)
      return 0
      ;;
  esac
  case "${cur}" in
    -*)
      COMPREPLY=( $(compgen -W "-file -userlog -name -pool -help -backwards -forwards -limit -match -long -wide -format -autoformat -print-format" -- "${cur}") )
      return 0
      ;;
  esac
}

_condor_status()
{
  local cur prev_idx prev pool
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev_idx=$(( $COMP_CWORD - 1))
  prev="${COMP_WORDS[$prev_idx]}"

  __is_autoformat
  if [ $? -eq 1 ]; then
    return 0
  fi

  __get_condor_pool_name
  __get_status_query_type

  case "${prev}" in
    -dir*)
      COMPREPLY=( $(compgen -W "$(condor_status -pool $pool $query_type -af Name 2>/dev/null)" -- "${cur}") )
      return 0
      ;;
    -po*)
      _known_hosts_real -- "${cur}"
      return 0
      ;;
    -subs*)
      COMPREPLY=( $(compgen -W "schedd collector negotiator startd master grid generic" -- "${cur}") )
      return 0
      ;;
    -ad*|-print-format)
      _filedir
      return 0
      ;;
    -so*|-con*|stati*)
      return 0
      ;;
  esac
  case "${cur}" in
    -*)
      # Some days, it seems like there are too many flags for condor_status...
      COMPREPLY=( $(compgen -W "-help -version -diagnose -absent -avail -ckptsrvr -claimed -cod -collector -debug -defrag -direct -java -vm -license -master -pool -ads -grid -run -schedd -server -startd -generic -subsystem -negotiator -storage -any -state -submitters -constraint -compact -statistics -target -long -xml -total -sort -natural -total -expert -wide -xml -attributes -format -autoformat -print-format" -- "${cur}") )
      ;;
    *)
      # Suggest one of the available slots
      COMPREPLY=( $(compgen -W "$(condor_status -pool $pool $query_type -af Name 2>/dev/null)" -- "${cur}") )
      return 0
      ;;
  esac
}

_condor_q()
{
  local cur prev_idx prev pool
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev_idx=$(( $COMP_CWORD - 1))
  prev="${COMP_WORDS[$prev_idx]}"

  __is_autoformat
  if [ $? -eq 1 ]; then
    return 0
  fi

  __get_condor_pool_name

  # Find out if we requested all users.
  allusers=1
  if [ "`condor_config_val CONDOR_Q_ONLY_MY_JOBS`" = true ]; then
    idx=1
    allusers=0
    while [ $idx -lt $COMP_CWORD ]; do
      arg="${COMP_WORDS[$idx]}"
      idx=$(( $idx + 1 ))
      if [[ ${arg} == -all* ]] ; then
        allusers=1
      fi
    done
  fi
  #echo "Value of allusers: $allusers"

  # Handle cases where we are in an option's argument
  case "${prev}" in
    -p*)
      _known_hosts_real -- "${cur}"
      return 0
      ;;
    -n*)
      # Suggest one of the available schedds
      COMPREPLY=( $(compgen -W "$(condor_status -pool $pool -schedd -af Name 2>/dev/null)" -- "${cur}") )
      return 0
      ;;
    -su*)
      COMPREPLY=( $(compgen -W "$(condor_status -pool $pool -const 'IdleJobs+RunningJobs+HeldJobs>0' -submitter -af Name 2>/dev/null | tr '@' ' ' | awk '{print $1;}' | tr '.' ' ' | awk '{print $NF;}' | sort | uniq)" -- "${cur}") )
      return 0
      ;;
    -u*|-slot*|-job*|-print-format)
      # Suggest a filename for the -userlog argument.
      _filedir
      return 0
      ;;
    -co*|-mco*|-li*|-fo*|-at*|-schedd-constraint)
      return 0
      ;;
  esac
  case "${cur}" in
    -*)
      COMPREPLY=( $(compgen -W "-attributes -long -xml -constraint -cputime -currentrun -expert -globus -goodput -hold -io -batch -nobatch -run -stream-results -wide -autoformat -debug -help -version -global -schedd-constraint -submitter -name -pool -jobads -userlog -autocluster -allusers -totals -analyze -better-analyze -machine -mconstraint -slotads -userprios -nouserprios -reverse -verbose" -- "${cur}") )
      return 0
      ;;
    *)
      # Suggest one of the available users
      if [ $allusers -eq 1 ]; then
        COMPREPLY=( $(compgen -W "$(condor_status -pool $pool -const 'IdleJobs+RunningJobs+HeldJobs>0' -submitter -af Name 2>/dev/null | tr '@' ' ' | awk '{print $1;}' | tr '.' ' ' | awk '{print $NF;}' | sort | uniq)" -- "${cur}") )
      fi
      COMPREPLY+=( $(compgen -W "$(condor_q -format '%d.' ClusterId -format '%d\n' ProcId)" -- "${cur}" ) )
      return 0
      ;;
  esac
}

complete -F _condor_q condor_q
complete -F _condor_status condor_status
complete -F _condor_history condor_history
complete -F _condor_submit condor_submit
complete -F _condor_config_val condor_config_val
complete -F _condor_act condor_rm
complete -F _condor_act condor_hold
complete -F _condor_act condor_release
complete -F _condor_act condor_suspend
complete -F _condor_act condor_continue