Skip to content

Commit

Permalink
Fix return codes
Browse files Browse the repository at this point in the history
  • Loading branch information
HanabishiRecca committed Apr 5, 2023
1 parent e22bac2 commit a8ea75c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions caches-manager
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ shopt -s nullglob dotglob

# $1: target directory
backup() {
[ -e "$1" ] || return
[ -e "$1" ] || return 0
echo -n "target exists, backing up... "
mv -T --backup=numbered "$1" "$1.bak"
}
Expand Down Expand Up @@ -44,7 +44,7 @@ make_bind() {
# $2: target directory
make_link() {
if [ -L "$2" ]; then
[ "$(readlink "$2")" == "$1" ] && return
[ "$(readlink "$2")" == "$1" ] && return 0
else
backup "$2"
fi
Expand All @@ -71,17 +71,17 @@ create_cache() {

if [ ! -d "${parent}" ]; then
echo "parent directory does not exist, skip."
return
return 0
fi

if [ ! -w "${parent}" ]; then
echo "no write access to parent directory, skip."
return
return 0
fi

if mountpoint -q "${dir}"; then
echo "mount point found, skip."
return
return 0
fi

if [ "$3" == "b" ]; then
Expand Down Expand Up @@ -116,7 +116,7 @@ read_config() {

# $1: configs directory
read_configs_from() {
[ -d "$1" ] || return
[ -d "$1" ] || return 0

for f in "$1/"*.conf; do
read_config "${f}"
Expand Down

0 comments on commit a8ea75c

Please sign in to comment.