From 5239e8ea4c8bfc759da346d74220f34ecc4d8c13 Mon Sep 17 00:00:00 2001 From: tg Date: Wed, 16 Mar 2011 20:56:33 +0000 Subject: [PATCH] =?UTF-8?q?actually,=20we=20need=20the=20android=20lsmod?= =?UTF-8?q?=20to=20be=20a=20builtin=20not=20an=20alias=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check.t | 76 +++------------------------------------------------------ funcs.c | 20 ++++++++++++++- main.c | 7 ++---- 3 files changed, 25 insertions(+), 78 deletions(-) diff --git a/check.t b/check.t index 75b0688..9ef2766 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.428 2011/03/16 20:26:34 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.429 2011/03/16 20:56:30 tg Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ @@ -5528,7 +5528,7 @@ expected-stdout: name: aliases-1-hartz4 description: Check if built-in shell aliases are okay -category: arge +category: android,arge stdin: alias typeset -f @@ -5546,28 +5546,6 @@ expected-stdout: source='PATH=$PATH:. command .' type='whence -v' --- -name: aliases-1-android -description: - Check if built-in shell aliases are okay -category: android -stdin: - alias - typeset -f -expected-stdout: - autoload='typeset -fu' - functions='typeset -f' - hash='alias -t' - history='fc -l' - integer='typeset -i' - local=typeset - login='exec login' - lsmod='cat /proc/modules' - nameref='typeset -n' - nohup='nohup ' - r='fc -e -' - source='PATH=$PATH:. command .' - type='whence -v' ---- name: aliases-2a description: Check if “set -o sh” disables built-in aliases (except a few) @@ -5643,7 +5621,7 @@ expected-stdout: name: aliases-2b-hartz4 description: Check if “set -o sh” does not influence built-in aliases -category: arge +category: android,arge arguments: !-o!sh! stdin: alias @@ -5665,7 +5643,7 @@ expected-stdout: name: aliases-3b-hartz4 description: Check if running as sh does not influence built-in aliases -category: arge +category: android,arge stdin: cp "$__progname" sh ./sh -c 'alias; typeset -f' @@ -5684,52 +5662,6 @@ expected-stdout: source='PATH=$PATH:. command .' type='whence -v' --- -name: aliases-2b-android -description: - Check if “set -o sh” does not influence built-in aliases -category: android -arguments: !-o!sh! -stdin: - alias - typeset -f -expected-stdout: - autoload='typeset -fu' - functions='typeset -f' - hash='alias -t' - history='fc -l' - integer='typeset -i' - local=typeset - login='exec login' - lsmod='cat /proc/modules' - nameref='typeset -n' - nohup='nohup ' - r='fc -e -' - source='PATH=$PATH:. command .' - type='whence -v' ---- -name: aliases-3b-android -description: - Check if running as sh does not influence built-in aliases -category: android -stdin: - cp "$__progname" sh - ./sh -c 'alias; typeset -f' - rm -f sh -expected-stdout: - autoload='typeset -fu' - functions='typeset -f' - hash='alias -t' - history='fc -l' - integer='typeset -i' - local=typeset - login='exec login' - lsmod='cat /proc/modules' - nameref='typeset -n' - nohup='nohup ' - r='fc -e -' - source='PATH=$PATH:. command .' - type='whence -v' ---- name: aliases-funcdef-1 description: Check if POSIX functions take precedences over aliases diff --git a/funcs.c b/funcs.c index 94b3e26..ead7b0b 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #endif #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.176 2011/03/13 01:20:19 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.177 2011/03/16 20:56:32 tg Exp $"); #if HAVE_KILLPG /* @@ -60,6 +60,10 @@ __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.176 2011/03/13 01:20:19 tg Exp $"); #define c_ulimit c_label #endif +#if defined(ANDROID) +static int c_android_lsmod(const char **); +#endif + extern uint8_t set_refflag; /* @@ -130,6 +134,9 @@ const struct builtin mkshbuiltins[] = { #ifdef __MirBSD__ /* alias to "true" for historical reasons */ {"domainname", c_label}, +#endif +#if defined(ANDROID) + {"lsmod", c_android_lsmod}, #endif {NULL, (int (*)(const char **))NULL} }; @@ -3717,3 +3724,14 @@ c_sleep(const char **wp) return (rv); } #endif + +#if defined(ANDROID) +static int +c_android_lsmod(const char **wp MKSH_A_UNUSED) +{ + const char *cwp[3] = { "cat", "/proc/modules", NULL }; + + builtin_argv0 = cwp[0]; + return (c_cat(cwp)); +} +#endif diff --git a/main.c b/main.c index a169ef3..7802245 100644 --- a/main.c +++ b/main.c @@ -33,7 +33,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.183 2011/03/16 20:43:34 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.184 2011/03/16 20:56:33 tg Exp $"); extern char **environ; @@ -70,10 +70,7 @@ static const char *initcoms[] = { /* not "alias -t --": hash -r needs to work */ "hash=alias -t", "type=whence -v", -#if defined(ANDROID) - /* evil hack */ - "lsmod=cat /proc/modules", -#elif !defined(MKSH_UNEMPLOYED) +#if !defined(ANDROID) && !defined(MKSH_UNEMPLOYED) /* not in Android for political reasons */ /* not in ARGE mksh due to no job control */ "stop=kill -STOP",