[git commit] ash simplify PS1 initialization
Denys Vlasenko
vda.linux at googlemail.com
Sun Oct 4 22:36:08 UTC 2026
commit: https://git.busybox.net/busybox/commit/?id=6644e8376e54e9bdddda5564dd1497eb16ac62d0
branch: https://git.busybox.net/busybox/log/?h=master
function old new delta
.rodata 104788 104781 -7
init 432 422 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-17) Total: -17 bytes
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
shell/ash.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/shell/ash.c b/shell/ash.c
index 9142feb8c..d96c5a6c7 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -2304,7 +2304,11 @@ static const struct {
{ VSTRFIXED|VTEXTFIXED|VUNSET, "MAILPATH" , changemail },
#endif
{ VSTRFIXED|VTEXTFIXED , bb_PATH_root_path, changepath },
+#if ENABLE_FEATURE_EDITING_FANCY_PROMPT
+ { VSTRFIXED|VTEXTFIXED , "PS1=\\w \\$ ", NULL },
+#else
{ VSTRFIXED|VTEXTFIXED , "PS1=$ " , NULL },
+#endif
{ VSTRFIXED|VTEXTFIXED , "PS2=> " , NULL },
{ VSTRFIXED|VTEXTFIXED , "PS4=+ " , NULL },
#if ENABLE_ASH_GETOPTS
@@ -2455,14 +2459,13 @@ initvar(void)
struct var *end;
struct var **vpp;
- /*
- * PS1 depends on uid
- */
-#if ENABLE_FEATURE_EDITING && ENABLE_FEATURE_EDITING_FANCY_PROMPT
- vps1.var_text = "PS1=\\w \\$ ";
-#else
- if (!get_cached_euid(&groupinfo.euid))
+ /* PS1 depends on uid */
+#if !ENABLE_FEATURE_EDITING_FANCY_PROMPT
+ if (get_cached_euid(&groupinfo.euid) == 0)
vps1.var_text = "PS1=# ";
+ /* else: the default "$ " is already set */
+#else
+ /* default "\\w \\$ " prompt already takes care of #/$ */
#endif
vp = varinit;
end = vp + ARRAY_SIZE(varinit);
More information about the busybox-cvs
mailing list