#!/usr/bin/env bash
readonly FQHN=${1:-`hostname -f`}
readonly HOSTNAME=${FQHN%%.*}
I am struggling with the syntax to assign FQHN
to the lower case of either the first command line argument or the output of hostname -f
in a single assignment.
I have tried to use the various ways to lower case a variable reference contents as given in this answer but have not been able to integrate them into my code without having to use something like "${HOSTNAME,,}"
or "${FQHN,,}"
for every reference since you can not nest string substitutions.
I am really looking or a solution that does not rely on mutability.