Mercurial > illumos > illumos-gate
changeset 4305:1e1c1efdc717
1218270 *cat*: cat reports errors in a non-standard fashion
Contributed by River Tarnell <river@attenuate.org>
author | casper |
---|---|
date | Thu, 24 May 2007 06:51:03 -0700 |
parents | cb8b0d33b082 |
children | 8c27001b19c8 |
files | usr/src/cmd/cat/cat.c |
diffstat | 1 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/cat/cat.c Wed May 23 22:18:37 2007 -0700 +++ b/usr/src/cmd/cat/cat.c Thu May 24 06:51:03 2007 -0700 @@ -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 @@ 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 @@ 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 @@ 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 @@ if (fclose(fi) != 0) if (!silent) (void) fprintf(stderr, - gettext("cat: close error\n")); + gettext("cat: close error: %s\n"), + strerror(errno)); } }