[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fixing escape format when values are empty
From: |
pauline-galea |
Subject: |
Fixing escape format when values are empty |
Date: |
Thu, 8 Apr 2021 05:47:25 +0200 |
I am using the following format to use colour when displaying text.
an is the attribute number, bn is the background number, fn is the
foreground number.
fmt="\e[${an};${bn};${fn}m"
printf "${fmt}%s\e[0m" "Jane"
But "an", "bn", "fn" can be empty, and I then have to
fix fmt.
Currently I am using the following replacements, but unsure
if this solves all problems. Or perhaps there are simpler
way to modify fmt.
fmt="\e[${an};${bn};${fn}m"
fmt=${fmt/";;"/";"} # replace [; with [
fmt=${fmt/"[;"/"["} # replace [;; with [
- Fixing escape format when values are empty,
pauline-galea <=