aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-01 14:33:08 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-01 14:33:08 +0200
commit514b51ddf3474647e7089e467d4c01107c357fac (patch)
tree57a794eabd0c1db9966088f3268ddd804d42f9a5
parentcac4d002e78339272f75952959b4ce78b9239e7f (diff)
downloadbusybox-w32-514b51ddf3474647e7089e467d4c01107c357fac.tar.gz
busybox-w32-514b51ddf3474647e7089e467d4c01107c357fac.tar.bz2
busybox-w32-514b51ddf3474647e7089e467d4c01107c357fac.zip
ash: make internal globbing code selectable from config
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c82
1 files changed, 50 insertions, 32 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 4adf92ac2..dcf92da82 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -39,13 +39,22 @@
39 39
40#include <setjmp.h> 40#include <setjmp.h>
41#include <fnmatch.h> 41#include <fnmatch.h>
42#include <glob.h>
43#include <sys/times.h> 42#include <sys/times.h>
44#include <sys/utsname.h> /* for setting $HOSTNAME */ 43#include <sys/utsname.h> /* for setting $HOSTNAME */
45 44
46#include "busybox.h" /* for applet_names */ 45#include "busybox.h" /* for applet_names */
47#include "unicode.h"
48 46
47#if defined(__ANDROID_API__) && __ANDROID_API__ <= 24
48/* Bionic at least up to version 24 has no glob() */
49# undef ENABLE_ASH_INTERNAL_GLOB
50# define ENABLE_ASH_INTERNAL_GLOB 0
51#endif
52
53#if !ENABLE_ASH_INTERNAL_GLOB
54# include <glob.h>
55#endif
56
57#include "unicode.h"
49#include "shell_common.h" 58#include "shell_common.h"
50#if ENABLE_SH_MATH_SUPPORT 59#if ENABLE_SH_MATH_SUPPORT
51# include "math.h" 60# include "math.h"
@@ -87,6 +96,42 @@
87//config: shell (by Herbert Xu), which was created by porting the 'ash' shell 96//config: shell (by Herbert Xu), which was created by porting the 'ash' shell
88//config: (written by Kenneth Almquist) from NetBSD. 97//config: (written by Kenneth Almquist) from NetBSD.
89//config: 98//config:
99//config:config ASH_OPTIMIZE_FOR_SIZE
100//config: bool "Optimize for size instead of speed"
101//config: default y
102//config: depends on ASH
103//config: help
104//config: Compile ash for reduced size at the price of speed.
105//config:
106//config:config ASH_INTERNAL_GLOB
107//config: bool "Use internal glob() implementation"
108//config: default n
109//config: depends on ASH
110//config: help
111//config: Do not use glob() function from libc, use internal implementation.
112//config: Use this if you are getting "glob.h: No such file or directory"
113//config: or similar build errors.
114//config:
115//config:config ASH_RANDOM_SUPPORT
116//config: bool "Pseudorandom generator and $RANDOM variable"
117//config: default y
118//config: depends on ASH
119//config: help
120//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
121//config: Each read of "$RANDOM" will generate a new pseudorandom value.
122//config: You can reset the generator by using a specified start value.
123//config: After "unset RANDOM" the generator will switch off and this
124//config: variable will no longer have special treatment.
125//config:
126//config:config ASH_EXPAND_PRMT
127//config: bool "Expand prompt string"
128//config: default y
129//config: depends on ASH
130//config: help
131//config: "PS#" may contain volatile content, such as backquote commands.
132//config: This option recreates the prompt string from the environment
133//config: variable each time it is displayed.
134//config:
90//config:config ASH_BASH_COMPAT 135//config:config ASH_BASH_COMPAT
91//config: bool "bash-compatible extensions" 136//config: bool "bash-compatible extensions"
92//config: default y 137//config: default y
@@ -166,33 +211,6 @@
166//config: help 211//config: help
167//config: Enable "check for new mail" function in the ash shell. 212//config: Enable "check for new mail" function in the ash shell.
168//config: 213//config:
169//config:config ASH_OPTIMIZE_FOR_SIZE
170//config: bool "Optimize for size instead of speed"
171//config: default y
172//config: depends on ASH
173//config: help
174//config: Compile ash for reduced size at the price of speed.
175//config:
176//config:config ASH_RANDOM_SUPPORT
177//config: bool "Pseudorandom generator and $RANDOM variable"
178//config: default y
179//config: depends on ASH
180//config: help
181//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
182//config: Each read of "$RANDOM" will generate a new pseudorandom value.
183//config: You can reset the generator by using a specified start value.
184//config: After "unset RANDOM" the generator will switch off and this
185//config: variable will no longer have special treatment.
186//config:
187//config:config ASH_EXPAND_PRMT
188//config: bool "Expand prompt string"
189//config: default y
190//config: depends on ASH
191//config: help
192//config: "PS#" may contain volatile content, such as backquote commands.
193//config: This option recreates the prompt string from the environment
194//config: variable each time it is displayed.
195//config:
196 214
197//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) 215//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
198//applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh)) 216//applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh))
@@ -6994,7 +7012,7 @@ addfname(const char *name)
6994} 7012}
6995 7013
6996/* If we want to use glob() from libc... */ 7014/* If we want to use glob() from libc... */
6997#if 1 7015#if !ENABLE_ASH_INTERNAL_GLOB
6998 7016
6999/* Add the result of glob() to the list */ 7017/* Add the result of glob() to the list */
7000static void 7018static void
@@ -7055,7 +7073,7 @@ nometa:
7055} 7073}
7056 7074
7057#else 7075#else
7058/* Homegrown globbing code. (dash also has both, uses homegrown one.) */ 7076/* ENABLE_ASH_INTERNAL_GLOB: Homegrown globbing code. (dash also has both, uses homegrown one.) */
7059 7077
7060/* 7078/*
7061 * Do metacharacter (i.e. *, ?, [...]) expansion. 7079 * Do metacharacter (i.e. *, ?, [...]) expansion.
@@ -7286,7 +7304,7 @@ expandmeta(struct strlist *str /*, int flag*/)
7286 str = str->next; 7304 str = str->next;
7287 } 7305 }
7288} 7306}
7289#endif /* our globbing code */ 7307#endif /* ENABLE_ASH_INTERNAL_GLOB */
7290 7308
7291/* 7309/*
7292 * Perform variable substitution and command substitution on an argument, 7310 * Perform variable substitution and command substitution on an argument,