From 2a78b2bffa2dd9d23ab306c2671c0a7273af6410 Mon Sep 17 00:00:00 2001 From: Chris Piro Date: Wed, 9 Nov 2011 16:37:32 -0800 Subject: [PATCH] bash completion: work around PHP CLI readline in command substitution Summary: (At least my build of) PHP tries to do readline magic on the terminal when invoked from the shell, even inside bash's command substitution operator. Work around it by piping the output of ##echo## to ##php##, so the input isn't a terminal. Test Plan: ##bash$ arc li## now gives me possible completions rather than breaking and inserting a literal tab Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: 1096 --- resources/shell/bash-completion | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/resources/shell/bash-completion b/resources/shell/bash-completion index c87230d8..e431064f 100644 --- a/resources/shell/bash-completion +++ b/resources/shell/bash-completion @@ -1,24 +1,22 @@ -_arc() +_arc () { - CUR="${COMP_WORDS[COMP_CWORD]}" COMPREPLY=() - OPTS=$(arc shell-complete --current ${COMP_CWORD} -- ${COMP_WORDS[@]}) - + OPTS=$(echo | arc shell-complete --current ${COMP_CWORD} -- ${COMP_WORDS[@]}) + if [ $? -ne 0 ]; then return $? fi - + if [ "$OPTS" = "FILE" ]; then COMPREPLY=( $(compgen -f -- ${CUR}) ) return 0 fi - + if [ "$OPTS" = "ARGUMENT" ]; then return 0 fi - - COMPREPLY=( $(compgen -W "${OPTS}" -- ${CUR}) ) + COMPREPLY=( $(compgen -W "${OPTS}" -- ${CUR}) ) } complete -F _arc -o filenames arc -- 2.43.0