Skip to content

Commit 23bf9f4

Browse files
committed
Use $SUDO when calling 'which' (if appropriate)
1 parent 6690130 commit 23bf9f4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

format-udf.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ fi
384384
# ensure have required drive info tool
385385
echo -n "[+] Looking for drive info tool..."
386386
# `true` is so that a failure here doesn't cause entire script to exit prematurely
387-
TOOL_BLOCKDEV=$(which blockdev 2>/dev/null) || true
387+
TOOL_BLOCKDEV=$($SUDO which blockdev 2>/dev/null) || true
388388
# `true` is so that a failure here doesn't cause entire script to exit prematurely
389389
TOOL_IOREG=$(which ioreg 2>/dev/null) || true
390390
if [[ -x "$TOOL_BLOCKDEV" ]]; then
@@ -402,7 +402,7 @@ echo " using $TOOL_DRIVE_INFO"
402402
# ensure have required drive listing tool
403403
echo -n "[+] Looking for drive listing tool..."
404404
# `true` is so that a failure here doesn't cause entire script to exit prematurely
405-
TOOL_BLOCKDEV=$(which blockdev 2>/dev/null) || true
405+
TOOL_BLOCKDEV=$($SUDO which blockdev 2>/dev/null) || true
406406
# `true` is so that a failure here doesn't cause entire script to exit prematurely
407407
TOOL_DISKUTIL=$(which diskutil 2>/dev/null) || true
408408
if [[ -x "$TOOL_BLOCKDEV" ]]; then
@@ -420,7 +420,7 @@ echo " using $TOOL_DRIVE_LISTING"
420420
# ensure have required drive summary tool
421421
echo -n "[+] Looking for drive summary tool..."
422422
# `true` is so that a failure here doesn't cause entire script to exit prematurely
423-
TOOL_BLKID=$(which blkid 2>/dev/null) || true
423+
TOOL_BLKID=$($SUDO which blkid 2>/dev/null) || true
424424
if [[ -x "$TOOL_BLKID" ]]; then
425425
TOOL_DRIVE_SUMMARY=$TOOL_BLKID
426426
echo " using $TOOL_DRIVE_SUMMARY"
@@ -433,9 +433,9 @@ fi
433433
# ensure have required unmount tool
434434
echo -n "[+] Looking for unmount tool..."
435435
# `true` is so that a failure here doesn't cause entire script to exit prematurely
436-
TOOL_UMOUNT=$(which umount 2>/dev/null) || true
436+
TOOL_UMOUNT=$($SUDO which umount 2>/dev/null) || true
437437
# `true` is so that a failure here doesn't cause entire script to exit prematurely
438-
TOOL_DISKUTIL=$(which diskutil 2>/dev/null) || true
438+
TOOL_DISKUTIL=$($SUDO which diskutil 2>/dev/null) || true
439439
# prefer 'diskutil' if available, as it's required on macOS (even if 'umount' is present)
440440
if [[ -x "$TOOL_DISKUTIL" ]]; then
441441
TOOL_UNMOUNT=$TOOL_DISKUTIL
@@ -452,9 +452,9 @@ echo " using $TOOL_UNMOUNT"
452452
# ensure have required UDF tool
453453
echo -n "[+] Looking for UDF tool..."
454454
# `true` is so that a failure here doesn't cause entire script to exit prematurely
455-
TOOL_MKUDFFS=$(which mkudffs 2>/dev/null) || true
455+
TOOL_MKUDFFS=$($SUDO which mkudffs 2>/dev/null) || true
456456
# `true` is so that a failure here doesn't cause entire script to exit prematurely
457-
TOOL_NEWFS_UDF=$(which newfs_udf 2>/dev/null) || true
457+
TOOL_NEWFS_UDF=$($SUDO which newfs_udf 2>/dev/null) || true
458458
if [[ -x "$TOOL_MKUDFFS" ]]; then
459459
TOOL_UDF=$TOOL_MKUDFFS
460460
elif [[ -x "$TOOL_NEWFS_UDF" ]]; then

0 commit comments

Comments
 (0)