diff --git a/idd.sh b/idd.sh index 44d5aa8..8d2d521 100755 --- a/idd.sh +++ b/idd.sh @@ -30,6 +30,20 @@ Options(){ printf "${BWHITE}[Q]${NC} - Quit\n" } +CheckFile(){ + if [ ! -f "${1}" ];then + printf "${LRED}${1} is not a valid file path${NC}\n" + exit 0; + fi +} + +CheckDev(){ + if [ ! -b "${1}" ];then + printf "${LRED}${1} is not a valid block device${NC}\n" + exit 0; + fi +} + Quit(){ if [ "${1}" = "q" ];then echo @@ -63,6 +77,7 @@ case "$1" in printf "${YELLOW}Copy & paste full file path here: ${NC}" read filepath + CheckFile ${filepath} Quit ${filepath} clear Options @@ -74,6 +89,8 @@ case "$1" in echo printf "${YELLOW}Enter name of device${NC} (${LCYAN}example${NC}, ${LBLUE}sdb${NC}): " read devname + DEVPATH="${DEVICEDIR}/${devname}" + CheckDev ${DEVPATH} Quit ${devname} echo @@ -109,6 +126,7 @@ case "$1" in printf "${YELLOW}Copy & paste full file path here: ${NC}" read filepath + CheckFile ${filepath} Quit ${filepath} @@ -122,6 +140,9 @@ case "$1" in echo printf "${YELLOW}Enter name of device${NC} (${LCYAN}example${NC}, ${LBLUE}sdb${NC}): " read devname + + DEVPATH="${DEVICEDIR}/${devname}" + CheckDev ${DEVPATH} Quit ${devname} echo