Skip to content

Commit 2e247b6

Browse files
committed
Remove destination folder existence check and only create it when the path contains slash(s)
1 parent 8eb77fc commit 2e247b6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bin/git-cp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ else
4242
echo 1>&2 "$DESTINATION_FILENAME is not a file path."
4343
exit 80
4444
fi
45-
DESTINATION_DIR="${DESTINATION_FILENAME%/*}"
46-
if [ ! -d "$DESTINATION_DIR" ]; then
45+
if [[ "$DESTINATION_FILENAME" = */* ]]; then
46+
DESTINATION_DIR="${DESTINATION_FILENAME%/*}"
4747
if ! mkdir -p "$DESTINATION_DIR"; then
4848
echo 1>&2 "Failed to create destination directory: $DESTINATION_DIR"
4949
exit 160

0 commit comments

Comments
 (0)