-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR] envsubst #507
Comments
It might? Neither the man page nor the --help output explain what it does (what's shell-format). envsubst -v PATH didn't print anything, and envsubst -v '$PATH' printed PATH... So it's basically you want something like: $ echo '$SHLVL/$DISPLAY' | eval Except as a standalone shell command? I mean, I suppose I could do it as a shell builtin instead of a shell function. Not entirely sure WHY, but... sure? Have you tried asking Chet the bash maintainer if he thinks there's already a way to do this built in to bash? Seems like there should be somewhere, a trivial shell function with some sort of ${1@Q} or declare corner case... |
And you want a safe command that's not gonna $(subshell) and so on. Writing it seems trivial, especially if I can leverage the code I already wrote for toysh. Working out what the specification actually IS, not so much. |
Here is the man page: https://man7.org/linux/man-pages/man1/envsubst.1.html and some examples https://www.baeldung.com/linux/envsubst-command It is a utility by itself, not a shell builtin. eg: |
That would be the man page I mentioned not finding particularly enlightening, yes. The examples are helpful though, thanks. (I never would have guessed that shell-format was INSANE enough to need the $ on the variable name to be substituted.) I'm aware it's a standalone command, most external packages are, I'm just saying it would be easier for me to implement it as a shell builtin because the shell already has variable resolution plumbing including the various ${name/search/replace} that kaniini/envsubst#1 has an open issue for (I'd more or less get that for free). However, they presumably want it NOT to run $(subshell) and so on for security reasons, which doesn't sound hard to block but I'd want to think about the design a bit to be sure. As for having a shell builtin that's also available as a standalone command in the $PATH... well that's kind of what TOYFLAG_MAYFORK does, except sort of in reverse here. (The tricksy part is that scripts/single.sh special cases sh for standalone builds and I'd need to categorize this properly. This command wants to use the shell plumbing, but without the shell builtin variables like $OLDPWD and $RANDOM because echo '$RANDOM' | env -i envsubst doesn't print them. Possibly some chunk of code should get factored out...) |
envsubst
is frequently used in container world for environment variable substitution. It was added in Alpine as discussed in https://gitlab.alpinelinux.org/alpine/aports/-/issues/14935Does it make sense to include it as a toybox command?
The text was updated successfully, but these errors were encountered: