freebsd-src/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
funcs
tests sh: nullify ENV in tests 2022-08-20 13:27:42 +02:00
alias.c
alias.h
arith.h
arith_yacc.c
arith_yacc.h
arith_yylex.c
builtins.def
cd.c
cd.h
dot.profile
dot.shrc
error.c
error.h
eval.c
eval.h
exec.c
exec.h
expand.c
expand.h
histedit.c sh(1): Allow non-printing characters in prompt strings 2022-12-22 19:10:48 +01:00
input.c
input.h
jobs.c
jobs.h sh: Fix mismatch in array bounds for vforkexecshell(). 2022-09-28 14:05:07 -07:00
mail.c
mail.h
main.c
main.h
Makefile sh: install hard link with same mode as target 2022-11-23 15:10:02 -05:00
Makefile.depend
memalloc.c
memalloc.h
miscbltin.c
mkbuiltins
mknodes.c
mksyntax.c
mktokens
myhistedit.h
mystring.c
mystring.h
nodes.c.pat
nodetypes
options.c sh: accept fc options grouped behind one '-' 2022-08-20 13:26:05 +02:00
options.h
output.c
output.h
parser.c sh(1): Allow non-printing characters in prompt strings 2022-12-22 19:10:48 +01:00
parser.h
profile sh: when loading profile, read only .sh files. 2022-10-22 19:05:31 +02:00
redir.c
redir.h
sh.1 sh(1): Allow non-printing characters in prompt strings 2022-12-22 19:10:48 +01:00
shell.h
show.c
show.h
TOUR
trap.c
trap.h
var.c
var.h