22
33# Author: jules randolph <[email protected] > https://github.com/jsamr44# License: MIT
5- # Version 1.2
5+ # Version v1.2.1
66#
77# Usage: [<options>...] <file.iso>
88#
@@ -188,15 +188,18 @@ parseOptions() {
188188 display_help
189189 exit 1
190190 fi
191+ if [ -d " $selectedIsoFile " ]; then
192+ failAndExit " Provided file \` $selectedIsoFile ' is a directory."
193+ fi
191194 if [ ! -f " $selectedIsoFile " ]; then
192- failAndExit " Provided iso file \` $selectedIsoFile ' does not exists or is a directory ."
195+ failAndExit " Provided iso file \` $selectedIsoFile ' does not exists."
193196 fi
194197}
195198
196199checkPackages () (
197200 checkpkg () {
198201 if [[ $( which " $1 " ) == " " ]]; then
199- echo -n " Package '$1 ' not found!"
202+ echowarn -n " Package '$1 ' not found!"
200203 if [[ ! $pkgmgr == " " ]]; then
201204 read -r -n1 -p " Attempt installation? (y/n)>" answer
202205 echo
@@ -206,7 +209,7 @@ checkPackages() (
206209 n)
207210 read -r -n1 -p " Proceed anyway? (y/n)>" answer2
208211 echo
209- if [[ " $answer2 " == " n" ]] ; then exit
212+ if [[ " $answer2 " == " n" ]] ; then exit 1
210213 fi
211214 ;;
212215 esac
@@ -265,7 +268,7 @@ selectDrive() {
265268 }
266269 chooseDrive () {
267270 echo " Select the device corresponding to the USB device you want to make bootable (${drives[*]} ). Type exit to quit."
268- read -r -p " Select device name >" _selectedDrive
271+ read -r -p " Select device id >" _selectedDrive
269272 if containsElement " $_selectedDrive " " ${drives[@]} " ; then
270273 selectedDrive=" /dev/$_selectedDrive "
271274 else
@@ -284,16 +287,14 @@ selectDrive() {
284287 lsblk | grep --color=never -e ' ^[sh]'
285288 chooseDrive
286289 else
287- if [[ " $selectedDrive " =~ " /dev" ]]; then
288- if [ -e " $selectedDrive " ]; then
289- if [[ " $selectedDrive " =~ /dev/[a-zA-Z]+[0-9]+ ]]; then
290- failAndExit " \` $selectedDrive ' is a partition. Select a drive instead."
291- fi
292- else
293- failAndExit " The device $selectedDrive does not exists"
294- fi
295- else
296- failAndExit " The selected device is not a valid posix device file (should start with \` /dev')"
290+ if [ ! -e " $selectedDrive " ]; then
291+ failAndExit " The device $selectedDrive does not exists"
292+ fi
293+ if [ ! -b " $selectedDrive " ]; then
294+ failAndExit " The selected device \` $selectedDrive ' is not a valid block file."
295+ fi
296+ if [[ " $selectedDrive " =~ [a-zA-Z]+[0-9]+$ ]]; then
297+ failAndExit " \` $selectedDrive ' is a partition. Select a drive instead."
297298 fi
298299 fi
299300}
0 commit comments