[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syntax error near unexpected token `newline' within loops
From: |
Dr. Werner Fink |
Subject: |
Re: Syntax error near unexpected token `newline' within loops |
Date: |
Mon, 24 Apr 2017 13:41:15 +0200 |
User-agent: |
Mutt/1.6.2 (2016-07-01) |
On Mon, Apr 24, 2017 at 02:25:41PM +0300, Pierre Gaston wrote:
> On Mon, Apr 24, 2017 at 1:59 PM, <werner@suse.de> wrote:
>
> > (...)
> >
> > and yes
> >
> > V_NAME=Friday
> > for (( INDEX=0; INDEX<$((10-${#V_NAME})) ; INDEX++ ))
> > do
> > echo $INDEX
> > done
> >
> > does also work, nevertheless using $(...) in the very first example is
> > allowed
> >
> >
> or even for (( INDEX=0; INDEX<(10-${#V_NAME}) ; INDEX++ ))
> but otherwise yes, syntax looks ok
Yep ... the code could be more efficiently like
V_NAME=Friday
typeset -i len=$((10 - ${#V_NAME}))
for (( INDEX=0; INDEX < len; INDEX++ )); do echo $INDEX; done
... nevertheless even the intricate code should not cause an error I guess :)
--
"Having a smoking section in a restaurant is like having
a peeing section in a swimming pool." -- Edward Burr
signature.asc
Description: PGP signature