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*

8
  • 3
    set -k is so that one can use cmd ENVVAR=value in place of ENVVAR=value cmd, that won't work in your example unless set -k was run prior to invoking f. Also, not many shells support it nowadays and only for backward compatibility with the Bourne shell. In the Bourne (or Korn) shell, that wouldn't work for functions. And because it affects shell parsing, it has to be in effect at the time the shell reads the code that makes use of it there. Commented Nov 7, 2017 at 9:49
  • 1
    You may also want to mention set -a Commented Nov 7, 2017 at 9:50
  • This is a helpful answer but I feel like it should also address how/why shell variables are different than environment variables, 'cuz that's super confusing. Commented Jun 11, 2020 at 21:33
  • @mblakesley ok, edited. Is that what you're looking for? Commented Aug 8, 2020 at 22:30
  • 2
    @mblakesley OK, I tried again. Commented Aug 10, 2020 at 12:57