1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-03 04:02:42 +01:00
phorge-arcanist/support/shell/templates/bash-template.sh
epriestley afcaeea9c3 [Wilds] Shell complete files with spaces in them correctly
Summary: Fixes T9116. Ref T13098. Fix shell completion handling of filenames with spaces in them. This is a big mess -- see T9116 for discussion and I'll walk through things below.

Test Plan:
These all now seem to do the right thing:

```
arc we<tab> -> arc weld (+space)
arc weld fo<tab> -> arc weld foo\ bar (+space)
arc weld 'fo<tab> -> arc weld 'foo bar' (+space)
arc weld src<tab> -> arc weld src/ (no space)
arc weld src/w<tab> -> arc weld src/work (no space)
arc weld src/work<tab><tab> -> suggests "workflow/", "workingcopy/"
arc shell-complete --gen<tab> -> arc shell-complete --generate
```

These also work, which I think is nice-to-have:

```
arc WEL<tab> -> arc weld
arc shell-complete --GEN<tab> -> arc shell-complete --generate
```

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13098, T9116

Differential Revision: https://secure.phabricator.com/D19705
2018-09-25 16:15:51 -07:00

22 lines
441 B
Bash

_arcanist_complete_{{{BIN}}} ()
{
COMPREPLY=()
RESULT=$(echo | {{{BIN}}} shell-complete \
--current ${COMP_CWORD} \
-- \
"${COMP_WORDS[@]}" \
2>/dev/null)
if [ $? -ne 0 ]; then
return $?
fi
if [ "$RESULT" == "<compgen:file>" ]; then
RESULT=$( compgen -A file -- ${COMP_WORDS[COMP_CWORD]} )
fi
local IFS=$'\n'
COMPREPLY=( $RESULT )
}
complete -F _arcanist_complete_{{{BIN}}} -o filenames {{{BIN}}}