From 4433d04f1eb3cfe9b531745279cb96a1cebad39d Mon Sep 17 00:00:00 2001 From: Christopher Arndt Date: Fri, 14 Jun 2019 11:04:00 +0200 Subject: [PATCH] Fix several problems in install.sh * Fix shell syntax in 'xdg' and 'DIRECTORY' variable definitions. * Fix check whether theme file already exists to look at destination not source file. * Quote 'answer' shell variable. * Install themes with proper file permissions. * Make indentation consistent. Signed-off-by: Christopher Arndt --- install.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index ee69fcd..da06cd0 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -xdg=${${XDG_DATA_HOME}:-${HOME}/.local/share} -DIRECTORY="${xdg}/rofi/themes/}" +xdg="${XDG_DATA_HOME:-${HOME}/.local/share}" +DIRECTORY="${xdg}/rofi/themes" if [ ! -d "${DIRECTORY}" ] then @@ -10,26 +10,26 @@ then fi declare -i ia=0 -for themefile in **/*.rasi +for themefile in **/*.rasi do - if [ -f "${themefile}" ] && [ ${ia} -eq 0 ] + if [ -f "${DIRECTORY}/${themefile##*/}" ] && [ ${ia} -eq 0 ] then - echo "Theme '${themefile}' exists, overwrite? y/N/a(ll)" + echo -n "Theme '${DIRECTORY}/${themefile##*/}' exists, overwrite? y/N/a(ll) " read answer - if [ x$answer = x"y" ] + if [ "x$answer" = x"y" ] then echo "+Installing '${themefile}'" - install "${themefile}" "${DIRECTORY}" - elif [ x${answer} = x"a" ] + install -m 644 "${themefile}" "${DIRECTORY}" + elif [ "x${answer}" = x"a" ] then ia=1 echo "+Installing '${themefile}'" - install "${themefile}" "${DIRECTORY}" + install -m 644 "${themefile}" "${DIRECTORY}" else echo "+Skipping ${themefile}" - fi + fi else - echo "+Installing '${themefile}'" - install "${themefile}" "${DIRECTORY}" + echo "+Installing '${themefile}'" + install -m 644 "${themefile}" "${DIRECTORY}" fi done