This commit adds support for applet "aliases" for ash and
hush. A similar mechanism is employed in BASH_IS_{ASH,HUSH}.
This new feature allows any user-desired applet name to be
mapped to ash or hush (e.g. "dash", "zsh").This commit uses existing piggyback mechanisms in the Makefile to generate two new header files (ash_aliases.h and hush_aliases.h), which are used by applets.h (using the //applet: syntax in ash.c and hush.c) to add aliases to the shells. Signed-off-by: Nadav Tasher <[email protected]> --- Makefile | 7 ++++++- include/.gitignore | 2 ++ scripts/shell_aliases | 11 +++++++++++ shell/ash.c | 12 ++++++++++++ shell/hush.c | 12 ++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 scripts/shell_aliases diff --git a/Makefile b/Makefile index 9550c391a..0b9b811b2 100644 --- a/Makefile +++ b/Makefile @@ -851,13 +851,16 @@ quiet_cmd_gen_common_bufsiz = GEN include/common_bufsiz.h cmd_gen_common_bufsiz = $(srctree)/scripts/generate_BUFSIZ.sh include/common_bufsiz.h quiet_cmd_split_autoconf = SPLIT include/autoconf.h -> include/config/* cmd_split_autoconf = scripts/basic/split-include include/autoconf.h include/config +quiet_cmd_gen_shell_aliases = GEN include/ash_aliases.h include/hush_aliases.h + cmd_gen_shell_aliases = $(srctree)/scripts/shell_aliases include/ash_aliases.h include/hush_aliases.h quiet_cmd_gen_embedded_scripts = GEN include/embedded_scripts.h cmd_gen_embedded_scripts = $(srctree)/scripts/embedded_scripts include/embedded_scripts.h $(srctree)/embed $(srctree)/applets_sh #bbox# piggybacked generation of few .h files -include/config/MARKER: scripts/basic/split-include include/autoconf.h $(wildcard $(srctree)/embed/*) $(wildcard $(srctree)/applets_sh/*) $(srctree)/scripts/embedded_scripts +include/config/MARKER: scripts/basic/split-include include/autoconf.h $(wildcard $(srctree)/embed/*) $(wildcard $(srctree)/applets_sh/*) $(srctree)/scripts/shell_aliases $(srctree)/scripts/embedded_scripts $(call cmd,split_autoconf) $(call cmd,gen_bbconfigopts) $(call cmd,gen_common_bufsiz) + $(call cmd,gen_shell_aliases) $(call cmd,gen_embedded_scripts) @touch $@ @@ -984,6 +987,8 @@ MRPROPER_FILES += .config .config.old include/asm .version .old_version \ include/applet_tables.h \ include/applets.h \ include/usage.h \ + include/ash_aliases.h \ + include/hush_aliases.h \ applets/usage \ .kernelrelease Module.symvers tags TAGS cscope* \ busybox_old diff --git a/include/.gitignore b/include/.gitignore index 13a96e018..eb96a7bc9 100644 --- a/include/.gitignore +++ b/include/.gitignore @@ -10,3 +10,5 @@ /usage_compressed.h /usage.h /common_bufsiz.h* +/ash_aliases.h +/hush_aliases.h diff --git a/scripts/shell_aliases b/scripts/shell_aliases new file mode 100755 index 000000000..4e3b6279f --- /dev/null +++ b/scripts/shell_aliases @@ -0,0 +1,11 @@ +#!/bin/bash + +. ./.config || exit 1 + +for alias in $CONFIG_EXTRA_ASH_ALIASES; do + echo "IF_ASH(APPLET_ODDNAME($alias, ash, BB_DIR_BIN, BB_SUID_DROP, ash))" +done > "$1" + +for alias in $CONFIG_EXTRA_HUSH_ALIASES; do + echo "IF_HUSH(APPLET_ODDNAME($alias, hush, BB_DIR_BIN, BB_SUID_DROP, hush))" +done > "$2" diff --git a/shell/ash.c b/shell/ash.c index 5e21ac7e1..b400fe282 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -170,12 +170,24 @@ //config: you to run the specified command or builtin, //config: even when there is a function with the same name. //config: +//config:config EXTRA_ASH_ALIASES +//config: string "extra aliases" +//config: default "" +//config: depends on SHELL_ASH +//config: help +//config: Extra names for ash (applet names), separated +//config: by a space. +//config: //config:endif # ash options //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) // APPLET_ODDNAME:name main location suid_type help //applet:IF_SH_IS_ASH( APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) //applet:IF_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) +// +//applet:#if ENABLE_EXTRA_ASH_ALIASES +//applet:# include "ash_aliases.h" +//applet:#endif //kbuild:lib-$(CONFIG_SHELL_ASH) += ash.o ash_ptr_hack.o shell_common.o //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o diff --git a/shell/hush.c b/shell/hush.c index 28873ec75..49e49e8d0 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -323,12 +323,24 @@ //config: default n //config: depends on SHELL_HUSH //config: +//config:config EXTRA_HUSH_ALIASES +//config: string "extra aliases" +//config: default "" +//config: depends on SHELL_HUSH +//config: help +//config: Extra names for hush (applet names), separated +//config: by a space. +//config: //config:endif # hush options //applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP)) // APPLET_ODDNAME:name main location suid_type help //applet:IF_SH_IS_HUSH( APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, hush)) //applet:IF_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, hush)) +// +//applet:#if ENABLE_EXTRA_HUSH_ALIASES +//applet:# include "hush_aliases.h" +//applet:#endif //kbuild:lib-$(CONFIG_SHELL_HUSH) += hush.o match.o shell_common.o //kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o -- 2.43.0 _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox
