(The patch diff is in mail attachment because I'm not sure if Gmail
likes tab characters in mail messages.)

This would makes all ash options indented inside "ash" in menuconfig.
It appears that menuconfig has a limit at tracking multiple dependency
lines like this (it looks like a "diamond problem" but I'm not sure if
it is):

               ---ASH <----------
              /                  \       ASH_OPTIMIZE_FOR_SIZE
    !NOMMU <-*----SH_IS_ASH <----[OR] <--ASH_INTERNAL_GLOB
              \                  /       ASH_RANDOM_SUPPORT
               ---BASH_IS_ASH <--        [...]

The kconfig-language document [1] states that:

> If a menu entry somehow depends on the previous entry, it can be
> made a submenu of it. First, the previous (parent) symbol must be
> part of the dependency list and then one of these two conditions
> must be true:
> - the child entry must become invisible, if the parent is set to 'n'

    [BusyBox ash used to satisfy this, but no longer does]

> - the child entry must only be visible, if the parent is visible

    [BusyBox ash configs actually satisfy this, but because of
     "diamond" above this might not be easily detected]

So I found out a direct workaround: by making ash options explicitly
depend on !NOMMU, we can tell menuconfig that rule 2 above is satisfied
without any more tracking.

               ---------------------
              /                     \
    !NOMMU <-*-----ASH <--------     \
              \                 \     \        ASH_OPTIMIZE_FOR_SIZE
               *---SH_IS_ASH <---[OR]-[AND] <--ASH_INTERNAL_GLOB
                \                /             ASH_RANDOM_SUPPORT
                 --BASH_IS_ASH <-              [...]

So all ash options would now be indented under "ash".

[1] "Documentation/kbuild/kconfig-language.txt" in Linux kernel source

Signed-off-by: Kang-Che Sung <explore...@gmail.com>
From abdf0c53e17d8f58336f0558bcee1e2848474901 Mon Sep 17 00:00:00 2001
From: Explorer09 <explore...@gmail.com>
Date: Thu, 5 Jan 2017 10:55:45 +0800
Subject: [PATCH] Explicltly group "ash options" and "hush options"

This would makes all ash options indented inside "ash" in menuconfig.
It appears that menuconfig has a limit at tracking multiple dependency
lines like this (it looks like a "diamond problem" but I'm not sure if
it is):

               ---ASH <----------
              /                  \       ASH_OPTIMIZE_FOR_SIZE
    !NOMMU <-*----SH_IS_ASH <----[OR] <--ASH_INTERNAL_GLOB
              \                  /       ASH_RANDOM_SUPPORT
               ---BASH_IS_ASH <--        [...]

The kconfig-language document [1] states that:

> If a menu entry somehow depends on the previous entry, it can be
> made a submenu of it. First, the previous (parent) symbol must be
> part of the dependency list and then one of these two conditions
> must be true:
> - the child entry must become invisible, if the parent is set to 'n'

    [Busybox ash used to satisfy this, but no longer does]

> - the child entry must only be visible, if the parent is visible

    [Busybox ash configs actually satisfy this, but because of
     "diamond" above this might not be easily detected]

So I found out a direct workaround: by making ash options explicitly
depend on !NOMMU, we can tell menuconfig that rule 2 above is satisfied
without any more tracking.

               ---------------------
              /                     \
    !NOMMU <-*-----ASH <--------     \
              \                 \     \        ASH_OPTIMIZE_FOR_SIZE
               *---SH_IS_ASH <---[OR]-[AND] <--ASH_INTERNAL_GLOB
                \                /             ASH_RANDOM_SUPPORT
                 --BASH_IS_ASH <-              [...]

So all ash options would now be indented under "ash".

[1] "Documentation/kbuild/kconfig-language.txt" in Linux kernel source

Signed-off-by: Kang-Che Sung <explore...@gmail.com>
---
 shell/Config.src |  9 ++++-----
 shell/ash.c      | 22 +++++++---------------
 shell/hush.c     | 16 +++++-----------
 3 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/shell/Config.src b/shell/Config.src
index 9bd493fed..c08bfc095 100644
--- a/shell/Config.src
+++ b/shell/Config.src
@@ -80,10 +80,12 @@ endchoice
 INSERT
 
 
+comment "Options common to all shells"
+if ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
+
 config FEATURE_SH_MATH
 	bool "POSIX math support"
 	default y
-	depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
 	help
 	  Enable math support in the shell via $((...)) syntax.
 
@@ -99,14 +101,12 @@ config FEATURE_SH_MATH_64
 config FEATURE_SH_EXTRA_QUIET
 	bool "Hide message on interactive shell startup"
 	default y
-	depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
 	help
 	  Remove the busybox introduction when starting a shell.
 
 config FEATURE_SH_STANDALONE
 	bool "Standalone shell"
 	default n
-	depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
 	help
 	  This option causes busybox shells to use busybox applets
 	  in preference to executables in the PATH whenever possible. For
@@ -139,7 +139,6 @@ config FEATURE_SH_STANDALONE
 config FEATURE_SH_NOFORK
 	bool "Run 'nofork' applets directly"
 	default n
-	depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
 	help
 	  This option causes busybox shells to not execute typical
 	  fork/exec/wait sequence, but call <applet>_main directly,
@@ -157,11 +156,11 @@ config FEATURE_SH_NOFORK
 config FEATURE_SH_HISTFILESIZE
 	bool "Use $HISTFILESIZE"
 	default y
-	depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
 	help
 	  This option makes busybox shells to use $HISTFILESIZE variable
 	  to set shell history size. Note that its max value is capped
 	  by "History size" setting in library tuning section.
 
+endif # Options common to all shells
 
 endmenu
diff --git a/shell/ash.c b/shell/ash.c
index 7c53946ce..8d418e9bb 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -26,17 +26,20 @@
 //config:	  shell (by Herbert Xu), which was created by porting the 'ash' shell
 //config:	  (written by Kenneth Almquist) from NetBSD.
 //config:
+//config:# ash options
+//config:# note: Don't remove !NOMMU part in the next line; it would break
+//config:# menuconfig's indenting.
+//config:if !NOMMU && (ASH || SH_IS_ASH || BASH_IS_ASH)
+//config:
 //config:config ASH_OPTIMIZE_FOR_SIZE
 //config:	bool "Optimize for size instead of speed"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Compile ash for reduced size at the price of speed.
 //config:
 //config:config ASH_INTERNAL_GLOB
 //config:	bool "Use internal glob() implementation"
 //config:	default y	# Y is bigger, but because of uclibc glob() bug, let Y be default for now
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Do not use glob() function from libc, use internal implementation.
 //config:	  Use this if you are getting "glob.h: No such file or directory"
@@ -45,7 +48,6 @@
 //config:config ASH_RANDOM_SUPPORT
 //config:	bool "Pseudorandom generator and $RANDOM variable"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable pseudorandom generator and dynamic variable "$RANDOM".
 //config:	  Each read of "$RANDOM" will generate a new pseudorandom value.
@@ -56,7 +58,6 @@
 //config:config ASH_EXPAND_PRMT
 //config:	bool "Expand prompt string"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  "PS#" may contain volatile content, such as backquote commands.
 //config:	  This option recreates the prompt string from the environment
