Hi,

had a sleepless night, so contributing sleep.c and sleep.1.

Thanks,
Kamil

On Mon, May 23, 2011 at 03:15:43AM +0100, Connor Lane Smith wrote:
> Hey all,
> 
> I think it's about time we started a minimalist, statically linked set
> of core utilities. The BSD family are bloated, and the GNU monstrous.
> Some of us seem to be resorting to using those from Plan 9, which were
> designed for another operating system and exist on Unix through a
> compatibility shim.
> 
> So, in a glorious demonstration of NIH syndrome, let's make our own!
> I'm unsure exactly which utilities we should include (suggestions on a
> comprehensive set?), but in terms of functionality a good rule of
> thumb is to only include flags present in both POSIX and Plan 9, thus
> making a sweet little subset. There are exceptions to this, like grep
> -q and ls -a, but it's a useful guideline.
> 
> I've written a handful so far (basename, cat, echo, false, grep, tee,
> touch, true, wc), which I've attached. Each tool is between 6 and 88
> SLOC, and compiles with musl into a static binary between 13K and 45K
> in size. The manual pages are nice and short, too.
> 
> If anyone else wants to contribute a tool written in the same style
> they are most welcome. I'd like to set up an hg repo soon, but I'm
> quite busy with exams atm.
> 
> Thanks,
> cls


.TH SLEEP 1 sbase\-VERSION
.SH NAME
sleep \- wait for a specified amount of time
.SH SYNOPSIS
.B sleep
.RI SECONDS
.SH DESCRIPTION
Wait until SECONDS have elapsed.
/* See LICENSE file for copyright and license details. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "util.h"

int
main(int argc, char *argv[])
{
	int seconds;

	if (argc != 2)
		eprintf("usage: %s SECONDS\n", argv[0]);
	else {
		seconds = atoi(argv[1]);
		while (0 != (seconds = sleep(seconds)));
	}
	return EXIT_SUCCESS;
}

Reply via email to