Skip to content

Commit 8eb77fc

Browse files
committed
Replace subshell command with builtin operation to infer DESTINATION_DIR
1 parent b867455 commit 8eb77fc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

bin/git-cp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ else
3838
exit 40
3939
fi
4040

41-
DESTINATION_DIR="$(dirname "$DESTINATION_FILENAME")"
41+
if [[ "$DESTINATION_FILENAME" == */ ]]; then
42+
echo 1>&2 "$DESTINATION_FILENAME is not a file path."
43+
exit 80
44+
fi
45+
DESTINATION_DIR="${DESTINATION_FILENAME%/*}"
4246
if [ ! -d "$DESTINATION_DIR" ]; then
43-
echo "Creating destination directory: $DESTINATION_DIR"
44-
mkdir -p "$DESTINATION_DIR"
45-
if [ $? -ne 0 ]; then
47+
if ! mkdir -p "$DESTINATION_DIR"; then
4648
echo 1>&2 "Failed to create destination directory: $DESTINATION_DIR"
47-
exit 80
49+
exit 160
4850
fi
4951
fi
5052

0 commit comments

Comments
 (0)