Sam Trenholme's webpage
This article was posted to the Usenet group alt.hackers in 1995; any technical information is probably outdated.

Smallest Unix Shell

Article: 8651 of alt.hackers
From: (Warren Toomey)
Newsgroups: alt.hackers
Subject: Smallest Unix Shell
Date: 21 Sep 1995 00:00:52 GMT
Organization: Australian Defence Force Academy
Lines: 26
Distribution: world
Message-ID: 43q9vk$
Status: RO

ObHack: A challenge with a friend to come up with the smallest Unix shell in C.
Here's the results, the smallest being 123 characters (124 with a \n):

strtok(c," ");c=0);(fork()||execvp(*v,v))&&wait(0);}}

strtok(c," ");c=0);fork()?wait(0):execvp(*v,v);}}

strsep(&c," "););fork()?wait(0):execvp(*v,v);}}

strsep(&c," "););fork()?wait(0):execvp(*v,v);}}

I've broken them into 2 lines each for easier reading. Fixing the small bug
that all four versions have would increase the size by at least 10 characters.



Copyright (c) 1995, Warren Toomey. Microsoft Network is prohibited from
redistributing this work in any form, in whole or in part, without a license.
License to distribute this post is available to Microsoft for $1000.
Posting without permission constitutes an agreement to these terms.

Child Child Child Child

Back to index