[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fixing escape format when values are empty
From: |
Dennis Williamson |
Subject: |
Re: Fixing escape format when values are empty |
Date: |
Wed, 7 Apr 2021 22:49:41 -0500 |
On Wed, Apr 7, 2021, 10:47 PM <pauline-galea@gmx.com> wrote:
> 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 [
>
>
>
Please use tput.
>