Advertisement
Guest User

Untitled

a guest
Aug 16th, 2014
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.72 KB | None | 0 0
  1. _reply_compgen_array()
  2. {
  3.     # Create the argument for compgen -W by escaping twice.
  4.     #
  5.     # One round of escape is because we want to reply with escaped arguments. A
  6.     # second round is required because compgen -W will helpfully expand it's
  7.     # argument.
  8.     local i wlist
  9.     echo ${COMPREPLY}
  10.     for i in ${!COMPREPLY[*]}; do
  11.         local q=$(quote "$(printf %q "${COMPREPLY[$i]}")")
  12.         wlist+=$q$'\n'
  13.     done
  14.  
  15.     # We also have to add another round of escaping to $cur.
  16.     local ecur="$cur"
  17.     ecur="${ecur//\\/\\\\}"
  18.     ecur="${ecur//\'/\'}"
  19.  
  20.     # Actually generate completions.
  21.     local oldifs=$IFS
  22.     IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)'
  23.     IFS=$oldifs
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement