Mercurial > hg > toybox
view toys/basename.c @ 186:25447caf1b4b
Change command main() functions to return void, and exit(toys.exitval) from
the toybox infrastructure instead. Eliminates a return call from each command.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 29 Nov 2007 18:14:37 -0600 |
parents | 00bbb7f65b6f |
children | d4176f3f3835 |
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" void 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); }