mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
fix small typo
@@ -3,13 +3,13 @@
|
|||||||
### Problematic code:
|
### Problematic code:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
string="stirng" ; echo "$string" | sed -e "s/ir/ri/"
|
string="string" ; echo "$string" | sed -e "s/ir/ri/"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Correct code:
|
### Correct code:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
string="stirng" ; echo "${string//ir/ri}"
|
string="string" ; echo "${string//ir/ri}"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rationale:
|
### Rationale:
|
||||||
@@ -21,7 +21,7 @@ Let's assume somewhere earlier in your code you have put data into a variable (E
|
|||||||
Occasionally a more complex sed substitution is required. For example, getting the last character of a string.
|
Occasionally a more complex sed substitution is required. For example, getting the last character of a string.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
string="stirng" ; echo "$string" | sed -e "s/^.*\(.\)$/\1/"
|
string="string" ; echo "$string" | sed -e "s/^.*\(.\)$/\1/"
|
||||||
```
|
```
|
||||||
|
|
||||||
This is a bit simple for the example and there are alternative ways of doing this in the shell, but this SC2001 flags on several of my crazy complex sed commands which are beyond the scope of this example. Utilizing some of the more complex capabilities of sed is required occasionally and it is safe to ignore SC2001.
|
This is a bit simple for the example and there are alternative ways of doing this in the shell, but this SC2001 flags on several of my crazy complex sed commands which are beyond the scope of this example. Utilizing some of the more complex capabilities of sed is required occasionally and it is safe to ignore SC2001.
|
||||||
|
Reference in New Issue
Block a user