autoconf
[Top][All Lists]
Advanced

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

Re: Bourne sh redirection, a loop variable, and ':'


From: Bruce Korb
Subject: Re: Bourne sh redirection, a loop variable, and ':'
Date: Wed, 3 Sep 2008 13:29:01 -0700

On Wed, Sep 3, 2008 at 12:45 PM, Ralf Wildenhues <address@hidden> wrote:
> Hello,
>
> is this nice little Bourne shell quirk already known?
>
> $ for i in 1 2 3 ; do : >x$i; done
> $ ls
> x1
>
> It works when I use 'echo' instead of ':'.
>
> Seen with Solaris 10 sh, but also some other old shells IIRC.

Are there any shells around older than a Solaris /bin/sh ??
Over 20 years old, IIRC.  Anyway, for amusement:

#  for i in 1 2 3 ; do : >x$i ; sleep 60 ; done ; date ; ls -l x*
Wednesday, September  3, 2008  1:25:25 PM PDT
-rw-r--r--   1 root     root           0 Sep  3 13:22 x1

it seems that the no-op is removed from the loop after the first iteration.
I guessed as much, but this makes it clearer.  Pretty weird. - Bruce




reply via email to

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