@@ -65,70 +66,60 @@
 //config:config ASH_BASH_COMPAT
 //config:	bool "bash-compatible extensions"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable bash-compatible extensions.
 //config:
 //config:config ASH_IDLE_TIMEOUT
 //config:	bool "Idle timeout variable"
 //config:	default n
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enables bash-like auto-logout after $TMOUT seconds of idle time.
 //config:
 //config:config ASH_JOB_CONTROL
 //config:	bool "Job control"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable job control in the ash shell.
 //config:
 //config:config ASH_ALIAS
 //config:	bool "Alias support"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable alias support in the ash shell.
 //config:
 //config:config ASH_GETOPTS
 //config:	bool "Builtin getopt to parse positional parameters"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable support for getopts builtin in ash.
 //config:
 //config:config ASH_BUILTIN_ECHO
 //config:	bool "Builtin version of 'echo'"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable support for echo builtin in ash.
 //config:
 //config:config ASH_BUILTIN_PRINTF
 //config:	bool "Builtin version of 'printf'"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable support for printf builtin in ash.
 //config:
 //config:config ASH_BUILTIN_TEST
 //config:	bool "Builtin version of 'test'"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable support for test builtin in ash.
 //config:
 //config:config ASH_HELP
 //config:	bool "help builtin"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable help builtin in ash.
 //config:
 //config:config ASH_CMDCMD
 //config:	bool "'command' command to override shell builtins"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable support for the ash 'command' builtin, which allows
 //config:	  you to run the specified command with the specified arguments,
@@ -137,9 +128,10 @@
 //config:config ASH_MAIL
 //config:	bool "Check for new mail on interactive shells"
 //config:	default y
-//config:	depends on ASH || SH_IS_ASH || BASH_IS_ASH
 //config:	help
 //config:	  Enable "check for new mail" function in the ash shell.
+//config:
+//config:endif # ash options
 
 //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
 //applet:IF_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash))
diff --git a/shell/hush.c b/shell/hush.c
index a56d3b280..2a55f2e96 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -96,10 +96,12 @@
 //config:	  It does not handle select, aliases, tilde expansion,
 //config:	  &>file and >&file redirection of stdout+stderr.
 //config:
+//config:# hush options
+//config:if HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config:
 //config:config HUSH_BASH_COMPAT
 //config:	bool "bash-compatible extensions"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  Enable bash-compatible extensions.
 //config:
@@ -113,14 +115,12 @@
 //config:config HUSH_HELP
 //config:	bool "help builtin"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  Enable help builtin in hush. Code size + ~1 kbyte.
 //config:
 //config:config HUSH_INTERACTIVE
 //config:	bool "Interactive mode"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  Enable interactive mode (prompt and command editing).
 //config:	  Without this, hush simply reads and executes commands
@@ -148,35 +148,30 @@
 //config:config HUSH_TICK
 //config:	bool "Process substitution"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  Enable process substitution `command` and $(command) in hush.
 //config:
 //config:config HUSH_IF
 //config:	bool "Support if/then/elif/else/fi"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  Enable if/then/elif/else/fi in hush.
 //config:
 //config:config HUSH_LOOPS
 //config:	bool "Support for, while and until loops"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  Enable for, while and until loops in hush.
 //config:
 //config:config HUSH_CASE
 //config:	bool "Support case ... esac statement"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  Enable case ... esac statement in hush. +400 bytes.
 //config:
 //config:config HUSH_FUNCTIONS
 //config:	bool "Support funcname() { commands; } syntax"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  Enable support for shell functions in hush. +800 bytes.
 //config:
@@ -190,7 +185,6 @@
 //config:config HUSH_RANDOM_SUPPORT
 //config:	bool "Pseudorandom generator and $RANDOM variable"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  Enable pseudorandom generator and dynamic variable "$RANDOM".
 //config:	  Each read of "$RANDOM" will generate a new pseudorandom value.
@@ -198,18 +192,18 @@
 //config:config HUSH_EXPORT_N
 //config:	bool "Support 'export -n' option"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  export -n unexports variables. It is a bash extension.
 //config:
 //config:config HUSH_MODE_X
 //config:	bool "Support 'hush -x' option and 'set -x' command"
 //config:	default y
-//config:	depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
 //config:	help
 //config:	  This instructs hush to print commands before execution.
 //config:	  Adds ~300 bytes.
 //config:
+//config:endif # hush options
+//config:
 //config:config MSH
 //config:	bool "msh (deprecated: aliased to hush)"
 //config:	default n
-- 
2.11.0

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to