freebsd-dev/bin/sh
Juraj Lutter 3cf65f8a7f sh(1): Allow non-printing characters in prompt strings
Introduce new prompt format characters:

- '\[' starts the sequence of non-printing chatacters
- '\]' ends the sequence of non-printing characters

Within these sequences, the following characters are now supported:

- '\a' emits ASCII BEL (0x07, 007) character
- '\e' emits ASCII ESC (0x1b, 033) character
- '\r' emits ASCII CR (0x0d, 015) character
- '\n' emits ASCII CRLF sequence

These can be used to embed ANSI sequences into prompt strings.

Example in .shrc:

PS1="\[\e[7m\]\u@\h\[\e[0m\]:\w \\$ "

This tries to maintain some degree of compatibility with GNU bash,
that uses GNU readline library (which behaves slightly different from
BSD editline): It has two "non-printing boundary" characters:

- RL_PROMPT_START_IGNORE (\001)
- RL_PROMPT_END_IGNORE (\002)

while BSD editline only has one (when using EL_PROMPT_ESC setting), so
for this purpose, ASCII \001 was chosen and both \[ and \] emits
this character.

And while here, enlarge PROMPTLEN from 128 to 192 characters.

Reviewed by:		jilles
Approved by:		jilles
Differential Revision:	https://reviews.freebsd.org/D37701
2022-12-22 19:10:48 +01:00
..
bltin General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
funcs
tests sh: nullify ENV in tests 2022-08-20 13:27:42 +02:00
alias.c sh: Fix use after free when resetting an in-use alias. 2017-04-16 22:10:02 +00:00
alias.h
arith_yacc.c sh: Restore $((x)) error checking after fix for $((-9223372036854775808)) 2019-02-10 22:23:05 +00:00
arith_yacc.h sh: Restore $((x)) error checking after fix for $((-9223372036854775808)) 2019-02-10 22:23:05 +00:00
arith_yylex.c sh: Restore $((x)) error checking after fix for $((-9223372036854775808)) 2019-02-10 22:23:05 +00:00
arith.h sh: Remove unused function declaration for arith_lex_reset(). 2017-03-18 20:41:07 +00:00
builtins.def sh: Remove remnants to compile out fc completely 2020-04-22 21:45:43 +00:00
cd.c sh: Fix rare memory leak with SIGINT 2020-01-01 12:06:37 +00:00
cd.h
dot.profile sh: Set PATH envvar after setting HOME in dotfile 2021-10-26 22:50:09 +08:00
dot.shrc sh(1): fix home/del key on mobaxterm env 2021-10-20 14:00:20 +02:00
error.c src/bin/sh: Fix spelling errors 2021-10-02 10:39:24 -06:00
error.h sh: Unify EXERROR and EXEXEC 2018-11-09 14:58:24 +00:00
eval.c src/bin/sh: Fix spelling errors 2021-10-02 10:39:24 -06:00
eval.h
exec.c sh: Add -o verify to use O_VERIFY when sourcing scripts 2021-09-23 10:43:09 +02:00
exec.h sh: Use exitstatus instead of exerrno to pass EXEXEC status 2018-10-27 20:17:57 +00:00
expand.c sh: Fix ${param?} default error message 2018-11-28 20:03:53 +00:00
expand.h
histedit.c sh(1): Allow non-printing characters in prompt strings 2022-12-22 19:10:48 +01:00
input.c sh: Avoid some headers when NO_HISTORY is set. 2021-11-24 17:53:39 -08:00
input.h sh: Add -o verify to use O_VERIFY when sourcing scripts 2021-09-23 10:43:09 +02:00
jobs.c sh: Don't add something to a null pointer 2022-01-26 23:13:20 +01:00
jobs.h sh: Fix mismatch in array bounds for vforkexecshell(). 2022-09-28 14:05:07 -07:00
mail.c sh: Don't use padvance() for MAIL/MAILPATH 2018-07-15 09:14:30 +00:00
mail.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
main.c sh: Add -o verify to use O_VERIFY when sourcing scripts 2021-09-23 10:43:09 +02:00
main.h sh: Add -o verify to use O_VERIFY when sourcing scripts 2021-09-23 10:43:09 +02:00
Makefile sh: install hard link with same mode as target 2022-11-23 15:10:02 -05:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
memalloc.c sh: silence sanitizer 2021-04-01 07:31:03 +02:00
memalloc.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
miscbltin.c read builtin: Empty variables on timeout 2021-09-24 11:34:54 -07:00
mkbuiltins sh: Remove remnants to compile out fc completely 2020-04-22 21:45:43 +00:00
mknodes.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
mksyntax.c sh: Split CNL syntax category to avoid a check on state[level].syntax 2018-05-21 21:52:48 +00:00
mktokens Don't hardcode /usr/bin as the path for mktemp in build tools 2018-02-06 15:41:35 +00:00
myhistedit.h sh: implement persistent history storage 2021-05-10 18:57:13 +02:00
mystring.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
mystring.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
nodes.c.pat
nodetypes src/bin/sh: Fix spelling errors 2021-10-02 10:39:24 -06:00
options.c sh: accept fc options grouped behind one '-' 2022-08-20 13:26:05 +02:00
options.h sh: Add -o verify to use O_VERIFY when sourcing scripts 2021-09-23 10:43:09 +02:00
output.c sh: Send normal output from bind builtin to stdout 2019-02-19 21:27:30 +00:00
output.h sh: Send normal output from bind builtin to stdout 2019-02-19 21:27:30 +00:00
parser.c sh(1): Allow non-printing characters in prompt strings 2022-12-22 19:10:48 +01:00
parser.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
profile sh: when loading profile, read only .sh files. 2022-10-22 19:05:31 +02:00
redir.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
redir.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
sh.1 sh(1): Allow non-printing characters in prompt strings 2022-12-22 19:10:48 +01:00
shell.h src/bin/sh: Fix spelling errors 2021-10-02 10:39:24 -06:00
show.c sh: fix debug build 2021-04-11 09:23:14 +02:00
show.h sh: fix debug build 2021-04-11 09:23:14 +02:00
TOUR sh: Unify EXERROR and EXEXEC 2018-11-09 14:58:24 +00:00
trap.c sh: Avoid some headers when NO_HISTORY is set. 2021-11-24 17:53:39 -08:00
trap.h sh: Keep ignored SIGINT/SIGQUIT after set in a background job 2020-08-28 15:35:45 +00:00
var.c sh: Do not place exported but unset variables into the environment 2019-01-03 20:22:35 +00:00
var.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00