Skip to content

Commit 08664b1

Browse files
committed
demo of "declare -i"
示例中变量名不一致,对应描述一并做了修改。 CentOS 7: GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu) Ubuntu 19.10: GNU bash,version 5.0.3(1)-release (x86_64-pc-linux-gnu)
1 parent 92e48c5 commit 08664b1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/variable.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ $ echo $result
386386
注意,一个变量声明为整数以后,依然可以被改写为字符串。
387387

388388
```bash
389-
$ declare -i val=12
389+
$ declare -i var=12
390390
$ var=foo
391391
$ echo $var
392-
foo
392+
0
393393
```
394394

395-
上面例子中,变量`foo`声明为整数,但是覆盖以后,就变成了字符串,Bash 不会报错。
395+
上面例子中,变量`var`声明为整数,覆盖以后,Bash 不会报错,但会赋以不确定的值,上面的例子中可能输出0,也可能输出的是3
396396

397397
**(2)`-x`参数**
398398

0 commit comments

Comments
 (0)