From 2c1e1cc748ed9029be26769caed9b3d7b35f10de Mon Sep 17 00:00:00 2001 From: Tom Jorquera Date: Wed, 10 May 2017 19:32:03 +0200 Subject: [PATCH 1/5] bin/dev.sh: Improve shell detection Shell detection used hardcoded paths that made it fail when using distributions using a different scheme (e.g. debian-based distros). Improve shell detection by using a glob-based comparison, where we do not assume any specific path leading to the shell binary. --- bin/dev.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/dev.sh b/bin/dev.sh index 7c24b2b..7320dae 100755 --- a/bin/dev.sh +++ b/bin/dev.sh @@ -16,19 +16,21 @@ echo "alias memopol-launch=\"memopol-code && memopol runserver\"" >> $ALIASROOT echo "alias memopol-update-all=\"memopol-code && bin/update-all\"" >> $ALIASROOT echo "alias memopol-refresh-scores=\"memopol-code && memopol refresh_scores\"" >> $ALIASROOT -if [ $SHELL = "/bin/bash" ] -then +case $SHELL in +*/bash) echo "Bash detected" echo "Update $HOME/.bashrc file" - RCSHELL="$HOME/.bashrc" -elif [ $SHELL = "/bin/zsh" ] -then - echo "Zsh detected" - echo "Update $HOME/.zshrc file" - RCSHELL="$HOME/.zshrc" -else + RCSHELL="$HOME/.bashrc" + ;; +*/zsh) + echo "Zsh detected" + echo "Update $HOME/.zshrc file" + RCSHELL="$HOME/.zshrc" + ;; +*) echo "SHELL don't supported. Try using BASH or ZSH, or manually." -fi + ;; +esac echo "source $ALIASROOT" >> $RCSHELL source $ALIASROOT -- GitLab From d7bdb9b31c56bff1a2a6170d3f9ded61918d7ede Mon Sep 17 00:00:00 2001 From: Tom Jorquera Date: Wed, 10 May 2017 20:54:47 +0200 Subject: [PATCH 2/5] bin/dev: set RCSHELL to /dev/null on default case When no shell is detected, set `RCSHELL` variable to point to /dev/null. This avoid weird error messages. --- bin/dev.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/dev.sh b/bin/dev.sh index 7320dae..9d325a3 100755 --- a/bin/dev.sh +++ b/bin/dev.sh @@ -29,6 +29,7 @@ case $SHELL in ;; *) echo "SHELL don't supported. Try using BASH or ZSH, or manually." + RCSHELL="/dev/null" ;; esac -- GitLab From c8ad26c7bf4ea8ffce223349b7d74966c46161c5 Mon Sep 17 00:00:00 2001 From: Tom Jorquera Date: Wed, 10 May 2017 19:41:32 +0200 Subject: [PATCH 3/5] bin/dev.sh: fix `memopol-update-all` alias `memopol-update-all` was not working due to a typo in its definition. Fixed. --- bin/dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/dev.sh b/bin/dev.sh index 9d325a3..950ac69 100755 --- a/bin/dev.sh +++ b/bin/dev.sh @@ -13,7 +13,7 @@ echo $ALIASROOT echo "Create a dedicated alias file in $ALIASROOT" echo "alias memopol-code=\"cd $REPOROOT && source $REPOROOT/memopol_env/bin/activate && DJANGO_DEBUG=True\"" > $ALIASROOT echo "alias memopol-launch=\"memopol-code && memopol runserver\"" >> $ALIASROOT -echo "alias memopol-update-all=\"memopol-code && bin/update-all\"" >> $ALIASROOT +echo "alias memopol-update-all=\"memopol-code && bin/update_all\"" >> $ALIASROOT echo "alias memopol-refresh-scores=\"memopol-code && memopol refresh_scores\"" >> $ALIASROOT case $SHELL in -- GitLab From db44b8d390105b9a6f7b0a0525812af3a1e9603a Mon Sep 17 00:00:00 2001 From: Tom Jorquera Date: Wed, 10 May 2017 19:37:00 +0200 Subject: [PATCH 4/5] bin/dev.sh: Improve informational messages to user Fix typos, correct grammar and clarify some instructions in user messages. --- bin/dev.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/dev.sh b/bin/dev.sh index 950ac69..ee36d13 100755 --- a/bin/dev.sh +++ b/bin/dev.sh @@ -28,7 +28,7 @@ case $SHELL in RCSHELL="$HOME/.zshrc" ;; *) - echo "SHELL don't supported. Try using BASH or ZSH, or manually." + echo "SHELL not supported. Try using BASH or ZSH, or set alias manually." RCSHELL="/dev/null" ;; esac @@ -40,5 +40,5 @@ source $ALIASROOT echo -e "You can use the following aliases :\n" echo -e "\t memopol-code : Go into the repository and activate the virtualenv" echo -e "\t memopol-launch : Run the development server" -echo -e "\t memopoll-update-all : Get all the production data" +echo -e "\t memopol-update-all : Get all the production data" echo -e "\t memopol-refresh-scores : Refresh all scores" -- GitLab From 6ee07d6facb83014acccb33d036ff52b55661ba6 Mon Sep 17 00:00:00 2001 From: Tom Jorquera Date: Wed, 10 May 2017 21:02:11 +0200 Subject: [PATCH 5/5] bin/dev: Fix memopol-code alias Fix `memopol-code` alias so that the env variable `DJANGO_DEBUG` is actually exported. --- bin/dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/dev.sh b/bin/dev.sh index ee36d13..52cabd5 100755 --- a/bin/dev.sh +++ b/bin/dev.sh @@ -11,7 +11,7 @@ REPOROOT="$( readlink -m "${BASH_SOURCE[0]}"/../..)" ALIASROOT=$REPOROOT"/.memopol.alias" echo $ALIASROOT echo "Create a dedicated alias file in $ALIASROOT" -echo "alias memopol-code=\"cd $REPOROOT && source $REPOROOT/memopol_env/bin/activate && DJANGO_DEBUG=True\"" > $ALIASROOT +echo "alias memopol-code=\"cd $REPOROOT && source $REPOROOT/memopol_env/bin/activate && export DJANGO_DEBUG=True\"" > $ALIASROOT echo "alias memopol-launch=\"memopol-code && memopol runserver\"" >> $ALIASROOT echo "alias memopol-update-all=\"memopol-code && bin/update_all\"" >> $ALIASROOT echo "alias memopol-refresh-scores=\"memopol-code && memopol refresh_scores\"" >> $ALIASROOT -- GitLab