Fix: linter warnings

This commit is contained in:
natemaia 2020-03-25 08:30:25 -07:00
parent 4e60793784
commit 4d3c93c034

View File

@ -5,12 +5,14 @@
# Some ideas and code reworked from other resources
# AIF, Calamares, and the Arch Wiki.. Credit where credit is due
# shellcheck disable=SC2086,SC2046
VER=2.1.24
# default values {
: ${DIST=ArchLabs} # distro name if not set
: ${MNT=/mnt} # installation root mountpoint if not set
: "${DIST=ArchLabs}" # distro name if not set
: "${MNT=/mnt}" # installation root mountpoint if not set
ANS=/tmp/ans # dialog answer output file
FONT=ter-i16n # font used for the linux console
HOOKS=shutdown # additional mkinitcpio HOOKS
@ -122,9 +124,8 @@ declare -A PKG_EXT=(
_welcome="\nThis will help you get $DIST installed and setup on your system.\n\nIf you are unsure about a section the default option will be listed or\nthe first selected item will be the default.\n\n\nMenu Navigation:\n\n - Select items with the arrow keys or the option number.\n - Use [Space] to toggle check boxes and [Enter] to accept.\n - Switch between fields using [Tab] or the arrow keys.\n - Use [Page Up] and [Page Down] to jump whole pages\n - Press the highlighted key of an option to select it.\n"
_keymap="\nPick which keymap to use for the system from the list below\n\nThis is used once a graphical environment is running (Xorg).\n\nSystem default: us"
_vconsole="\nSelect the console keymap, the console is the tty shell you reach before starting a graphical environment (Xorg).\n\nIts keymap is separate from the one used by the graphical environments, though many do use the same such as 'us' English.\n\nSystem default: us"
_prep="\nThis is the installer main menu, once a step is complete you will return here.\n\nOn successful completion of a step the cursor will be advanced to the next step\nOn failure the cursor will be placed on the step required to advance (when possible).\n\nSteps beginning with an asterix (*) are required.\n\nOnce you're happy with the choices and the required steps are complete, selecting the final step will begin the install."
_prep="\nThis is the installer main menu, once a step is complete you will return here.\n\nOn successful completion of a step the cursor will be advanced to the next step\nOn failure the cursor will be placed on the step required to advance (when possible).\n\nSteps beginning with an asterisk (*) are required.\n\nOnce you're happy with the choices and the required steps are complete, selecting the final step will begin the install."
_device="\nSelect a device to use from the list below.\n\nDevices (/dev) are the available drives on the system. /sda, /sdb, /sdc ..."
_resize="\nSelect a new filesystem size in MB, a new partition will be created from the free space but will be left unformatted.\nThe lowest size is just enough to fit the currently in use space on the partition while the default is set to split the free space evenly.\n\nUse Tab or the arrow keys move the cursor between the buttons and the value, when the cursor is on the value, you can edit it by:\n\n - left/right cursor movement to select a digit to modify\n - +/- characters to increment/decrement the digit by one\n - 0 through 9 to set the digit to the given value\n\nSome keys are also recognized in all cursor positions:\n\n - Home/End set the value to its maximum or minimum\n - Pageup/Pagedown increment the value so that the slider moves by one column."
_mount="\nUse [Space] to toggle mount options from below, press [Enter] when done to confirm selection.\n\nNot selecting any and confirming will run an automatic mount."
_warn="\nIMPORTANT: Choose carefully when editing, formatting, and mounting partitions or your DATA MAY BE LOST.\n\nTo mount a partition without formatting it, select 'skip' when prompted to choose a filesystem during the mounting stage.\nThis can only be used for partitions that already contain a filesystem and cannot be the root (/) partition, it needs to be formatted before install.\n"
_part="\nFull device auto partitioning is available for beginners otherwise cfdisk is recommended.\n\n - All systems will require a root partition (8G or greater).\n - UEFI or BIOS using LUKS without LVM require a separate boot partition (100-512M)."
@ -364,7 +365,7 @@ select_mkuser()
# make sure a username was entered and that the passwords match
if [[ -z ${ans[0]} || ${ans[0]} =~ \ |\' || ${ans[0]} =~ [^a-z0-9] ]]; then
msg "Invalid Username" "\nInvalid user name.\n\nPlease try again.\n"; u=''
msg "Invalid Username" "\nInvalid user name.\n\nPlease try again.\n"; ans[0]=''
elif [[ -z "${ans[1]}" || "${ans[1]}" != "${ans[2]}" ]]; then
msg "Password Mismatch" "\nThe user passwords do not match.\n\nPlease try again.\n"
elif [[ "${ans[4]}" != "${ans[5]}" ]]; then
@ -596,11 +597,11 @@ part_menu()
while :; do
choice=""
dlg choice menu "Edit Partitions" "$_part\n\n$(lsblk -no NAME,MODEL,SIZE,FSTYPE,LABEL $device)" \
dlg choice menu "Edit Partitions" "$_part\n\n$(lsblk -no NAME,MODEL,SIZE,FSTYPE,LABEL "$device")" \
"auto" "Whole device automatic partitioning" \
"cfdisk" "Curses based variant of fdisk" \
"cgdisk" "Curses based variant of gdisk" \
"parted" "GNU partition editor" $([[ $DISPLAY ]] && hash gparted >/dev/null 2>&1 && printf \
"parted" "GNU partition editor" $([[ "$DISPLAY" ]] && hash gparted >/dev/null 2>&1 && printf \
"gparted 'A gui front end to parted'") \
"fdisk" "Dialog-driven creation and manipulation of partitions" \
"gdisk" "A text-mode partitioning tool that works on GUID Partition Table (GPT) disks" \
@ -766,7 +767,8 @@ part_mount()
local part="$1"
local mntpt="${MNT}$2"
shift 2
local fs="$(lsblk -lno FSTYPE "$part")"
local fs
fs="$(lsblk -lno FSTYPE "$part")"
mkdir -p "$mntpt"
@ -795,7 +797,7 @@ part_format()
msg "Format" "\nFormatting $part as $fs\n" 0
mkfs.$fs ${FS_CMD_FLAGS[$fs]} "$part" > /dev/null 2> "$ERR"
errshow 0 "mkfs.$fs ${FS_CMD_FLAGS[$fs]} '$part' > /dev/null" || return 1
sleep $delay
sleep "$delay"
}
part_device()
@ -983,7 +985,8 @@ select_boot()
esac
fi
local fs="$(fsck -N "$BOOT")"
local fs
fs="$(fsck -N "$BOOT")"
if ([[ $SYS == 'BIOS' ]] && grep -q 'ext[34]' <<< "$fs") || ([[ $SYS == 'UEFI' ]] && grep -q 'fat' <<< "$fs"); then
yesno "Format Boot Partition" "\nIMPORTANT: The boot partition $BOOT $_format" "Format $BOOT" "Skip Formatting" 1 || return 0
fi
@ -1139,7 +1142,8 @@ select_filesystem()
{
local part="$1"
local fs=''
local cur="$(lsblk -lno FSTYPE "$part" 2> /dev/null)"
local cur
cur="$(lsblk -lno FSTYPE "$part" 2> /dev/null)"
local txt="\nSelect which filesystem to use for: $part\n\nDefault: ext4"
# bail early if the partition was created in part_auto()
@ -1214,7 +1218,6 @@ install_main()
clear
die 127
else
local exists=''
for f in ${EDIT_FILES[$choice]}; do
if [[ -e ${MNT}$f ]]; then
${EDITOR:-vim} "${MNT}$f"
@ -1228,8 +1231,6 @@ install_main()
install_base()
{
local msg oldmsg
clear
tput cnorm
if [[ $BG_PID ]] && kill -0 $BG_PID 2> /dev/null; then
@ -1649,6 +1650,7 @@ install_background()
chrun "pacman -Syyu $BASE_PKGS --noconfirm --needed" > /tmp/bgout 2>&1
) &
BG_PID=$!
# shellcheck disable=SC2064
trap "kill $BG_PID 2> /dev/null" EXIT
}
@ -2516,11 +2518,13 @@ termcol()
errshow()
{
# shellcheck disable=SC2181
[ $? -eq 0 ] && return 0
local fatal=$1
shift # always shift off the fatal level arg
local txt="\nCommand: $1\n\n\n\nError:\n$(errmsg)\n\n"
local txt
txt="\nCommand: $1\n\n\n\nError:\n$(errmsg)\n\n"
tput cnorm
if (( fatal )); then
yesno "Install Error" "${txt}Errors at this stage must be fixed before the install can continue.\n$_errchoice" "Handle normally" "Continue, it's fixed" ||
@ -2630,7 +2634,7 @@ system_devices()
DEV_COUNT=0
while read -r line; do
(( DEV_COUNT++ ))
[[ "$line" ]] && (( DEV_COUNT++ ))
done <<< "$SYS_DEVS"
}
@ -2682,7 +2686,7 @@ while getopts ":htl:d" OPT; do
h) usage "$0" ;;
t) TEARFREE=true ;;
l)
if [[ "${!WM_SESSIONS[@]}" =~ $OPTARG ]]; then
if [[ "${!WM_SESSIONS[*]}" =~ $OPTARG ]]; then
live "$OPTARG"
else
echo "error: invalid session for -l, see -h for help"; die 1
@ -2695,6 +2699,7 @@ done
system_identify
system_devices
fontsize=16
while :; do
dlg fontsize menu "Font Size" "\nSelect a font size from the list below.\n\nDefault: 16" \
12 "setfont ter-i12n" 14 "setfont ter-i14n" 16 "setfont ter-i16n" 18 "setfont ter-i18n" \