Re: is it a bug that \e's dont get escaped in declare -p output
From:
Léa Gris
Subject:
Re: is it a bug that \e's dont get escaped in declare -p output
Date:
Wed, 17 Mar 2021 21:59:01 +0100
User-agent:
Telnet/1.0 [tlh] (PDP11/DEC)
Le 17/03/2021 à 21:13, Alex fxmbsw7 Ratchev écrivait :
hm at least now we know array declare -p formatting would work in
workarounds, good to .. :)
Instead of:
var=$'1\e[G\e[K2' ; declare -p var
do:
var=$'1\e[G\e[K2' ; printf 'declare -- %s\n' "${var@A}"
And if you want a human readable dumpvars, then code it.
Here it is:
#!/usr/bin/env bash
dump_vars () {
local ___varname
for ___varname; do
local ___varflags=${!___varname@a}
___varflags=${___varflags:--}
if [[ "$___varflags" =~ [Aa] ]]; then
declare -p "$___varname"
else