This adds more verbose documentation of what each control sequence does, and
the state of its implementation. It does significantly expand this comment
block though, so I split it into a separate patch in case it doesn't fit or
needs adjustments.
From 77bfc52911ff3d46eff19396826849be724b4198 Mon Sep 17 00:00:00 2001
From: Avery Terrel <aver...@proton.me>
Date: Wed, 24 Sep 2025 02:58:15 +0000
Subject: [PATCH 2/2] sh: better document prompt control characters
Don't just list which ones we aim to support, describe them and
identify differences between Bash's documentation and what we do.
---
toys/pending/sh.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 4e4afcef..10ba4351 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -3744,7 +3744,36 @@ static void do_prompt(char *prompt)
break;
}
- // \nnn \dD{}hHjlstT@AuvVwW!#$
+ // [ ] unimplemented
+ // [-] working for most purposes
+ // [x] working
+ //
+ // [ ] \nnn ascii octal
+ // [ ] \j number of active jobs
+ // [ ] \l basename of shell's terminal device
+ // [?] \! history number of this command
+ // [?] \# command number of this command
+ // won't implement: \[, \], bash hack for non-printables. query cursor pos instead
+ // [x] \A 24h HH:MM
+ // [x] \d "Tue May 26"
+ // [x] \D{format} strftime(format). empty format is locale-specific
+ // [x] \e terminal escape (same as \033, \x1e)
+ // [x] \h hostname up to first '.'
+ // [x] \H hostname
+ // [x] \n newline
+ // [x] \r carriage return
+ // [x] \s shell name (basename $0)
+ // [x] \t 24h HH:MM:SS
+ // [x] \T 12h HH:MM:SS
+ // [x] \u username
+ // [x] \v version (2.00)
+ // [-] \V version + patch (2.00.0, currently is the same as \v)
+ // [-] \w $PWD with $PROMPT_DIRTRIM (currently doesn't use $PROMPT_DIRTRIM)
+ // [x] \W basename $PWD, $HOME as tilde
+ // [x] \@ 12h HH:MM am/pm
+ // [x] \$ # if EUID=0, else $
+ // [x] \\ backslash
+ //
// Ignore bash's "nonprintable" hack; query our cursor position instead.
if (cc=='[' || cc==']') continue;
else if (cc=='$') *pp++ = getuid() ? '$' : '#';
--
2.49.1
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net