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

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

 



On Wed, Sep 3, 2008 at 12:45 PM, Ralf Wildenhues <Ralf.Wildenhues@xxxxxx> 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


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux