Mercurial > hg > toybox
view toys/basename.c @ 183:93899f7c3e0c
Rebuild toybox when a header file changes
author | Charlie Shepherd <masterdriverz@gentoo.org> |
---|---|
date | Sun, 25 Nov 2007 16:54:29 +0000 |
parents | 00bbb7f65b6f |
children | 25447caf1b4b |
line wrap: on
line source
/* vi: set sw=4 ts=4: */ /* basename.c - print non-directory portion of path * * See http://www.opengroup.org/onlinepubs/009695399/utilities/basename.html */ #include "toys.h" int basename_main(void) { char *name = basename(*toys.optargs); char *suffix = toys.optargs[1]; if (suffix) { char *end = name+strlen(name)-strlen(suffix); if (end>name && !strcmp(end,suffix)) *end=0; } puts(name); return 0; }