From 57df46c3ff259d460f066eb45847a96250b55b7e Mon Sep 17 00:00:00 2001 From: Nathan Farrant-Diaz Date: Wed, 8 Jun 2016 11:14:59 -0400 Subject: [PATCH] proper bash styling on all scripts --- scripts/apex-to-file | 6 +++--- scripts/check_conf_file.sh | 22 +++++++++++----------- scripts/new-conf-file | 28 ++++++++++++++-------------- scripts/read-conf-file | 4 ++-- scripts/uninstall-apex | 4 ++-- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/scripts/apex-to-file b/scripts/apex-to-file index 014046c..26e813f 100755 --- a/scripts/apex-to-file +++ b/scripts/apex-to-file @@ -1,4 +1,4 @@ # designed to be called from frontrunner script -script_folder=$(dirname $0) -$script_folder/check_conf_file.sh || exit 1 -$script_folder/apexupdate.sh || exit 1 +script_folder=$(dirname "${0}") +"${script_folder}"/check_conf_file.sh || exit 1 +"${script_folder}"/apexupdate.sh || exit 1 diff --git a/scripts/check_conf_file.sh b/scripts/check_conf_file.sh index 0dca3eb..a964028 100755 --- a/scripts/check_conf_file.sh +++ b/scripts/check_conf_file.sh @@ -3,7 +3,7 @@ # This script is designed to be run from the top level directory of your project and will break if called from anywhere else if [ ! -e ./config/asc.conf ]; then - echo "Missing or broken symbolic link: $PWD/config/asc.conf" + echo "Missing or broken symbolic link: ${PWD}/config/asc.conf" echo "Please use the command 'npm run switch-conf-file' to create the symbolic link ./config/asc.conf to your config file" echo "If you don't have a config file set up you can create one using 'npm run new-config-file'" exit 1 @@ -13,24 +13,24 @@ echo "Using the config file at: $(readlink config/asc.conf)" source ./config/asc.conf -if [ -z "$apexappid" ]; then - echo "Missing config: $apexappid apexappid"; exit 1 +if [ -z "${apexappid}" ]; then + echo "Missing config: ${apexappid} apexappid"; exit 1 fi -if [ -z "$workspace_name" ]; then - echo "Missing config: $workspace_name workspace_name"; exit 1 +if [ -z "${workspace_name}" ]; then + echo "Missing config: ${workspace_name} workspace_name"; exit 1 fi -if [ -z "$database_connection" ]; then - echo "Missing config: $database_connection database_connection"; exit 1 +if [ -z "${database_connection}" ]; then + echo "Missing config: ${database_connection} database_connection"; exit 1 fi -if [ -z "$username" ]; then - echo "Missing config: $username username"; exit 1 +if [ -z "${username}" ]; then + echo "Missing config: ${username} username"; exit 1 fi -if [ -z "$password" ]; then - echo "Missing config: $password password"; exit 1 +if [ -z "${password}" ]; then + echo "Missing config: ${password} password"; exit 1 fi echo "Config file looks good! Moving on to the next step..." diff --git a/scripts/new-conf-file b/scripts/new-conf-file index b646fd3..7dad97e 100755 --- a/scripts/new-conf-file +++ b/scripts/new-conf-file @@ -6,12 +6,12 @@ echo "Creating new config file..." echo -n "Please enter the file name of your config file: " read conf_file -if [ -z $conf_file ]; then +if [ -z "${conf_file}" ]; then echo "Please input a value for your config file name before pressing enter"; exit 1 fi -if [ -e ./config/$conf_file ]; then - echo "Sorry, the file ./scripts/$conf_file already exists. Either delete the existing file or choose a different name and try again."; exit 1 +if [ -e ./config/"${conf_file}" ]; then + echo "Sorry, the file ./scripts/${conf_file} already exists. Either delete the existing file or choose a different name and try again."; exit 1 fi echo -n "Please enter the apexappid you would like to use. This should be chosen very carefully to avoid conflicts with other developers' app ids: " @@ -40,31 +40,31 @@ if [ ! -d ./config/ ]; then mkdir config fi -echo "apexappid=$apexappid" > ./config/$conf_file -echo "workspace_name=$workspace_name" >> ./config/$conf_file -echo "parsing_schema=$parsing_schema" >> ./config/$conf_file -echo "app_alias=$app_alias" >> ./config/$conf_file -echo "database_connection=$database_connection" >> ./config/$conf_file -echo "username=$username" >> ./config/$conf_file -echo "password=$password" >> ./config/$conf_file +echo "apexappid=${apexappid}" > ./config/"${conf_file}" +echo "workspace_name=${workspace_name}" >> ./config/"${conf_file}" +echo "parsing_schema=${parsing_schema}" >> ./config/"${conf_file}" +echo "app_alias=${app_alias}" >> ./config/"${conf_file}" +echo "database_connection=${database_connection}" >> ./config/"${conf_file}" +echo "username=${username}" >> ./config/"${conf_file}" +echo "password=${password}" >> ./config/"${conf_file}" echo "Config file successfully generated! It looks like this:" -cat ./config/$conf_file +cat ./config/"${conf_file}" -echo "If anything looks wrong you can simply edit the file yourself at ./config/$conf_file" +echo "If anything looks wrong you can simply edit the file yourself at ./config/${conf_file}" echo echo -n "Would you like to switch to the new config file now [y/n]: " read switch_bool -if [ $switch_bool == "y" ]; then +if [ "${switch_bool}" == "y" ]; then cd config if [ -h asc.conf ]; then rm asc.conf fi - ln -s $conf_file asc.conf + ln -s "${conf_file}" asc.conf cd .. echo "./config/asc.conf now points to ./config/$( readlink ./config/asc.conf )" else diff --git a/scripts/read-conf-file b/scripts/read-conf-file index ca75132..3e0bed6 100755 --- a/scripts/read-conf-file +++ b/scripts/read-conf-file @@ -1,7 +1,7 @@ # designed to be called from to level project dir -if [ ! -h ./config/asc.conf ]; then - echo "Missing symbolic link: $PWD/config/asc.conf" +if [ ! -e ./config/asc.conf ]; then + echo "Missing or broken symbolic link: ${PWD}/config/asc.conf" echo "Please use the command 'npm run switch-conf-file' to create the symbolic link ./config/asc.conf to your config file" echo "If you don't have a config file set up you can create one using 'npm run new-config-file'" exit 1 diff --git a/scripts/uninstall-apex b/scripts/uninstall-apex index cbbb28f..98dedcd 100755 --- a/scripts/uninstall-apex +++ b/scripts/uninstall-apex @@ -1,5 +1,5 @@ # designed to be called from frontrunner script script_folder=$(dirname $0) -$script_folder/check_conf_file.sh || exit 1 +"${script_folder}"/check_conf_file.sh || exit 1 source config/asc.conf || exit 1 -sqlplus $username/$password@$database_connection @$script_folder/uninstall_apex.sql $apexappid $workspace_name $parsing_schema || exit 1 +sqlplus "${username}"/"${password}"@"${database_connection}" @"${script_folder}"/uninstall_apex.sql "${apexappid}" "${workspace_name}" "${parsing_schema}" || exit 1