blob: 982606a8f99c39970c36ffee498df3655b93e794 (
plain) (
tree)
|
|
#include <unistd.h>
#include <string.h>
#include <libgen.h>
static int my_write(int fd, const char *s, size_t l)
{
if (!l) l = strlen(s);
while (l) {
ssize_t n = write(fd, s, l);
if (n<0) return -1;
s += n; l -= n;
}
return 0;
}
int main(int argc, char *argv[])
{
char *s;
if (argc != 2) {
my_write(2, argv[0], 0);
my_write(2, ": missing operand\n", 0);
return 1;
}
s = dirname(argv[1]);
if (my_write(1, s, 0)<0 || my_write(1, "\n", 1)<0)
return 1;
return 0;
}
|