mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2267 (markdown)
32
SC2267.md
Normal file
32
SC2267.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
## xargs -i is deprecated in favor of -I{}
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Implicit replacement string
|
||||||
|
xargs -i ls {}
|
||||||
|
|
||||||
|
# Explicit replacement string
|
||||||
|
xargs -imyfilename ls myfilename
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
xargs -I {} ls {}
|
||||||
|
|
||||||
|
xargs -I filename ls filename
|
||||||
|
```
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
`xargs -i` is a GNU specific option. It has been deprecated in favor of the POSIX standard option `-I`.
|
||||||
|
|
||||||
|
Note that `-i` will implicitly use `{}` as a token if nothing is specified, while `-I` requires it to be explicit.
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
### Related resources:
|
||||||
|
|
||||||
|
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
|
Reference in New Issue
Block a user