mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Don't use pipe to replace here-string bash executes the RHS in a subshell so will break read expressions
@@ -178,14 +178,15 @@ done
|
|||||||
Bash, ksh:
|
Bash, ksh:
|
||||||
|
|
||||||
```Bash
|
```Bash
|
||||||
grep aaa <<< "$g"
|
read aaa <<< $(grep foo bar)
|
||||||
```
|
```
|
||||||
|
|
||||||
POSIX:
|
POSIX:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# not exactly the same -- <<< adds a trailing \n if $g doesn't end with \n
|
read << EOF
|
||||||
printf '%s' "$g" | grep aaa
|
$(grep foo bar)
|
||||||
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
### echo flags
|
### echo flags
|
||||||
|
Reference in New Issue
Block a user