~emersion/mrsh-dev

entry.c: fix absolute path test v1 APPLIED

Drew DeVault: 1
 entry.c: fix absolute path test

 1 files changed, 3 insertions(+), 7 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/mrsh-dev/patches/9125/mbox | git am -3
Learn more about email & git

[PATCH] entry.c: fix absolute path test Export this patch

Fixes #120
---
 shell/entry.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/shell/entry.c b/shell/entry.c
index 9bbcbfe..b5e9846 100644
--- a/shell/entry.c
+++ b/shell/entry.c
@@ -119,16 +119,12 @@ void mrsh_source_env(struct mrsh_state *state) {
 		return;
 	}
 	path = expand_parameter(state, path);
-	char *real = realpath(path, NULL);
-	if (strcmp(path, real) != 0) {
+	if (path[0] != '/') {
 		fprintf(stderr, "Error: $ENV is not an absolute path; "
 				"this is undefined behavior.\n");
 		fprintf(stderr, "Continuing without sourcing it.\n");
-		free(path);
-		free(real);
-		return;
+	} else {
+		source_file(state, path);
 	}
-	source_file(state, real);
 	free(path);
-	free(real);
 }
-- 
2.24.0
Pushed:

To git.sr.ht:~emersion/mrsh
   715e6efeb77b..307cb3693614  master -> master

Thanks!
View this thread in the archives