changeset 839:1067e99efbdc

ccwrap shouldn't segfault if PATH isn't exported. (Thanks to Wangji Hoan for spotting this bug.)
author Rob Landley <rob@landley.net>
date Thu, 08 Oct 2009 01:02:05 -0500
parents 3cd64af0d1b6
children 96b276eda7f1
files sources/toys/ccwrap.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sources/toys/ccwrap.c	Tue Oct 06 17:57:23 2009 -0500
+++ b/sources/toys/ccwrap.c	Thu Oct 08 01:02:05 2009 -0500
@@ -64,6 +64,9 @@
 
 char *find_in_path(char *path, char *filename, int has_exe)
 {
+	// Don't segfault if $PATH wasn't exported
+	if (!path) return 0;
+
 	char *cwd = getcwd(NULL, 0);
 
 	if (index(filename, '/') && is_file(filename, has_exe))
@@ -130,7 +133,7 @@
 
 	// What directory is the wrapper script in?
 	if(!(topdir = find_in_path(getenv("PATH"), argv[0], 1))) {
-		fprintf(stderr, "can't find %s in $PATH\n", argv[0]);
+		fprintf(stderr, "can't find %s in $PATH (did you export it?)\n", argv[0]);
 		exit(1);
 	} else {
 		char *path = getenv("PATH"), *temp;