Blame | Letzte Änderung | Log anzeigen | RSS feed
# This file is part of the Symfony package.## (c) Fabien Potencier <fabien@symfony.com>## For the full copyright and license information, please view# https://symfony.com/doc/current/contributing/code/license.html_sf_{{ COMMAND_NAME }}() {# Use newline as only separator to allow space in completion valuesIFS=$'\n'local sf_cmd="${COMP_WORDS[0]}"# for an alias, get the real script behind itsf_cmd_type=$(type -t $sf_cmd)if [[ $sf_cmd_type == "alias" ]]; thensf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")elif [[ $sf_cmd_type == "file" ]]; thensf_cmd=$(type -p $sf_cmd)fiif [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; thenreturn 1filocal cur prev words cword_get_comp_words_by_ref -n := cur prev words cwordlocal completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-a{{ VERSION }}")for w in ${words[@]}; dow=$(printf -- '%b' "$w")# remove quotes from typed valuesquote="${w:0:1}"if [ "$quote" == \' ]; thenw="${w%\'}"w="${w#\'}"elif [ "$quote" == \" ]; thenw="${w%\"}"w="${w#\"}"fi# empty values are ignoredif [ ! -z "$w" ]; thencompletecmd+=("-i$w")fidonelocal sfcompleteif sfcomplete=$(${completecmd[@]} 2>&1); thenlocal quote suggestionsquote=${cur:0:1}# Use single quotes by default if suggestions contains backslash (FQCN)if [ "$quote" == '' ] && [[ "$sfcomplete" =~ \\ ]]; thenquote=\'fiif [ "$quote" == \' ]; then# single quotes: no additional escaping (does not accept ' in values)suggestions=$(for s in $sfcomplete; do printf $'%q%q%q\n' "$quote" "$s" "$quote"; done)elif [ "$quote" == \" ]; then# double quotes: double escaping for \ $ ` "suggestions=$(for s in $sfcomplete; dos=${s//\\/\\\\}s=${s//\$/\\\$}s=${s//\`/\\\`}s=${s//\"/\\\"}printf $'%q%q%q\n' "$quote" "$s" "$quote";done)else# no quotes: double escapingsuggestions=$(for s in $sfcomplete; do printf $'%q\n' $(printf '%q' "$s"); done)fiCOMPREPLY=($(IFS=$'\n' compgen -W "$suggestions" -- $(printf -- "%q" "$cur")))__ltrim_colon_completions "$cur"elseif [[ "$sfcomplete" != *"Command \"_complete\" is not defined."* ]]; then>&2 echo>&2 echo $sfcompletefireturn 1fi}complete -F _sf_{{ COMMAND_NAME }} {{ COMMAND_NAME }}