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*

11
  • Interesting demo of env producing these environment strings when fed an arg that contains a newline in the right place. (Which is possible even with shells that don't support $'escape sequences'). Unless env could (or POSIXly should?) be doing any filtering itself? Otherwise should be possible with just a POSIX shell environment, no compiler other other programming languages needed. (It's still not directly from sh, which is what the question asked about; good data points on that, too.) Commented Sep 8 at 6:27
  • Didn't do what? AFAICT, zsh doesn't strip the env vars it can't import as shell variables either. Note that bash sets variables with %% in their name since shellshock for its exported functions, so it would be silly if it did this kind of thing. Commented Sep 8 at 6:51
  • @PeterCordes, mm, the post says "could an implementation of POSIX sh keep invalid names in the environment that it executes utilities under?" and I read that as asking if it's possible for a program launched from a POSIX-like shell to receive envvars with funny names, in some way, regardless of how they came to be. Commented Sep 8 at 10:04
  • @StéphaneChazelas, I don't know what zsh is supposed to do, but at least with that simple test, zsh didn't pass through the envvar with the funny name. Commented Sep 8 at 10:05
  • 1
    @StéphaneChazelas, ok, right, I only tried the zsh on my mac (zsh 5.9 (x86_64-apple-darwin23.0)) at first, I should have mentioned that. The behaviour looks to be different there vs. on Ubuntu, so I suppose it might be some Apple-specific modification(?) Commented Sep 8 at 12:29