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*

9
  • 2
    You need to quote $somevar to handle IFS=x. Either that or quote x. Commented Jun 26, 2015 at 0:02
  • 1
    @mikeserv Thanks, I like learning about edge cases :) Do you mean if [ -z "${somevar+x}" ]? Would the quoting still be required inside [[ and ]]? Commented Sep 3, 2018 at 14:19
  • @TomHale - yes, in rare cases. the [ test routines accept command line parameters, and so the usual expansions and interpretations as ordered in the usual way should be relied upon to render at invocation of the test applied that which you should cause to be read thereby by any program command line. test{!+"!"} Commented Oct 10, 2018 at 6:02
  • @mikeserv I guess your yes is to my 2nd question... Is the first a yes, too? Commented Oct 10, 2018 at 14:14
  • 2
    +1; this appears to be the simplest way to do this when set -u is in effect and the Bash version is pre-4.2. Commented Jan 8, 2019 at 22:56