Abd*_*red 42 command-line bash prompt
当我登录到 shell 时,我看到了其值存储在 PS1 中的提示。
我在使用 here-document 语法时也遇到了另一个提示(但不知道是哪个):
bc << HERE
>
Run Code Online (Sandbox Code Playgroud)
但这就是所有类型的提示。到目前为止我遇到过。什么样的情况会引起不同类型的提示?
dha*_*hag 54
这是 bash 文档所说的:
PS1 The value of this parameter is expanded (see PROMPTING below)
and used as the primary prompt string. The default value is
``\s-\v\$ ''.
PS2 The value of this parameter is expanded as with PS1 and used as
the secondary prompt string. The default is ``> ''.
PS3 The value of this parameter is used as the prompt for the select
command (see SHELL GRAMMAR above).
PS4 The value of this parameter is expanded as with PS1 and the
value is printed before each command bash displays during an
execution trace. The first character of PS4 is replicated mul?
tiple times, as necessary, to indicate multiple levels of indi?
rection. The default is ``+ ''.
Run Code Online (Sandbox Code Playgroud)
那么,PS1是您正常的“等待命令”提示PS2吗,是您在键入不完整的命令后看到的继续提示,
PS3是在select命令等待输入时显示的,
PS4还是调试跟踪行前缀。
我引用的文档没有这么说,但是PS3bash 中的默认值
是#?:
$ select x in foo bar baz; do echo $x; done
1) foo
2) bar
3) baz
#? 3
baz
#? 2
bar
#? ^C
Run Code Online (Sandbox Code Playgroud)