aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-30 18:41:01 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-30 18:41:01 +0100
commitd4f3db9427c443b2709fc9a00bc46d8a71be806b (patch)
treef71b9fd8f2eb1509621ec434fb9b664928f637dc
parent474ed06c3939391cbfd7b70bf4960403ae166762 (diff)
downloadbusybox-w32-d4f3db9427c443b2709fc9a00bc46d8a71be806b.tar.gz
busybox-w32-d4f3db9427c443b2709fc9a00bc46d8a71be806b.tar.bz2
busybox-w32-d4f3db9427c443b2709fc9a00bc46d8a71be806b.zip
ash: if using libc glob(), skip it if no metachars are in word
This saves making tons of pointless stat() calls function old new delta expandarg 888 921 +33 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index d617168b9..ecd2146e4 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7047,6 +7047,21 @@ expandmeta(struct strlist *str /*, int flag*/)
7047 7047
7048 if (fflag) 7048 if (fflag)
7049 goto nometa; 7049 goto nometa;
7050
7051 /* Avoid glob() (and thus, stat() et al) for words like "echo" */
7052 p = str->text;
7053 while (*p) {
7054 if (*p == '*')
7055 goto need_glob;
7056 if (*p == '?')
7057 goto need_glob;
7058 if (*p == '[')
7059 goto need_glob;
7060 p++;
7061 }
7062 goto nometa;
7063
7064 need_glob:
7050 INT_OFF; 7065 INT_OFF;
7051 p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP); 7066 p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP);
7052// GLOB_NOMAGIC (GNU): if no *?[ chars in pattern, return it even if no match 7067// GLOB_NOMAGIC (GNU): if no *?[ chars in pattern, return it even if no match