replace cut usage with choose

This commit is contained in:
Tobias Powalowski 2024-07-28 22:07:31 +02:00
parent 9a0abb54b9
commit 62caddf370
8 changed files with 31 additions and 31 deletions

View file

@ -9,7 +9,7 @@ _archboot_check
rm -r /usr/share/{licenses,locale} /usr/lib/{systemd,tmpfiles.d} rm -r /usr/share/{licenses,locale} /usr/lib/{systemd,tmpfiles.d}
pacman -Sy pacman -Sy
#shellcheck disable=SC2013 #shellcheck disable=SC2013
for i in $(pacman -Q | cut -d ' ' -f1); do for i in $(pacman -Q | choose 0); do
#shellcheck disable=SC2086 #shellcheck disable=SC2086
rm -r "${_PACMAN_LIB}"/local/"$(pacman -Q ${i} | sd ' ' '-')" rm -r "${_PACMAN_LIB}"/local/"$(pacman -Q ${i} | sd ' ' '-')"
#shellcheck disable=SC2086 #shellcheck disable=SC2086

View file

@ -128,7 +128,7 @@ _show_login() {
} }
_abort() { _abort() {
if _dialog --yesno "Abort$(echo "${_TITLE}" | cut -d '|' -f5) ?" 5 45; then if _dialog --yesno "Abort$(echo "${_TITLE}" | choose 4 -f '\|') ?" 5 45; then
[[ -e "${_ANSWER}-running" ]] && rm "${_ANSWER}-running" [[ -e "${_ANSWER}-running" ]] && rm "${_ANSWER}-running"
[[ -e "${_ANSWER}" ]] && rm "${_ANSWER}" [[ -e "${_ANSWER}" ]] && rm "${_ANSWER}"
clear clear

View file

@ -16,7 +16,7 @@ _run ()
# only take services from systemd package # only take services from systemd package
pacman -Sy &>"${_NO_LOG}" pacman -Sy &>"${_NO_LOG}"
#shellcheck disable=SC2046 #shellcheck disable=SC2046
_map _file $(pacman -Ql systemd | grep '/usr/lib/systemd/system/.' | cut -d ' ' -f2) _map _file $(pacman -Ql systemd | grep '/usr/lib/systemd/system/.' | choose 1)
_map _file /usr/lib/sysusers.d/{arch,basic}.conf _map _file /usr/lib/sysusers.d/{arch,basic}.conf
# disable systemd services: # disable systemd services:
for i in lvm2-{lvmpolld,monitor} systemd-{boot,random-seed,sysusers\ for i in lvm2-{lvmpolld,monitor} systemd-{boot,random-seed,sysusers\

View file

@ -23,7 +23,7 @@ _umount_btrfs() {
_find_btrfsraid_devices() { _find_btrfsraid_devices() {
_btrfs_scan _btrfs_scan
if [[ -z "${_DETECT_CREATE_FILESYSTEM}" && "${_FSTYPE}" == "btrfs" ]]; then if [[ -z "${_DETECT_CREATE_FILESYSTEM}" && "${_FSTYPE}" == "btrfs" ]]; then
for i in $(btrfs filesystem show "${_DEV}" | cut -d ' ' -f 11); do for i in $(btrfs filesystem show "${_DEV}" | choose 10); do
_BTRFS_DEVS="${_BTRFS_DEVS}#${i}" _BTRFS_DEVS="${_BTRFS_DEVS}#${i}"
done done
fi fi
@ -34,7 +34,7 @@ _find_btrfsraid_bootloader_devices() {
_BTRFS_COUNT=1 _BTRFS_COUNT=1
if [[ "$(${_LSBLK} FSTYPE "${_BOOTDEV}")" == "btrfs" ]]; then if [[ "$(${_LSBLK} FSTYPE "${_BOOTDEV}")" == "btrfs" ]]; then
_BTRFS_DEVS="" _BTRFS_DEVS=""
for i in $(btrfs filesystem show "${_BOOTDEV}" | cut -d ' ' -f 11); do for i in $(btrfs filesystem show "${_BOOTDEV}" | choose 10); do
_BTRFS_DEVS="${_BTRFS_DEVS}#${i}" _BTRFS_DEVS="${_BTRFS_DEVS}#${i}"
_BTRFS_COUNT=$((_BTRFS_COUNT+1)) _BTRFS_COUNT=$((_BTRFS_COUNT+1))
done done
@ -46,7 +46,7 @@ _find_btrfs_subvolume() {
if [[ -z "${_DETECT_CREATE_FILESYSTEM}" ]]; then if [[ -z "${_DETECT_CREATE_FILESYSTEM}" ]]; then
# existing btrfs subvolumes # existing btrfs subvolumes
_mount_btrfs _mount_btrfs
for i in $(btrfs subvolume list "${_BTRFSMP}" | cut -d ' ' -f 9 | rg -v 'var/lib/machines|var/lib/portables'); do for i in $(btrfs subvolume list "${_BTRFSMP}" | choose 8 | rg -v 'var/lib/machines|var/lib/portables'); do
echo "${i}" echo "${i}"
[[ "${1}" ]] && echo "${1}" [[ "${1}" ]] && echo "${1}"
done done
@ -59,7 +59,7 @@ _find_btrfs_bootloader_subvolume() {
_BTRFS_SUBVOLUMES="" _BTRFS_SUBVOLUMES=""
_DEV="${_BOOTDEV}" _DEV="${_BOOTDEV}"
_mount_btrfs _mount_btrfs
for i in $(btrfs subvolume list "${_BTRFSMP}" | cut -d ' ' -f 7); do for i in $(btrfs subvolume list "${_BTRFSMP}" | choose 7); do
_BTRFS_SUBVOLUMES="${_BTRFS_SUBVOLUMES}#${i}" _BTRFS_SUBVOLUMES="${_BTRFS_SUBVOLUMES}#${i}"
done done
_umount_btrfs _umount_btrfs
@ -70,7 +70,7 @@ _find_btrfs_bootloader_subvolume() {
_subvolumes_in_use() { _subvolumes_in_use() {
_SUBVOLUME_IN_USE="" _SUBVOLUME_IN_USE=""
while read -r i; do while read -r i; do
echo "${i}" | rg -F -q "|btrfs|" && _SUBVOLUME_IN_USE="${_SUBVOLUME_IN_USE} $(echo "${i}" | cut -d '|' -f 9)" echo "${i}" | rg -F -q "|btrfs|" && _SUBVOLUME_IN_USE="${_SUBVOLUME_IN_USE} $(echo "${i}" | choose 8 -f '\|')"
done < /tmp/.parts done < /tmp/.parts
} }
@ -84,7 +84,7 @@ _check_btrfs_filesystem_creation() {
_FSTYPE="btrfs" _FSTYPE="btrfs"
_SKIP_FILESYSTEM=1 _SKIP_FILESYSTEM=1
# check on filesystem creation, skip subvolume asking then! # check on filesystem creation, skip subvolume asking then!
echo "${i}" | cut -d '|' -f 4 | rg -q 1 && _DETECT_CREATE_FILESYSTEM=1 echo "${i}" | choose 3 -f '\|' | rg -q 1 && _DETECT_CREATE_FILESYSTEM=1
fi fi
done done
} }
@ -198,7 +198,7 @@ _check_btrfs_subvolume(){
[[ -n "${_DOMKFS}" && "${_FSTYPE}" == "btrfs" ]] && _DETECT_CREATE_FILESYSTEM=1 [[ -n "${_DOMKFS}" && "${_FSTYPE}" == "btrfs" ]] && _DETECT_CREATE_FILESYSTEM=1
if [[ -z "${_DETECT_CREATE_FILESYSTEM}" && -z "${_CREATE_MOUNTPOINTS}" ]]; then if [[ -z "${_DETECT_CREATE_FILESYSTEM}" && -z "${_CREATE_MOUNTPOINTS}" ]]; then
_mount_btrfs _mount_btrfs
for i in $(btrfs subvolume list "${_BTRFSMP}" | cut -d ' ' -f 9); do for i in $(btrfs subvolume list "${_BTRFSMP}" | choose 8); do
if echo "${i}" | rg -q "${_BTRFS_SUBVOLUME}"; then if echo "${i}" | rg -q "${_BTRFS_SUBVOLUME}"; then
_dialog --title " ERROR " --no-mouse --infobox "You have defined 2 identical SUBVOLUMES!\nPlease enter another name." 4 45 _dialog --title " ERROR " --no-mouse --infobox "You have defined 2 identical SUBVOLUMES!\nPlease enter another name." 4 45
sleep 3 sleep 3

View file

@ -32,7 +32,7 @@ _PACMAN="pacman --root ${_DESTDIR} --cachedir=${_DESTDIR}${_CACHEDIR} --noconfir
_linux_firmware() { _linux_firmware() {
_PACKAGES="${_PACKAGES// linux-firmware / }" _PACKAGES="${_PACKAGES// linux-firmware / }"
#shellcheck disable=SC2013 #shellcheck disable=SC2013
for i in $(cut -d ' ' -f1</proc/modules); do for i in $(choose 0 </proc/modules); do
if modinfo "${i}" | rg -qw 'firmware:'; then if modinfo "${i}" | rg -qw 'firmware:'; then
_PACKAGES="${_PACKAGES} linux-firmware" _PACKAGES="${_PACKAGES} linux-firmware"
break break

View file

@ -110,7 +110,7 @@ _enter_mountpoint() {
rg -qw "/srv" /tmp/.parts && _MP=/var rg -qw "/srv" /tmp/.parts && _MP=/var
_dialog --no-cancel --title " Mountpoint for ${_DEV} " --inputbox "" 7 65 "${_MP}" 2>"${_ANSWER}" || return 1 _dialog --no-cancel --title " Mountpoint for ${_DEV} " --inputbox "" 7 65 "${_MP}" 2>"${_ANSWER}" || return 1
_MP=$(cat "${_ANSWER}") _MP=$(cat "${_ANSWER}")
if [[ "$(rg -F "|${_MP}|" /tmp/.parts | cut -d '|' -f 3)" == "${_MP}" ]]; then if [[ "$(rg -F "|${_MP}|" /tmp/.parts | choose 2 -f '\|')" == "${_MP}" ]]; then
_dialog --infobox "ERROR: You have defined 2 identical mountpoints!\nPlease select another mountpoint." 4 45 _dialog --infobox "ERROR: You have defined 2 identical mountpoints!\nPlease select another mountpoint." 4 45
_MP="" _MP=""
sleep 3 sleep 3
@ -140,18 +140,18 @@ _check_mkfs_values() {
_run_mkfs() { _run_mkfs() {
while read -r line; do while read -r line; do
# basic parameters # basic parameters
_DEV=$(echo "${line}" | cut -d '|' -f 1) _DEV=$(echo "${line}" | choose 0 -f '\|')
_FSTYPE=$(echo "${line}" | cut -d '|' -f 2) _FSTYPE=$(echo "${line}" | choose 1 -f '\|')
_MP=$(echo "${line}" | cut -d '|' -f 3) _MP=$(echo "${line}" | choose 2 -f '\|')
_DOMKFS=$(echo "${line}" | cut -d '|' -f 4) _DOMKFS=$(echo "${line}" | choose 3 -f '\|')
_LABEL_NAME=$(echo "${line}" | cut -d '|' -f 5) _LABEL_NAME=$(echo "${line}" | choose 4 -f '\|')
_FS_OPTIONS=$(echo "${line}" | cut -d '|' -f 6) _FS_OPTIONS=$(echo "${line}" | choose 5 -f '\|')
[[ "${_FS_OPTIONS}" == "NONE" ]] && _FS_OPTIONS="" [[ "${_FS_OPTIONS}" == "NONE" ]] && _FS_OPTIONS=""
# bcachefs, btrfs and other parameters # bcachefs, btrfs and other parameters
if [[ ${_FSTYPE} == "bcachefs" ]]; then if [[ ${_FSTYPE} == "bcachefs" ]]; then
_BCFS_DEVS="${_BCFS_DEVS//#/ }" _BCFS_DEVS="${_BCFS_DEVS//#/ }"
_BCFS_DEVS=$(echo "${line}" | cut -d '|' -f 7) _BCFS_DEVS=$(echo "${line}" | choose 6 -f '\|')
_BCFS_COMPRESS=$(echo "${line}" | cut -d '|' -f 8) _BCFS_COMPRESS=$(echo "${line}" | choose 7 -f '\|')
if [[ "${_BCFS_COMPRESS}" == "NONE" ]];then if [[ "${_BCFS_COMPRESS}" == "NONE" ]];then
_BCFS_COMPRESS="" _BCFS_COMPRESS=""
else else
@ -160,13 +160,13 @@ _run_mkfs() {
_mkfs "${_DEV}" "${_FSTYPE}" "${_DESTDIR}" "${_DOMKFS}" "${_MP}" "${_LABEL_NAME}" "${_FS_OPTIONS}" \ _mkfs "${_DEV}" "${_FSTYPE}" "${_DESTDIR}" "${_DOMKFS}" "${_MP}" "${_LABEL_NAME}" "${_FS_OPTIONS}" \
"${_BCFS_DEVS}" "${_BCFS_COMPRESS}" || return 1 "${_BCFS_DEVS}" "${_BCFS_COMPRESS}" || return 1
elif [[ ${_FSTYPE} == "btrfs" ]]; then elif [[ ${_FSTYPE} == "btrfs" ]]; then
_BTRFS_DEVS=$(echo "${line}" | cut -d '|' -f 7) _BTRFS_DEVS=$(echo "${line}" | choose 6 -f '\|')
# remove # from array # remove # from array
_BTRFS_DEVS="${_BTRFS_DEVS//#/ }" _BTRFS_DEVS="${_BTRFS_DEVS//#/ }"
_BTRFS_LEVEL=$(echo "${line}" | cut -d '|' -f 8) _BTRFS_LEVEL=$(echo "${line}" | choose 7 -f '\|')
[[ ! "${_BTRFS_LEVEL}" == "NONE" && "${_FSTYPE}" == "btrfs" ]] && _BTRFS_LEVEL="-m ${_BTRFS_LEVEL} -d ${_BTRFS_LEVEL}" [[ ! "${_BTRFS_LEVEL}" == "NONE" && "${_FSTYPE}" == "btrfs" ]] && _BTRFS_LEVEL="-m ${_BTRFS_LEVEL} -d ${_BTRFS_LEVEL}"
_BTRFS_SUBVOLUME=$(echo "${line}" | cut -d '|' -f 9) _BTRFS_SUBVOLUME=$(echo "${line}" | choose 8 -f '\|')
_BTRFS_COMPRESS=$(echo "${line}" | cut -d '|' -f 10) _BTRFS_COMPRESS=$(echo "${line}" | choose 9 -f '\|')
[[ "${_BTRFS_COMPRESS}" == "NONE" ]] && _BTRFS_COMPRESS="" [[ "${_BTRFS_COMPRESS}" == "NONE" ]] && _BTRFS_COMPRESS=""
_mkfs "${_DEV}" "${_FSTYPE}" "${_DESTDIR}" "${_DOMKFS}" "${_MP}" "${_LABEL_NAME}" "${_FS_OPTIONS}" \ _mkfs "${_DEV}" "${_FSTYPE}" "${_DESTDIR}" "${_DOMKFS}" "${_MP}" "${_LABEL_NAME}" "${_FS_OPTIONS}" \
"${_BTRFS_DEVS}" "${_BTRFS_LEVEL}" "${_BTRFS_SUBVOLUME}" "${_BTRFS_COMPRESS}" || return 1 "${_BTRFS_DEVS}" "${_BTRFS_LEVEL}" "${_BTRFS_SUBVOLUME}" "${_BTRFS_COMPRESS}" || return 1
@ -193,7 +193,7 @@ _create_filesystem() {
_dialog --no-cancel --title " LABEL Name on ${_DEV} " --inputbox "Keep it short and use no spaces or special characters." 8 60 \ _dialog --no-cancel --title " LABEL Name on ${_DEV} " --inputbox "Keep it short and use no spaces or special characters." 8 60 \
"$(${_LSBLK} LABEL "${_DEV}" 2>"${_NO_LOG}")" 2>"${_ANSWER}" || return 1 "$(${_LSBLK} LABEL "${_DEV}" 2>"${_NO_LOG}")" 2>"${_ANSWER}" || return 1
_LABEL_NAME=$(cat "${_ANSWER}") _LABEL_NAME=$(cat "${_ANSWER}")
if [[ "$(rg -F "|${_LABEL_NAME}|" /tmp/.parts | cut -d '|' -f5)" == "${_LABEL_NAME}" ]]; then if [[ "$(rg -F "|${_LABEL_NAME}|" /tmp/.parts | choose 4 -f '\|')" == "${_LABEL_NAME}" ]]; then
_dialog --title " ERROR " --no-mouse --infobox "You have defined 2 identical LABEL names!\nPlease enter another name." 4 45 _dialog --title " ERROR " --no-mouse --infobox "You have defined 2 identical LABEL names!\nPlease enter another name." 4 45
sleep 3 sleep 3
_LABEL_NAME="" _LABEL_NAME=""

View file

@ -66,17 +66,17 @@ _auto_create_filesystems() {
_PROGRESS_COUNT=$((100/_MAX_COUNT)) _PROGRESS_COUNT=$((100/_MAX_COUNT))
## make and mount filesystems ## make and mount filesystems
for fsspec in ${_FSSPECS}; do for fsspec in ${_FSSPECS}; do
_DEV="${_DISK}$(echo "${fsspec}" | tr -d ' ' | cut -f1 -d '|')" _DEV="${_DISK}$(echo "${fsspec}" | tr -d ' ' | choose 0 -f '\|')"
# Add check on nvme or mmc controller: # Add check on nvme or mmc controller:
# NVME uses /dev/nvme0n1pX name scheme # NVME uses /dev/nvme0n1pX name scheme
# MMC uses /dev/mmcblk0pX # MMC uses /dev/mmcblk0pX
if echo "${_DISK}" | rg -q "nvme|mmc"; then if echo "${_DISK}" | rg -q "nvme|mmc"; then
_DEV="${_DISK}p$(echo "${fsspec}" | tr -d ' ' | cut -f1 -d '|')" _DEV="${_DISK}p$(echo "${fsspec}" | tr -d ' ' | choose 0 -f '\|')"
fi fi
_FSTYPE="$(echo "${fsspec}" | tr -d ' ' | cut -f2 -d '|')" _FSTYPE="$(echo "${fsspec}" | tr -d ' ' | choose 1 -f '\|')"
_DOMKFS=1 _DOMKFS=1
_MP="$(echo "${fsspec}" | tr -d ' ' | cut -f3 -d '|')" _MP="$(echo "${fsspec}" | tr -d ' ' | choose 2 -f '\|')"
_LABEL_NAME="$(echo "${fsspec}" | tr -d ' ' | cut -f4 -d '|')" _LABEL_NAME="$(echo "${fsspec}" | tr -d ' ' | choose 3 -f '\|')"
_FS_OPTIONS="" _FS_OPTIONS=""
_BTRFS_DEVS="" _BTRFS_DEVS=""
_BTRFS_LEVEL="" _BTRFS_LEVEL=""

View file

@ -13,7 +13,7 @@ _update()
esac esac
case $cur in case $cur in
*) *)
OPTS="$(update | grep '\-[a-z]' | cut -d ' ' -f2 | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g")" OPTS="$(update | rg '\-[a-z]' | choose 0 | sd '\x1B\[[0-9;]*[a-zA-Z]' '')"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0 return 0
;; ;;