diff options
author | Ron Yorston <rmy@pobox.com> | 2023-12-09 09:43:06 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-12-09 09:43:06 +0000 |
commit | 6bb25c4493268d24a3b82d3268b2adf624de88bd (patch) | |
tree | c68887dd2e818685192b5496e3e676944008af57 /libbb/appletlib.c | |
parent | 7dff7f37600209353cf4e86d1cca29bacf5f7372 (diff) | |
download | busybox-w32-6bb25c4493268d24a3b82d3268b2adf624de88bd.tar.gz busybox-w32-6bb25c4493268d24a3b82d3268b2adf624de88bd.tar.bz2 busybox-w32-6bb25c4493268d24a3b82d3268b2adf624de88bd.zip |
win32: allow hardcoded list of applets to override
The environment variable BB_OVERRIDE_APPLETS provides control over
which applets are preferred in standalone shell mode. Allow a
similar list to be hardcoded in the binary with the OVERRIDE_APPLETS
configuration string.
The environment variable is checked first. If it doesn't override
the applet the hardcoded string is then checked too.
The default for OVERRIDE_APPLETS is an empty string. In this case
the size and behaviour of the binary is unchanged.
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r-- | libbb/appletlib.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 6b610743a..3c9cebf1e 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -282,12 +282,11 @@ static int external_exists(const char *name) | |||
282 | return ret != NULL; | 282 | return ret != NULL; |
283 | } | 283 | } |
284 | 284 | ||
285 | int FAST_FUNC is_applet_preferred(const char *name) | 285 | static int is_applet_preferred_by_var(const char *name, const char *var) |
286 | { | 286 | { |
287 | const char *var, *s, *sep; | 287 | const char *s, *sep; |
288 | size_t len; | 288 | size_t len; |
289 | 289 | ||
290 | var = getenv(BB_OVERRIDE_APPLETS); | ||
291 | if (var && *var) { | 290 | if (var && *var) { |
292 | /* '-' disables all applets */ | 291 | /* '-' disables all applets */ |
293 | if (var[0] == '-' && var[1] == '\0') | 292 | if (var[0] == '-' && var[1] == '\0') |
@@ -319,6 +318,14 @@ int FAST_FUNC is_applet_preferred(const char *name) | |||
319 | } | 318 | } |
320 | return TRUE; | 319 | return TRUE; |
321 | } | 320 | } |
321 | |||
322 | int FAST_FUNC is_applet_preferred(const char *name) | ||
323 | { | ||
324 | int ret = is_applet_preferred_by_var(name, getenv(BB_OVERRIDE_APPLETS)); | ||
325 | if (sizeof(CONFIG_OVERRIDE_APPLETS) > 1 && ret) | ||
326 | ret = is_applet_preferred_by_var(name, CONFIG_OVERRIDE_APPLETS); | ||
327 | return ret; | ||
328 | } | ||
322 | #endif | 329 | #endif |
323 | 330 | ||
324 | 331 | ||