WITHSTDINAS(1)
π withstdinas β read ALL of stdin into an env var and go run another program with it π
okay so bestie, this is withstdinas(1) from the General Commands Manual and it is genuinely one of my fave little execline tools, no cap. let me tell you everything β¨
π NAME π
withstdinas β reads the entirety of standard input into an environment variable, then runs another program with that extra environment variable chillin' in its env π«Ά
πΈ SYNOPSIS πΈ
inside an execlineb(1) script, you'd do:
withstdinas [-i | -I | -D default] [-N | -n] [-E | -e] variable prog...
π¦ DESCRIPTION π¦
So. withstdinas reads its stdin until EOF. like, all of it. every last byte, until the party's over π
Then it exec(3)s into prog..., with variable added to the environment β and the value of variable is literally whatever got read on stdin. iconic behaviour, honestly π
and here's the little trick that makes it all work, iykyk: you can start prog... with importas -u variable variable to do the variable substitution π
β¨ OPTIONS β¨
π the newline situation
-Nβ do not chomp an ending newline off stdin. leave that newline exactly where you found it, bestie π-nβ chomp an ending newline off stdin. this one's the default, so it's already doing this unless you say otherwise π
π§ the autoimport situation
-eβ no autoimport. this is the default, so like, business as usual πΈ-Eβ autoimport! instead ofexec(3)ing into prog..., itexec(3)s intoimportas -ui variable variable prog.... basically it substitutes variable into the command line instead of dropping it into the environment. different vibe, same data π
π₯ the "uh oh, null character" situation
okay, so the rest of the options are all about the drama of: what do we do when the input isn't suitable as the contents of an environment variable? and by that I mean... it contains a null character π that's the vibes-killer right there.
-iβwithstdinasjust exits1. it's not mad, it's just disappointed π-Iβ variable gets removed from the environment, and execution proceeds anyway π«Ά-Ddefault β the value of variable is set to default, and execution proceeds, slay β¨
and when you give none of those options? the value of variable is set to whatever the start of the input is, right up to the first null character, and execution proceeds. so it just... stops caring at the null. lowkey iconic π
π SEE ALSO π
emptyenv(1), envfile(1), exec(1), execline-cd(1), execline-umask(1), execlineb(1), exit(1), export(1), fdblock(1), fdclose(1), fdmove(1), fdreserve(1), fdswap(1), getcwd(1), getpid(1), heredoc(1), piperw(1), posix-cd(1), posix-umask(1), redirfd(1), trap(1), tryexec(1), unexport(1), wait(1), exec(3)
π this man page is ported from the authoritative documentation at: https://skarnet.org/software/execline/withstdinas.html β go give it a read, fr fr π¦
π AUTHORS π
- Laurent Bercot
- Alexis <flexibeast@gmail.com> (man page port) π
Debian, February 14, 2021 β that's the source, the version, and the date, all bundled up with a little bow π tysm for reading bestie, go pipe something into an env var and SLAY π β¨
π¦ where this page comes from
- nixpkgs unstable: execline 2.9.9.2
- nixpkgs unstable: execline-man-pages 2.9.9.1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms