diff options
| author | casper <none@none> | 2007-05-24 06:51:03 -0700 |
|---|---|---|
| committer | casper <none@none> | 2007-05-24 06:51:03 -0700 |
| commit | 5b095dea6b95c930f7cab39fd243b03256f37802 (patch) | |
| tree | 210c50f897caa27f6eeb2d3160b2a5ba414ca081 /usr/src/cmd/cat | |
| parent | 1cce8a3fd4de339002c756b920bbddde497b9f78 (diff) | |
| download | illumos-joyent-5b095dea6b95c930f7cab39fd243b03256f37802.tar.gz | |
1218270 *cat*: cat reports errors in a non-standard fashion
Contributed by River Tarnell <river@attenuate.org>
Diffstat (limited to 'usr/src/cmd/cat')
| -rw-r--r-- | usr/src/cmd/cat/cat.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/usr/src/cmd/cat/cat.c b/usr/src/cmd/cat/cat.c index 7436e5b53a..3088d50116 100644 --- a/usr/src/cmd/cat/cat.c +++ b/usr/src/cmd/cat/cat.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -24,7 +23,7 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -42,6 +41,8 @@ #include <locale.h> #include <unistd.h> #include <sys/mman.h> +#include <errno.h> +#include <string.h> #include <widec.h> #include <wctype.h> @@ -240,7 +241,8 @@ main(int argc, char **argv) if ((fi = fopen(*argv, "r")) == NULL) { if (!silent) (void) fprintf(stderr, - gettext("cat: cannot open %s\n"), *argv); + gettext("cat: cannot open %s: %s\n"), + *argv, strerror(errno)); status = 2; continue; } @@ -253,8 +255,8 @@ main(int argc, char **argv) if (fstat(fileno(fi), &source) < 0) { if (!silent) (void) fprintf(stderr, - gettext("cat: cannot stat %s\n"), - (stdinflg) ? "-" : *argv); + gettext("cat: cannot stat %s: %s\n"), + (stdinflg) ? "-" : *argv, strerror(errno)); status = 2; continue; } @@ -276,7 +278,8 @@ main(int argc, char **argv) stdinflg?"-": *argv); if (fclose(fi) != 0) (void) fprintf(stderr, - gettext("cat: close error\n")); + gettext("cat: close error: %s\n"), + strerror(errno)); status = 2; continue; } @@ -304,7 +307,8 @@ main(int argc, char **argv) if (fclose(fi) != 0) if (!silent) (void) fprintf(stderr, - gettext("cat: close error\n")); + gettext("cat: close error: %s\n"), + strerror(errno)); } } |
