Minor fixes and better error handling

pull/692/head
Arijit Basu 4 months ago
parent 80d5512e41
commit ab86ccb833
No known key found for this signature in database
GPG Key ID: 0F8EF5258DC38077

@ -1495,8 +1495,9 @@ xplr.config.modes.builtin.quick_move = {
"$XPLR" -m 'LogError: %q' "could not create $DEST"
exit
fi
cd -- "$DEST" && pwd
"$XPLR" -m "ChangeDirectory: %q" "$DEST"
! cd -- "$DEST" && exit
DEST="$(pwd)"
while IFS= read -r -d '' PTH; do
PTH_ESC=$(printf %q "$PTH")
BASENAME=$(basename -- "$PTH")
@ -1517,11 +1518,11 @@ xplr.config.modes.builtin.quick_move = {
;;
esac
fi
if mv -v -- "${PTH:?}" "./${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC moved to $BASENAME_ESC"
if mv -v -- "${PTH:?}" "$DEST/${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC moved to $DEST/$BASENAME_ESC"
"$XPLR" -m 'FocusPath: %q' "$BASENAME"
else
"$XPLR" -m 'LogError: %q' "could not move $PTH_ESC to $BASENAME_ESC"
"$XPLR" -m 'LogError: %q' "could not move $PTH_ESC to $DEST/$BASENAME_ESC"
fi
done < "${XPLR_PIPE_RESULT_OUT:?}"
echo
@ -1565,15 +1566,16 @@ xplr.config.modes.builtin.quick_copy = {
"$XPLR" -m 'LogError: %q' "could not create $DEST"
exit
fi
cd -- "$DEST" && pwd
"$XPLR" -m "ChangeDirectory: %q" "$DEST"
! cd -- "$DEST" && exit
DEST="$(pwd)"
while IFS= read -r -d '' PTH; do
PTH_ESC=$(printf %q "$PTH")
BASENAME=$(basename -- "$PTH")
BASENAME_ESC=$(printf %q "$BASENAME")
if [ -e "$BASENAME" ]; then
echo
echo "$BASENAME_ESC exists, do you want to overwrite it?"
echo "$DEST/$BASENAME_ESC exists, do you want to overwrite it?"
read -p "[y]es, [n]o, [S]kip: " ANS < /dev/tty
case "$ANS" in
[yY]*)
@ -1587,11 +1589,11 @@ xplr.config.modes.builtin.quick_copy = {
;;
esac
fi
if cp -vr -- "${PTH:?}" "./${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC copied to $BASENAME_ESC"
if cp -vr -- "${PTH:?}" "$DEST/${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC copied to $DEST/$BASENAME_ESC"
"$XPLR" -m 'FocusPath: %q' "$BASENAME"
else
"$XPLR" -m 'LogError: %q' "could not copy $PTH_ESC to $BASENAME_ESC"
"$XPLR" -m 'LogError: %q' "could not copy $PTH_ESC to $DEST/$BASENAME_ESC"
fi
done < "${XPLR_PIPE_RESULT_OUT:?}"
echo

Loading…
Cancel
Save