mirror of
https://github.com/89luca89/distrobox.git
synced 2026-08-19 01:14:49 -05:00
install: add check for dest_path, ask for creation if it does not exist #177
This commit is contained in:
@@ -74,9 +74,33 @@ if [ "${verbose}" -ne 0 ]; then
|
|||||||
set -o xtrace
|
set -o xtrace
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure the foundamental variables are set and not empty, we will not proceed if
|
# Ensure we can write the dest_path specified
|
||||||
# they are not all set.
|
[ ! -w "$(dirname "${dest_path}")" ] && printf >&2 "Cannot write into %s, permission denied.\n" "${dest_path}" && exit 1
|
||||||
[ ! -w "${dest_path}" ] && printf >&2 "Cannot write into %s, permission denied.\n" "${dest_path}" && exit 1
|
# Ensure dest_path exists
|
||||||
|
if [ ! -d "${dest_path}" ]; then
|
||||||
|
printf >&2 "Path %s not found.\n" "${dest_path}"
|
||||||
|
printf >&2 "Do you want to create it now? [Y/n]: "
|
||||||
|
read -r response
|
||||||
|
response="${response:-"Y"}"
|
||||||
|
# Accept only y,Y,Yes,yes,n,N,No,no.
|
||||||
|
case "${response}" in
|
||||||
|
y | Y | Yes | yes | YES)
|
||||||
|
if ! mkdir -p "${dest_path}"; then
|
||||||
|
printf >&2 "Cannot write into %s, permission denied.\n" "${dest_path}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
n | N | No | no | NO)
|
||||||
|
printf >&2 "next time, create %s first\n" "${dest_path}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*) # Default case: If no more options then break out of the loop.
|
||||||
|
printf >&2 "Invalid input.\n"
|
||||||
|
printf >&2 "The available choices are: y,Y,Yes,yes,YES or n,N,No,no,NO.\nExiting.\n"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
man_dest_path="${dest_path}/../share/man/man1"
|
man_dest_path="${dest_path}/../share/man/man1"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user