From: Johan Myreen (jem@vipunen.hut.fi)
Date: 10/05/92


From: jem@vipunen.hut.fi (Johan Myreen)
Subject: /bin/echo
Date: 5 Oct 1992 21:34:09 GMT

In article <1992Oct3.110121.11725@klaava.Helsinki.FI> wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:

>Apart from that, a simple /bin/echo can be written rather easily. See
>the end of this posting for the version I use.

Just for the fun, here's a version of /bin/echo I wrote some time ago.

Sadly, the C standard does not allow this kind of recursion. But it
works! Implementing the -n switch is left as an exercise to the
reader...

#include <stdio.h>
int main(int argc, char **argv)
{
        switch (--argc) {
        case 0:
                break;
        case 1:
                printf("%s\n", *++argv);
                break;
        default:
                printf("%s ", *++argv);
                main(argc, argv);
        }
        return 0;
}