help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: suggestion to add ' unset -v ' to ${var@A} if not existing


From: #!microsuxx
Subject: Re: suggestion to add ' unset -v ' to ${var@A} if not existing
Date: Sun, 3 Nov 2024 01:35:17 +0100

example code ' svar '

! (( $# )) &&
return 1
unset -v svars sv svar
for svar ; do
sv=${!svar@A} sv=${sv:-unset -v $svar} svars+=( "svar_$svar=$sv" )
done
declare -g "${svars[@]}"
unset -v svars sv svar

On Sun, Nov 3, 2024, 00:56 #!microsuxx <fxmbsw7@gmail.com> wrote:

> echo ${IFS@A}
> IFS=$' \t\n'
>
> declare -A f
> echo ${f@A}
> declare -A f
>
> but echo ${nonexisting@A} returns nothing
>
> so my suggestion is to add , a probably optional opt , that will return
> the unset -v for nonexisting vars
>
> this makes save restore of vars one code less
> removing ..
>
> oifs=${oifs:-unset -v that_var}
>
> oifs=${IFS@A} IFS=new
> <exec $oifs>
>
> greets ..
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]