From 0f6d6099781024973e85c228bb3465884d223d08 Mon Sep 17 00:00:00 2001 From: Mark Nudelman Date: Thu, 27 Jul 2017 09:37:17 -0700 Subject: [PATCH] Fix bug in fcomplete when pattern does not match any file. --- .gitignore | 1 + filename.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f9a64020..2d75d015 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ obj/** release/** unicode/** *.cache +*.old NEWS README configure diff --git a/filename.c b/filename.c index 1ee9e1e9..73f83528 100644 --- a/filename.c +++ b/filename.c @@ -397,6 +397,7 @@ fcomplete(s) char *s; { char *fpat; + char *qs; if (secure) return (NULL); @@ -431,18 +432,19 @@ fcomplete(s) SNPRINTF1(fpat, len, "%s*", s); } #endif - s = lglob(fpat); + qs = lglob(fpat); + s = shell_unquote(qs); if (strcmp(s,fpat) == 0) { /* * The filename didn't expand. */ - free(s); - free(fpat); - return (NULL); + free(qs); + qs = NULL; } + free(s); free(fpat); - return (s); + return (qs); } #endif