2049 env(1) should print program it attempts to exec on error, not argv[0]
authorRobert Mustacchi <rm@joyent.com>
Tue, 29 May 2012 13:58:04 -0700
changeset 13707 3f41b24ce657
parent 13706 b83bad61dfe1
child 13708 6d0517b1a52b
2049 env(1) should print program it attempts to exec on error, not argv[0] Reviewed by: Dave Pacheco <[email protected]> Reviewed by: Dan Kruchinin <[email protected]> Reviewed by: Dan McDonald <[email protected]> Reviewed by: Jason King <[email protected]> Reviewed by: Garrett D'Amore <[email protected]> Reviewed by: Albert Lee <[email protected]> Approved by: Eric Schrock <[email protected]>
usr/src/cmd/env/env.c
--- a/usr/src/cmd/env/env.c	Tue May 29 11:05:54 2012 -0400
+++ b/usr/src/cmd/env/env.c	Tue May 29 13:58:04 2012 -0700
@@ -20,6 +20,9 @@
  */
 
 /*
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ */
+/*
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
@@ -101,7 +104,8 @@
 			(void) puts(*p++);
 	} else {
 		(void) execvp(argv[optind],  &argv[optind]);
-		(void) perror(argv[0]);
+		(void) fprintf(stderr, "%s: %s: %s\n", argv[0], argv[optind],
+		    strerror(errno));
 		exit(((errno == ENOENT) || (errno == ENOTDIR)) ? 127 : 126);
 	}
 	return (0);