Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 4
    Does this add anything to the prior answer, which AFAICT includes this idiom? echo $i is buggy, by the way -- if you have an argument passed as "*", you would instead have a list of filenames in the current directory emitted; should be echo "$i". Commented Oct 3, 2016 at 16:01
  • 1
    ...and printf '%s\n' "$i" is actually more correct than echo "$i" -- if your argument is -n, printf will print it, but echo may not (the POSIX specification for echo defines behavior as entirely undefined if the first argument is -n, or if any argument contains a backslash literal; moreover, some popular echo implementations defy black-letter POSIX by having -e or -E arguments have a behavior other than printing like strings on output). Commented Oct 3, 2016 at 16:02
  • 1
    The script does nothing. Pls explain! Commented Oct 3, 2016 at 19:17
  • @hschou, if it "does nothing", then you aren't passing it any arguments. Commented Oct 3, 2016 at 21:46
  • @hschou, I have updated the answer. The answer explains everything. Commented Oct 4, 2016 at 7:59