aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-03-01 11:35:13 +0000
committerRon Yorston <rmy@pobox.com>2019-03-01 11:35:13 +0000
commitd6a7bfff8a510bb4035fbd1cf29b555abff65b2f (patch)
tree803737f93f85a74c2b9ade9cd41b53a0cbbdc270
parent9e341902d55184668682ece2c774db62eadb5502 (diff)
downloadbusybox-w32-d6a7bfff8a510bb4035fbd1cf29b555abff65b2f.tar.gz
busybox-w32-d6a7bfff8a510bb4035fbd1cf29b555abff65b2f.tar.bz2
busybox-w32-d6a7bfff8a510bb4035fbd1cf29b555abff65b2f.zip
ash: add an option to enable case-insensitive filename globbing
The 'nocaseglob' shell option enables case-insensitive filename globbing. By default globbing is case-sensitive.
-rw-r--r--shell/ash.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c
index d63304bdb..b276544a6 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -169,10 +169,18 @@
169//config: default y 169//config: default y
170//config: depends on (ASH || SH_IS_ASH || BASH_IS_ASH) && PLATFORM_MINGW32 170//config: depends on (ASH || SH_IS_ASH || BASH_IS_ASH) && PLATFORM_MINGW32
171//config: help 171//config: help
172//config: Enable support for the 'noconsole' option, which attempts to 172//config: Enable support for the 'noconsole' option, which attempts to
173//config: hide the console normally associated with a command line 173//config: hide the console normally associated with a command line
174//config: application. This may be useful when running a shell script 174//config: application. This may be useful when running a shell script
175//config: from a GUI application. 175//config: from a GUI application.
176//config:
177//config:config ASH_NOCASEGLOB
178//config: bool "'nocaseglob' option"
179//config: default y
180//config: depends on (ASH || SH_IS_ASH || BASH_IS_ASH) && PLATFORM_MINGW32
181//config: help
182//config: Enable support for the 'nocaseglob' option, which allows
183//config: case-insensitive filename globbing.
176//config: 184//config:
177//config:endif # ash options 185//config:endif # ash options
178 186
@@ -430,6 +438,9 @@ static const char *const optletters_optnames[] = {
430#if ENABLE_ASH_NOCONSOLE 438#if ENABLE_ASH_NOCONSOLE
431 ,"\0" "noconsole" 439 ,"\0" "noconsole"
432#endif 440#endif
441#if ENABLE_ASH_NOCASEGLOB
442 ,"\0" "nocaseglob"
443#endif
433}; 444};
434 445
435#define optletters(n) optletters_optnames[n][0] 446#define optletters(n) optletters_optnames[n][0]
@@ -522,6 +533,9 @@ struct globals_misc {
522#if ENABLE_ASH_NOCONSOLE 533#if ENABLE_ASH_NOCONSOLE
523# define noconsole optlist[15 + BASH_PIPEFAIL + 2*DEBUG] 534# define noconsole optlist[15 + BASH_PIPEFAIL + 2*DEBUG]
524#endif 535#endif
536#if ENABLE_ASH_NOCASEGLOB
537# define nocaseglob optlist[15 + BASH_PIPEFAIL + 2*DEBUG + ENABLE_ASH_NOCONSOLE]
538#endif
525 539
526 /* trap handler commands */ 540 /* trap handler commands */
527 /* 541 /*
@@ -8138,6 +8152,10 @@ expmeta(exp_t *exp, char *name, unsigned name_len, unsigned expdir_len)
8138 while (!pending_int && (dp = readdir(dirp)) != NULL) { 8152 while (!pending_int && (dp = readdir(dirp)) != NULL) {
8139 if (dp->d_name[0] == '.' && !matchdot) 8153 if (dp->d_name[0] == '.' && !matchdot)
8140 continue; 8154 continue;
8155#if ENABLE_ASH_NOCASEGLOB
8156# undef pmatch
8157# define pmatch(a, b) !fnmatch((a), (b), nocaseglob ? FNM_CASEFOLD : 0)
8158#endif
8141 if (pmatch(start, dp->d_name)) { 8159 if (pmatch(start, dp->d_name)) {
8142 if (atend) { 8160 if (atend) {
8143 strcpy(enddir, dp->d_name); 8161 strcpy(enddir, dp->d_name);
@@ -8167,6 +8185,10 @@ expmeta(exp_t *exp, char *name, unsigned name_len, unsigned expdir_len)
8167 endname[-esc - 1] = esc ? '\\' : '/'; 8185 endname[-esc - 1] = esc ? '\\' : '/';
8168#undef expdir 8186#undef expdir
8169#undef expdir_max 8187#undef expdir_max
8188#if ENABLE_ASH_NOCASEGLOB
8189# undef pmatch
8190# define pmatch(a, b) !fnmatch((a), (b), 0)
8191#endif
8170} 8192}
8171 8193
8172static struct strlist * 8194static struct strlist *