Skip to content

Commit

Permalink
Replace subshell command with builtin operation to infer DESTINATION_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
weiw005 committed Oct 20, 2023
1 parent b867455 commit 8eb77fc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bin/git-cp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ else
exit 40
fi

DESTINATION_DIR="$(dirname "$DESTINATION_FILENAME")"
if [[ "$DESTINATION_FILENAME" == */ ]]; then
echo 1>&2 "$DESTINATION_FILENAME is not a file path."
exit 80
fi
DESTINATION_DIR="${DESTINATION_FILENAME%/*}"
if [ ! -d "$DESTINATION_DIR" ]; then
echo "Creating destination directory: $DESTINATION_DIR"
mkdir -p "$DESTINATION_DIR"
if [ $? -ne 0 ]; then
if ! mkdir -p "$DESTINATION_DIR"; then
echo 1>&2 "Failed to create destination directory: $DESTINATION_DIR"
exit 80
exit 160
fi
fi

Expand Down

0 comments on commit 8eb77fc

Please sign in to comment.