#!/bin/bash shopt -s extglob m4_include(common) write_source() { local tag= spec= label= uuid= comment=() label=$(lsblk -rno LABEL "$1" 2>/dev/null) uuid=$(lsblk -rno UUID "$1" 2>/dev/null) if (( bylabel )); then tag=LABEL spec=$label comment=("$source" "UUID=$uuid") elif (( byuuid )); then tag=UUID spec=$uuid comment=("$source") if [[ $label ]]; then comment+=("LABEL=$label") fi else [[ $uuid ]] && comment+=("UUID=$uuid") [[ $label ]] && comment+=("LABEL=$label") fi [[ $comment ]] && printf '# %s\n' "${comment[*]}" if [[ $spec ]]; then printf '%-20s' "$tag=$spec" else printf '%-20s' "$(mangle "$source")" fi } root=/mnt usage() { cat <