Skip to content

Commit ef56386

Browse files
committed
docs(read): add read -e
1 parent 16c872f commit ef56386

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

docs/intro.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,13 @@ Shell 伴随着 Unix 系统的诞生而诞生。
133133

134134
2019年,Bash 发布5.0版。
135135

136-
用户可以通过环境变量`$BASH_VERSION`查看本机的 Bash 版本。
136+
用户可以通过`bash`命令的`--version`参数或者环境变量`$BASH_VERSION`查看本机的 Bash 版本。
137137

138138
```bash
139+
$ bash --version
140+
GNU bash,版本 5.0.3(1)-release (x86_64-pc-linux-gnu)
141+
142+
# 或者
139143
$ echo $BASH_VERSION
140144
5.0.3(1)-release
141145
```

docs/read.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,22 @@ abc
139139

140140
上面例子中,变量`letter`只包含3个字母。
141141

142-
* (5) -e 參數*
142+
**(5)-e 参数**
143143

144-
`-e`參數可開啟`readline`功能,在輸入時可使用快捷鍵。
145-
詳情可參閱行操作。
144+
`-e`参数允许用户输入的时候,使用`readline`库提供的快捷键,比如自动补全。具体的快捷键可以参阅《行操作》一章。
146145

147146
```bash
148-
# 和-i搭配使用可以填充預設值
149-
$ read -e -i 'abc'
150-
abc
147+
#!/bin/bash
148+
149+
echo Please input the path to the file:
150+
151+
read -e fileName
152+
153+
echo $fileName
151154
```
152155

156+
上面例子中,`read`命令接受用户输入的文件名。这时,用户可能想使用 Tab 键的文件名“自动补全”功能,但是`read`命令的输入默认不支持`readline`库的功能。`-e`参数就可以允许用户使用自动补全。
157+
153158
**(6)其他参数**
154159

155160
- `-d delimiter`:定义字符串`delimiter`的第一个字符作为用户输入的结束,而不是一个换行符。

0 commit comments

Comments
 (0)