1/*- 2 * Copyright (c) 1991, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 27 unchanged lines hidden (view full) --- 36"@(#) Copyright (c) 1991, 1993, 1994\n\ 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41static const char sccsid[] = "@(#)dirname.c 8.4 (Berkeley) 5/4/95"; 42#endif /* not lint */ 43#include <sys/cdefs.h> |
44__FBSDID("$FreeBSD: head/usr.bin/dirname/dirname.c 188006 2009-02-02 11:19:56Z rwatson $"); |
45 46#include <err.h> 47#include <libgen.h> 48#include <stdio.h> 49#include <stdlib.h> 50#include <unistd.h> 51 52void usage(void); --- 8 unchanged lines hidden (view full) --- 61 switch(ch) { 62 case '?': 63 default: 64 usage(); 65 } 66 argc -= optind; 67 argv += optind; 68 |
69 if (argc < 1) |
70 usage(); 71 |
72 while (argc--) { 73 if ((p = dirname(*argv)) == NULL) 74 err(1, "%s", *argv); 75 argv++; 76 (void)printf("%s\n", p); 77 } |
78 exit(0); 79} 80 81void 82usage(void) 83{ 84 |
85 (void)fprintf(stderr, "usage: dirname string [...]\n"); |
86 exit(1); 87} |