mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2039 (markdown)
@@ -101,7 +101,8 @@ grep aaa <<< "$g"
|
||||
POSIX:
|
||||
|
||||
```sh
|
||||
printf '%s' "$g" | grep aaa # since we want to avoid `echo`
|
||||
# not exactly the same -- <<< adds a trailing \n if $g doesn't end with \n
|
||||
printf '%s' "$g" | grep aaa
|
||||
```
|
||||
|
||||
### echo flags
|
||||
@@ -138,7 +139,10 @@ POSIX:
|
||||
# TODO: Interpret it back to printf escapes for hard-to-copy chars like \t?
|
||||
# See also: http://git.savannah.gnu.org/cgit/libtool.git/tree/gl/build-aux/funclib.sh?id=c60e054#n1029
|
||||
reuse_quote()(
|
||||
for i; do echo -n \'; echo -n "$i" | sed -e "s/'/'\\\\''/g"; echo -n "' "; done
|
||||
for i; do
|
||||
__i_quote=$(printf '%s\n' "$i" | sed -e "s/'/'\\\\''/g"; echo x)
|
||||
printf "'%s'" "${__i_quote%x}"
|
||||
done
|
||||
)
|
||||
reuse_quote "$@"
|
||||
```
|
||||
|
Reference in New Issue
Block a user