From 2ee1e1a1744c4d0679058124eb7ceba78a0a5a84 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Sat, 23 Mar 2019 08:56:44 -0700 Subject: [PATCH] Fixed #30283 -- Fixed shellcheck warnings in django_bash_completion. --- AUTHORS | 2 +- extras/django_bash_completion | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6fed0a63cd..01908ad6c9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -31,7 +31,7 @@ answer newbie questions, and generally made Django that much better: Akshesh Doshi alang@bright-green.com Alasdair Nicol - Albert Wang + Albert Wang Alcides Fonseca Aleksandra Sendecka Aleksi Häkli diff --git a/extras/django_bash_completion b/extras/django_bash_completion index dfeefe4939..3c2f14c263 100755 --- a/extras/django_bash_completion +++ b/extras/django_bash_completion @@ -43,13 +43,11 @@ _python_django_completion() { if [[ ${COMP_CWORD} -ge 2 ]]; then local PYTHON_EXE=${COMP_WORDS[0]##*/} - echo $PYTHON_EXE | egrep "python([3-9]\.[0-9])?" >/dev/null 2>&1 - if [[ $? == 0 ]]; then + if echo "$PYTHON_EXE" | grep -qE "python([3-9]\.[0-9])?"; then local PYTHON_SCRIPT=${COMP_WORDS[1]##*/} - echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1 - if [[ $? == 0 ]]; then - COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \ - COMP_CWORD=$(( COMP_CWORD-1 )) \ + if echo "$PYTHON_SCRIPT" | grep -qE "manage\.py|django-admin(\.py)?"; then + COMPREPLY=( $( COMP_WORDS=( "${COMP_WORDS[*]:1}" ) + COMP_CWORD=$(( COMP_CWORD-1 )) DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) ) fi fi @@ -64,7 +62,7 @@ if command -v whereis &>/dev/null; then [[ $python != *-config ]] && pythons="${pythons} ${python##*/}" done unset python_interpreters - pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ") + pythons=$(echo "$pythons" | tr " " "\n" | sort -u | tr "\n" " ") else pythons=python fi