[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash Shell Parameter Expansion
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: Bash Shell Parameter Expansion |
Date: |
Sun, 10 Oct 2021 01:46:10 +0200 |
- is for unset, + for set, in logical given order executed
seq=( {0..2} )
seq[1]=
unset seq[0]
floop() { declare p r t="$1[$2]" ; declare -n that="$t"
for p in {,:}{-,+} ; do
eval r+='"$p ${that'"$p"re$'}\n"'
done
printf '%s\n\n%s\n\n\n' "$t" "$r"
}
foolloop() { declare -n this=$1 ; declare f
for f in 0 "${!this[@]}" ; do
floop "$1" "$f"
done
}
foolloop seq
seq[0]
- re
+
:- re
:+
seq[1]
-
+ re
:- re
:+
seq[2]
- 2
+ re
:- 2
:+ re
On Sun, Oct 10, 2021, 01:25 tolugboji <tolugboji@protonmail.com> wrote:
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Saturday, October 9th, 2021 at 11:09 PM, Alex fxmbsw7 Ratchev <
> fxmbsw7@gmail.com> wrote:
>
> > you may be not reading the man bash to your version ?
>
> I am reading from the site which should be the latest descriptions
>
> https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
>
> > a means b
> >
> > - means str appears when var is unset ( never used yet )
> >
> > - means str appears when var is set already
> >
> > :- means str if unset or empty
> >
> > :+ str if set or empty
> >
> > .. hmm im not sure atm..
>
> Reading more carefully, the omitting the colon case is described. There
> is a lot
> one can do with parameter expansion.
>
> Have seen that fontify=${st:+"no"} results in an empty value for fontify
> (when st is unset),
> even when fontify was previously assigned.
>
> > On Sun, Oct 10, 2021, 00:58 tolugboji tolugboji@protonmail.com
> wrote:
> >
> > > Some bash implementations mention ${PARAMETER-WORD} and
> > >
> > > ${PARAMETER+WORD}. But these are not mentioned
> > >
> > > in the gnu bash manual? Is this because they are not implemented in gnu
> > >
> > > bash?
>
- Bash Shell Parameter Expansion, (continued)
- Bash Shell Parameter Expansion, tolugboji, 2021/10/09
- Re: Bash Shell Parameter Expansion, Alex fxmbsw7 Ratchev, 2021/10/09
- Re: Bash Shell Parameter Expansion, Chet Ramey, 2021/10/09
- Re: Bash Shell Parameter Expansion, tolugboji, 2021/10/09
- Re: Bash Shell Parameter Expansion, Alex fxmbsw7 Ratchev, 2021/10/09
- Bash Shell Parameter Expansion, tolugboji, 2021/10/09
- Bash Shell Parameter Expansion, tolugboji, 2021/10/09
- Bash Shell Parameter Expansion, tolugboji, 2021/10/09
- Re: Bash Shell Parameter Expansion, Alex fxmbsw7 Ratchev, 2021/10/09
- Bash Shell Parameter Expansion, tolugboji, 2021/10/09
- Re: Bash Shell Parameter Expansion,
Alex fxmbsw7 Ratchev <=
- Re: Bash Shell Parameter Expansion, Greg Wooledge, 2021/10/09
- Re: Bash Shell Parameter Expansion, Lawrence Velázquez, 2021/10/09
- Bash Shell Parameter Expansion, tolugboji, 2021/10/09
Bash Shell Parameter Expansion, tolugboji, 2021/10/09