1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-06-30 19:07:11 -07:00

squash some shellcheck warnings

This commit is contained in:
Connor Olding 2021-01-06 20:53:34 +01:00
parent 4e4941aa68
commit 26445bf490

18
install
View File

@ -16,10 +16,10 @@ die() {
} }
dotless() { dotless() {
local f="$1" local f="$1" ind len
local ind="$(expr index "$f" .)" ind="$(expr index "$f" .)"
if [ "$ind" -gt 0 ]; then if [ "$ind" -gt 0 ]; then
local len="$(expr length "$f")" len="$(expr length "$f")"
REPLY="$(expr substr "$f" 2 "$len")" REPLY="$(expr substr "$f" 2 "$len")"
else else
REPLY="$1" REPLY="$1"
@ -67,7 +67,7 @@ softlink_pseudo() {
mkdir "$1" || die "couldn't mkdir $1" mkdir "$1" || die "couldn't mkdir $1"
fi fi
ls -A "$2" | while read -r REPLY; do find "$2" -maxdepth 1 | while read -r REPLY; do
local d1="$1/$REPLY" local d1="$1/$REPLY"
local d2="$2/$REPLY" local d2="$2/$REPLY"
if [ -d "$d2" ]; then if [ -d "$d2" ]; then
@ -83,7 +83,7 @@ softlink_pseudo() {
fi fi
done done
ls -A "$1" | while read -r REPLY; do find "$2" -maxdepth 1 | while read -r REPLY; do
local d1="$1/$REPLY" local d1="$1/$REPLY"
local d2="$2/$REPLY" local d2="$2/$REPLY"
if [ -d "$d2" ]; then if [ -d "$d2" ]; then
@ -113,7 +113,7 @@ softlink() {
which readlink >/dev/null || exit 1 # sanity check which readlink >/dev/null || exit 1 # sanity check
rc="$(readlink -f "$(dirname "$0")" )" rc="$(readlink -f "$(dirname "$0")" )"
cd "$HOME" cd "$HOME" || exit 1
backup_dir="$rc/backup-$(date -u '+%s')" backup_dir="$rc/backup-$(date -u '+%s')"
@ -149,7 +149,11 @@ is_empty() {
# but you might still want to remove this if you're adapting my install script. # but you might still want to remove this if you're adapting my install script.
for d in Desktop Documents Downloads Music Pictures Public Templates Video Videos; do for d in Desktop Documents Downloads Music Pictures Public Templates Video Videos; do
[ -d "$d" ] || continue [ -d "$d" ] || continue
is_empty "$d" && rm -r "$d" || note "not removing $d because it contains files" if is_empty "$d"; then
rm -r "$d"
else
note "not removing $d because it contains files"
fi
done done
# create instead my preferred directory structure. # create instead my preferred directory structure.