[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Use of $@
From: |
alex xmb ratchev |
Subject: |
Re: Use of $@ |
Date: |
Tue, 21 Feb 2023 15:13:49 +0100 |
On Tue, Feb 21, 2023, 2:43 PM Greg Wooledge <greg@wooledge.org> wrote:
> On Tue, Feb 21, 2023 at 08:35:13AM -0500, Greg Wooledge wrote:
> > On Tue, Feb 21, 2023 at 08:23:09AM -0500, Chris F.A. Johnson wrote:
> > > > Can anyone spot what's wrong?
> > >
> > > l()
> > > {
> > > declare i=1 s=$1
> > > shift
> > > while (( ++i <= $# ))
> > > do
> > > [[ ${!i} == "$s" ]] &&
> > > printf $i\\n && return
> > > done
> > > }
> >
> > You're starting with element 2, *after* having already shifted.
>
> Also, your return won't happen if your printf fails for any reason.
> That may be a highly theoretical situation, but not impossible. Either
> use "if" like a normal person, or use { printf...; return; } to force
> the return to occur even if printf fails.
>
i agree .. both for later versions
thanks .. greets ..
>
- Re: Use of $@, (continued)
- Re: Use of $@, Koichi Murase, 2023/02/21
- Re: Use of $@, Christof Warlich, 2023/02/21
- Re: Use of $@, alex xmb ratchev, 2023/02/21
- Re: Use of $@, alex xmb ratchev, 2023/02/21
- Re: Use of $@, Chris F.A. Johnson, 2023/02/21
- Re: Use of $@, alex xmb ratchev, 2023/02/21
- Re: Use of $@, Greg Wooledge, 2023/02/21
- Re: Use of $@, Greg Wooledge, 2023/02/21
- Re: Use of $@,
alex xmb ratchev <=
- Re: Use of $@, Kerin Millar, 2023/02/21
- Re: Use of $@, Greg Wooledge, 2023/02/21
- Re: Use of $@, Chet Ramey, 2023/02/21
- Re: Use of $@, Christof Warlich, 2023/02/23
- Re: Use of $@, alex xmb ratchev, 2023/02/23
- Re: Use of $@, Chet Ramey, 2023/02/23
Re: Use of $@, alex xmb ratchev, 2023/02/21