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 <chris@chrisarndt.de>
This commit is contained in:
Christopher Arndt 2019-06-14 11:04:00 +02:00
parent 7018be3e6e
commit 4433d04f1e

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
xdg=${${XDG_DATA_HOME}:-${HOME}/.local/share} xdg="${XDG_DATA_HOME:-${HOME}/.local/share}"
DIRECTORY="${xdg}/rofi/themes/}" DIRECTORY="${xdg}/rofi/themes"
if [ ! -d "${DIRECTORY}" ] if [ ! -d "${DIRECTORY}" ]
then then
@ -10,26 +10,26 @@ then
fi fi
declare -i ia=0 declare -i ia=0
for themefile in **/*.rasi for themefile in **/*.rasi
do do
if [ -f "${themefile}" ] && [ ${ia} -eq 0 ] if [ -f "${DIRECTORY}/${themefile##*/}" ] && [ ${ia} -eq 0 ]
then then
echo "Theme '${themefile}' exists, overwrite? y/N/a(ll)" echo -n "Theme '${DIRECTORY}/${themefile##*/}' exists, overwrite? y/N/a(ll) "
read answer read answer
if [ x$answer = x"y" ] if [ "x$answer" = x"y" ]
then then
echo "+Installing '${themefile}'" echo "+Installing '${themefile}'"
install "${themefile}" "${DIRECTORY}" install -m 644 "${themefile}" "${DIRECTORY}"
elif [ x${answer} = x"a" ] elif [ "x${answer}" = x"a" ]
then then
ia=1 ia=1
echo "+Installing '${themefile}'" echo "+Installing '${themefile}'"
install "${themefile}" "${DIRECTORY}" install -m 644 "${themefile}" "${DIRECTORY}"
else else
echo "+Skipping ${themefile}" echo "+Skipping ${themefile}"
fi fi
else else
echo "+Installing '${themefile}'" echo "+Installing '${themefile}'"
install "${themefile}" "${DIRECTORY}" install -m 644 "${themefile}" "${DIRECTORY}"
fi fi
done done