Mercurial > hg > toybox
annotate toys/dirname.c @ 312:064fc1b8b7b1
Chroot should stop option parsing at the first non-option argument.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 15 Aug 2008 14:14:10 -0500 |
parents | 5e8ca70863aa |
children |
rev | line source |
---|---|
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
1 /* vi: set sw=4 ts=4: |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
2 * |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
3 * dirname.c - print directory portion of path, or "." if none. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
4 * |
248
5e8ca70863aa
Fix copyright name
Charlie Shepherd <masterdriverz@gentoo.org>
parents:
234
diff
changeset
|
5 * Copyright 2007 Charlie Shepherd <masterdriverz@gentoo.org> |
178
0e94f5f14f08
Add comment and very minor tweak.
Rob Landley <rob@landley.net>
parents:
176
diff
changeset
|
6 * |
0e94f5f14f08
Add comment and very minor tweak.
Rob Landley <rob@landley.net>
parents:
176
diff
changeset
|
7 * See http://www.opengroup.org/onlinepubs/009695399/utilities/dirname.html |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
8 |
234
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
9 USE_DIRNAME(NEWTOY(dirname, "<1>1", TOYFLAG_BIN)) |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
10 |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
11 config DIRNAME |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
12 bool "dirname" |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
13 default y |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
14 help |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
15 usage: dirname path |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
16 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
17 Print the part of path up to the last slash. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
18 */ |
178
0e94f5f14f08
Add comment and very minor tweak.
Rob Landley <rob@landley.net>
parents:
176
diff
changeset
|
19 |
176
07533cabeede
Patch from Charlie Shepherd to add basename and dirname. (Fixed up to apply.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 #include "toys.h" |
07533cabeede
Patch from Charlie Shepherd to add basename and dirname. (Fixed up to apply.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 #include <libgen.h> |
07533cabeede
Patch from Charlie Shepherd to add basename and dirname. (Fixed up to apply.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 |
186
25447caf1b4b
Change command main() functions to return void, and exit(toys.exitval) from
Rob Landley <rob@landley.net>
parents:
178
diff
changeset
|
23 void dirname_main(void) |
176
07533cabeede
Patch from Charlie Shepherd to add basename and dirname. (Fixed up to apply.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
24 { |
178
0e94f5f14f08
Add comment and very minor tweak.
Rob Landley <rob@landley.net>
parents:
176
diff
changeset
|
25 puts(dirname(*toys.optargs)); |
176
07533cabeede
Patch from Charlie Shepherd to add basename and dirname. (Fixed up to apply.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
26 } |