mirror of
https://github.com/google/styleguide.git
synced 2024-03-22 13:11:43 +08:00
Project import generated by Copybara.
PiperOrigin-RevId: 312117514
This commit is contained in:
parent
7a59e424c8
commit
35fd3f0167
|
@ -1253,17 +1253,17 @@ We prefer the use of builtins such as the *Parameter Expansion*
|
||||||
functions in `bash(1)` as it's more robust and portable
|
functions in `bash(1)` as it's more robust and portable
|
||||||
(especially when compared to things like `sed`).
|
(especially when compared to things like `sed`).
|
||||||
|
|
||||||
Example:
|
Examples:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Prefer this:
|
# Prefer this:
|
||||||
addition=$(( ${X} + ${Y} ))
|
addition=$(( X + Y ))
|
||||||
substitution="${string/#foo/bar}"
|
substitution="${string/#foo/bar}"
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Instead of this:
|
# Instead of this:
|
||||||
addition="$(expr ${X} + ${Y})"
|
addition="$(expr "${X}" + "${Y}")"
|
||||||
substitution="$(echo "${string}" | sed -e 's/^foo/bar/')"
|
substitution="$(echo "${string}" | sed -e 's/^foo/bar/')"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user