@@ -309,7 +309,7 @@ function term_printLog() {
309
309
function term_indentAll() {
310
310
while read -r line; do
311
311
term_printColumn " " " $term_logPrefixLength " " $line "
312
- done < " ${1:-/ dev/ stdin} "
312
+ done < " ${1:-/ dev/ stdin} "
313
313
}
314
314
315
315
# $*: The message to print.
@@ -423,29 +423,15 @@ function fs_findFileFromPatterns() {
423
423
424
424
function fs_createTempFile() {
425
425
local -r _prefix=$1
426
- local _tmpFileTemplate=" $ct_tempRoot /$_prefix -XXX" _status
427
- mktemp " $_tmpFileTemplate "
428
- _status=$?
429
- if [ ! $_status -eq 0 ]; then
430
- ps_failAndExit IO_ERROR " Failed to create temporary file."
431
- fi
426
+ local _tmpFileTemplate=" $ct_tempRoot /$_prefix -XXX"
427
+ mktemp " $_tmpFileTemplate " || ps_failAndExit IO_ERROR " Failed to create temporary file."
432
428
}
433
429
# Print the name of the new folder if operation
434
430
# succeeded, fails otherwise.
435
431
#
436
432
# $1 - The folder name prefix
437
433
function fs_createMountFolder() {
438
- local _tmpFileTemplate _status
439
- if (( EUID == 0 )) ; then
440
- _tmpFileTemplate=" $ct_mountRoot /$1 -XXX"
441
- else
442
- _tmpFileTemplate=" $ct_tempRoot /$1 -XXX"
443
- fi
444
- mktemp -d " $_tmpFileTemplate "
445
- _status=$?
446
- if [ ! $_status -eq 0 ]; then
447
- ps_failAndExit IO_ERROR " Failed to create temporary mount point with pattern '$_tmpFileTemplate '."
448
- fi
434
+ mktemp -d " $ct_mountRoot /$1 -XXX" || ps_failAndExit IO_ERROR " Failed to create temporary mount point with pattern '$_tmpFileTemplate '."
449
435
}
450
436
451
437
function fs_syncdev() {
@@ -494,15 +480,15 @@ function fs_mountUSB() {
494
480
st_usbMountPoint=$( fs_createMountFolder usb) || exit " $? "
495
481
st_temporaryAssets+=(" $st_usbMountPoint " )
496
482
term_echoinfo " Created USB device mount point at '$st_usbMountPoint '"
497
- if ! mount -t " $_type " " $st_targetPartition " " $st_usbMountPoint " > /dev/null; then
483
+ if ! mount -t " $_type " " $st_targetPartition " " $st_usbMountPoint " > /dev/null; then
498
484
ps_failAndExit IO_ERROR " Could not mount USB device."
499
485
fi
500
486
}
501
487
502
488
# $1 - mountPoint
503
489
function fs_mountElToritoFile() {
504
490
local -r _mountPoint=" $1 "
505
- if ! mount -r -o loop -- " $sourceImageFile " " $_mountPoint " > /dev/null; then
491
+ if ! mount -r -o loop -- " $sourceImageFile " " $_mountPoint " > /dev/null; then
506
492
ps_failAndExit IO_ERROR " Could not mount image file."
507
493
else
508
494
st_temporaryAssets+=(" $_mountPoint " )
@@ -601,7 +587,7 @@ function fs_syncWithProgress() {
601
587
602
588
# $1 - The name of the command to check in $PATH.
603
589
function sys_hasCommand() {
604
- command -v " $1 " & > /dev/null
590
+ command -v " $1 " & > /dev/null
605
591
return $?
606
592
}
607
593
@@ -942,7 +928,7 @@ function asrt_checkSudo() {
942
928
if [[ -t 1 ]] && sys_hasCommand sudo; then
943
929
sudo --preserve-env " $0 " " $@ "
944
930
elif sys_hasCommand gksu; then
945
- exec 1> output_file
931
+ exec 1> output_file
946
932
gksu --preserve-env " $0 " " $@ "
947
933
else
948
934
ps_failAndExit MISSING_PRIVILEGE " You must run $scriptName as root."
@@ -989,15 +975,14 @@ function asrt_checkImageHash() {
989
975
printf " %s" \
990
976
" You can disable this check with $( term_boldify " -H, --no-hash-check" ) flags." | term_indentAll
991
977
st_temporaryAssets+=(" $_hashStoreFile " )
992
- (
978
+ (
993
979
local _hash
994
- local -i _status=0
980
+ local -i
995
981
_hash=$( $_hashName " $_imageName " | awk " {print \$ 1; exit }" )
996
- _status=$?
997
- if (( _status == 0 )) ; then
998
- printf " %s" " $_hash " > " $_hashStoreFile "
982
+ if (( $? == 0 )) ; then
983
+ printf " %s" " $_hash " > " $_hashStoreFile "
999
984
else
1000
- printf " %s" 1 > " $_hashStoreFile "
985
+ printf " %s" 1 > " $_hashStoreFile "
1001
986
fi
1002
987
) &
1003
988
st_backgroundProcess=$!
@@ -1015,7 +1000,7 @@ function asrt_checkImageHash() {
1015
1000
local -r _hashPath=$1 # Path to file containing _hashes
1016
1001
local -r _imageName=$2 # File to be checked
1017
1002
local -r _hashName=$3 # Name of command of _hash
1018
- local _status _answer
1003
+ local _answer
1019
1004
# Hash from _hash file
1020
1005
local _gHash
1021
1006
_gHash=$( awk -v pattern=" $_imageName $" ' $0 ~ pattern { print $1; exit }' " $_hashPath " )
@@ -1042,11 +1027,7 @@ function asrt_checkImageHash() {
1042
1027
esac
1043
1028
fi
1044
1029
# Hash from iso
1045
- _computeHashWithProgress $_hashName " $_imageName "
1046
- _status=$?
1047
- if (( _status != 0 )) ; then
1048
- ps_failAndExit THIRD_PARTY_ERROR " $_hashName command failed with status $_status "
1049
- fi
1030
+ _computeHashWithProgress $_hashName " $_imageName " || ps_failAndExit THIRD_PARTY_ERROR " $_hashName command failed with status $? "
1050
1031
if [ " $_gHash " != " $_lHash " ]; then
1051
1032
if [ " $enableForceHashCheck " == ' true' ]; then
1052
1033
ps_failAndExit ASSERTION_FAILED " Hash mismatch in '$_hashPath ' (${_hashName% sum} )."
@@ -1102,11 +1083,11 @@ function asrt_checkPackages() {
1102
1083
sys_checkCommand " $_pkg "
1103
1084
done
1104
1085
# test grep supports -P option
1105
- if ! echo 1 | grep -P ' 1' & > /dev/null; then
1086
+ if ! echo 1 | grep -P ' 1' & > /dev/null; then
1106
1087
ps_failAndExit MISSING_DEPENDENCY \
1107
1088
" You're using an old version of grep which does not support perl regular expression (-P option)."
1108
1089
fi
1109
- if echo " " | column -t -N t -W t & > /dev/null; then
1090
+ if echo " " | column -t -N t -W t & > /dev/null; then
1110
1091
st_hasLegacyColumn=false
1111
1092
else
1112
1093
# Old BSD command, see https://git.io/JfauE
@@ -1193,7 +1174,7 @@ function asrt_checkFSType() {
1193
1174
ps_failAndExit SYNOPSIS_NONCOMPL " Filesystem type '$_fsType ' not supported." \
1194
1175
" Supported filesystem types: $( sh_joinBy " ," " ${asrt_supportedFS[*]} " ) ."
1195
1176
fi
1196
- if ! command -v " mkfs.$_fsType " & > /dev/null; then
1177
+ if ! command -v " mkfs.$_fsType " & > /dev/null; then
1197
1178
ps_failAndExit MISSING_DEPENDENCY \
1198
1179
" Program 'mkfs.$_fsType ' could not be found on your system." \
1199
1180
" Please install it and retry."
@@ -1396,7 +1377,7 @@ function devi_configureLabel() {
1396
1377
# Fallback to "USER_VENDOR" if format
1397
1378
if [[ " $targetAction " == format ]]; then
1398
1379
_user=${SUDO_USER:- $USER }
1399
- _vendor=$( lsblk -ldno VENDOR " $targetDevice " 2> /dev/null)
1380
+ _vendor=$( lsblk -ldno VENDOR " $targetDevice " 2> /dev/null)
1400
1381
_vendor=${_vendor:- FLASH}
1401
1382
targetPartitionLabel=${targetPartitionLabel:- " ${_user^^} _${_vendor^^} " }
1402
1383
else
@@ -1549,7 +1530,7 @@ function devi_partitionUSB() {
1549
1530
# unmount any partition on selected device
1550
1531
mapfile -t devicePartitions < <( grep -oP " ^\\ K$targetDevice \\ S*" /proc/mounts)
1551
1532
for _partition in " ${devicePartitions[@]} " ; do
1552
- if ! umount " $_partition " > /dev/null; then
1533
+ if ! umount " $_partition " > /dev/null; then
1553
1534
ps_failAndExit IO_ERROR \
1554
1535
" Failed to unmount $_partition . It's likely that the partition is busy."
1555
1536
fi
@@ -1558,7 +1539,7 @@ function devi_partitionUSB() {
1558
1539
function _eraseDevice() {
1559
1540
term_echoinfo " Erasing contents of '$targetDevice '..."
1560
1541
# clean signature from selected device
1561
- wipefs --all --force " $targetDevice " & > /dev/null
1542
+ wipefs --all --force " $targetDevice " & > /dev/null
1562
1543
# erase drive
1563
1544
dd if=/dev/zero of=" $targetDevice " bs=512 count=1 conv=notrunc status=none | &
1564
1545
term_indentAll ||
@@ -1792,10 +1773,8 @@ function devi_inspectHybridImage() {
1792
1773
_supportsEFIBoot=false
1793
1774
fi
1794
1775
}
1795
- _diskReport=$( sfdisk -lJ -- " $sourceImageFile " 2> /dev/null)
1796
- if (( $? != 0 )) ; then
1797
- ps_failAndExit IO_ERROR " sfdisk couldn't read the partition table on the image file, which is likely corrupted."
1798
- fi
1776
+ _diskReport=$( sfdisk -lJ -- " $sourceImageFile " 2> /dev/null) \
1777
+ || ps_failAndExit IO_ERROR " sfdisk couldn't read the partition table on the image file, which is likely corrupted."
1799
1778
_partScheme=$( echo " $_diskReport " | jq -r ' .partitiontable.label' )
1800
1779
case $_partScheme in
1801
1780
dos) _inspectMBRPartTable ;;
@@ -1926,7 +1905,7 @@ function step_installBootloader() {
1926
1905
fi
1927
1906
fi
1928
1907
term_echoinfo " Found local SYSLINUX version '$_localSyslinuxVersion '"
1929
- sh_compute " $_localSyslinuxVersion == ${st_isoInspections[syslinuxVer]} " > /dev/null
1908
+ sh_compute " $_localSyslinuxVersion == ${st_isoInspections[syslinuxVer]} " > /dev/null
1930
1909
_versionsMatch=$?
1931
1910
if (( _versionsMatch == 0 )) ; then
1932
1911
term_echogood " image SYSLINUX version matches local version."
@@ -1972,7 +1951,7 @@ function step_installBootloader() {
1972
1951
function _installWtKernelOrgExtlinux() {
1973
1952
local _isExt32 _isHost32 _fallbackToLocal=false
1974
1953
term_echoinfo " Installing SYSLINUX bootloader in '$_syslinuxFolder ' with kernel.org version '$st_targetSyslinuxVersion '..."
1975
- file -b -- " ${st_syslinuxBinaries['extBin']} " | awk ' {print $2}' | grep -e ' ^32' & > /dev/null
1954
+ file -b -- " ${st_syslinuxBinaries['extBin']} " | awk ' {print $2}' | grep -e ' ^32' & > /dev/null
1976
1955
_isExt32=$?
1977
1956
echo " $ct_architecture " | grep -e ' 32|i386'
1978
1957
_isHost32=$?
@@ -1996,7 +1975,7 @@ function step_installBootloader() {
1996
1975
fi
1997
1976
fi
1998
1977
if [[ " $_fallbackToLocal " == true ]]; then
1999
- _installWtLocalExtlinux > /dev/null
1978
+ _installWtLocalExtlinux > /dev/null
2000
1979
fi
2001
1980
fs_syncdev
2002
1981
}
@@ -2036,7 +2015,7 @@ function step_copyWithRsync() {
2036
2015
term_echowarn " Detected a Windows install.wim file but wimsplit has been disabled with $( term_boldify ' --no-wim-split' ) option."
2037
2016
fi
2038
2017
fi
2039
- (
2018
+ (
2040
2019
# shellcheck disable=SC2086
2041
2020
rsync -r -q -I --no-links --no-perms --no-owner --no-group $_rsyncOptions " $st_elToritoMountPoint " /. " $st_usbMountPoint "
2042
2021
_status=$?
@@ -2045,7 +2024,7 @@ function step_copyWithRsync() {
2045
2024
echo
2046
2025
wimlib-imagex split " $_wimFile " " $st_usbMountPoint /sources/install.swm" 1024 | & term_indentAll
2047
2026
fi
2048
- echo " $_status " > " $_statusFile "
2027
+ echo " $_status " > " $_statusFile "
2049
2028
) &
2050
2029
st_backgroundProcess=$!
2051
2030
echo -n " $scriptName : Copying files from image to USB device with 'rsync' "
@@ -2071,9 +2050,9 @@ function step_copyWithDD() {
2071
2050
local _status
2072
2051
_statusFile=$( fs_createTempFile " bootiso-status" )
2073
2052
st_temporaryAssets+=(" $_statusFile " )
2074
- (
2053
+ (
2075
2054
dd if=" $sourceImageFile " of=" $targetDevice " bs=" $targetDDBusSize " status=none
2076
- echo " $? " > " $_statusFile "
2055
+ echo " $? " > " $_statusFile "
2077
2056
) &
2078
2057
st_backgroundProcess=$!
2079
2058
echo -n " $scriptName : Copying files from image to USB device with 'dd' "
0 commit comments