Skip to content

Commit 86a1acd

Browse files
committed
Target must already exist %5
1 parent 94f0d4d commit 86a1acd

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

sync.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ script_name="$(basename "${BASH_SOURCE[0]}")"
3535
# Collect and validate absolute paths for each target.
3636
targets=()
3737
for t; do
38-
mkdir -p "$t" # create target if missing
39-
abs_t="$(cd "$t" && pwd -P)" # resolve to canonical absolute path
38+
# Must already exist as a directory
39+
if [[ ! -d $t ]]; then
40+
echo "Error: '$t' does not exist or is not a directory" >&2
41+
exit 1
42+
fi
43+
44+
# resolve to canonical absolute path
45+
abs_t="$(cd "$t" && pwd -P)"
4046

4147
# Guard against syncing into a sub-directory of the template itself.
4248
if [[ $abs_t == "$script_dir"* ]]; then
43-
echo "Error: target $abs_t is inside template dir $script_dir" >&2
49+
echo "Error: '$t' is inside template dir $script_dir" >&2
4450
exit 1
4551
fi
4652

0 commit comments

Comments
 (0)