Patch from Charlie Shepherd to add basename and dirname.  (Fixed up to apply.)
diff --git a/toys/Config.in b/toys/Config.in
index 04640c5..34c3110 100644
--- a/toys/Config.in
+++ b/toys/Config.in
@@ -11,6 +11,14 @@
 	  With no arguments, shows available commands.  First argument is
 	  name of a command to run, followed by any arguments to that command.
 
+config BASENAME
+	bool "basename"
+	default y
+	help
+	  usage: basename path
+
+	  Print the part of path after the last slash.
+
 config BZCAT
 	bool "bzcat"
 	default n
@@ -68,6 +76,14 @@
 
 	  -k	Sets units back to 1024 bytes (the default without -P)
 
+config DIRNAME
+	bool "dirname"
+	default y
+	help
+	  usage: dirname path
+
+	  Print the part of path up to the last slash.
+
 config DMESG
 	bool "dmesg"
 	default y
diff --git a/toys/basename.c b/toys/basename.c
new file mode 100644
index 0000000..2ea6882
--- /dev/null
+++ b/toys/basename.c
@@ -0,0 +1,15 @@
+#include "toys.h"
+
+int basename_main(void)
+{
+	char *name = basename(toys.optargs[0]);
+	if (toys.optargs[1]) {
+		int slen = strlen(toys.optargs[1]);
+		int name_len = strlen(name);
+		if (slen < name_len)
+			if (!strcmp(name+name_len-slen, toys.optargs[1]))
+				*(name+name_len-slen) = '\0';
+	}
+	puts(name);
+	return 0;
+}
diff --git a/toys/dirname.c b/toys/dirname.c
new file mode 100644
index 0000000..454a5d6
--- /dev/null
+++ b/toys/dirname.c
@@ -0,0 +1,8 @@
+#include "toys.h"
+#include <libgen.h>
+
+int dirname_main(void)
+{
+	puts(dirname(toys.optargs[0]));
+	return 0;
+}
diff --git a/toys/toylist.h b/toys/toylist.h
index a55a56a..87bffed 100644
--- a/toys/toylist.h
+++ b/toys/toylist.h
@@ -105,11 +105,13 @@
 
 // The rest of these are alphabetical, for binary search.
 
+USE_BASENAME(NEWTOY(basename, "<1>2", TOYFLAG_BIN))
 USE_BZCAT(NEWTOY(bzcat, "", TOYFLAG_USR|TOYFLAG_BIN))
 USE_CATV(NEWTOY(catv, "vte", TOYFLAG_USR|TOYFLAG_BIN))
 USE_COUNT(NEWTOY(count, "", TOYFLAG_USR|TOYFLAG_BIN))
 USE_TOYSH(NEWTOY(cd, NULL, TOYFLAG_NOFORK))
 USE_DF(NEWTOY(df, "Pkt*a", TOYFLAG_USR|TOYFLAG_SBIN))
+USE_DIRNAME(NEWTOY(dirname, "<1>1", TOYFLAG_BIN))
 USE_DMESG(NEWTOY(dmesg, "s#n#c", TOYFLAG_BIN))
 USE_ECHO(NEWTOY(echo, "+en", TOYFLAG_BIN))
 USE_TOYSH(NEWTOY(exit, NULL, TOYFLAG_NOFORK))