FORSTDIN(1)

πŸ“¦ version 2.9.9.2, in nixpkgs unstable

πŸ’… FORSTDIN(1) β€” bestie's guide to the forstdin manual page πŸ’…

okay so this is a General Commands Manual page, and we're talking about the icon that is forstdin. Buckle up, it's giving "loops but make it stdin" πŸŽ€


✨ NAME ✨

forstdin β€” use input as loop elements to run another program πŸŒ€


🌸 SYNOPSIS 🌸

Inside an execlineb(1) script, bestie, it looks like this:

forstdin [-E | -e] [-p | -P maxpar | -o okcodes | -x breakcodes]
         [-N | -n] [-C | -c] [-0 | -d delim] variable loop...

πŸ’– DESCRIPTION πŸ’–

so forstdin reads its standard input as it becomes available β€” like, it doesn't sit around waiting, it's a main character that moves fast β€” and it splits that input on every line automatically (cf. execline-transform(7)).

Then, for every argument x in the split output, forstdin runs loop... as a child process, with variable= x added to its environment. iconic behavior honestly.

After that, forstdin exits 0 if it read something on stdin, and 1 if it didn't read anything. no cap, that's it. 🫢


πŸ”₯ OPTIONS πŸ”₯

  • -p β€” Parallel mode. Do not wait for a loop... instance to finish before spawning the next one. forstdin will still wait for all instances of loop to terminate before exiting, though. πŸ’…
  • -P maxpar β€” Like -p, but only run up to maxpar instances at a time. Minimum is 1; maximum is 10000. -p is equivalent to -P 10000, i.e. it can spawn a very large number of loop instances in parallel, but it's technically not infinite. (the math is mathing, but it's still a lot 🫠)
  • -o okcodes β€” okcodes must be a comma-separated list of exit codes. If the -p flag hasn't been given and loop exits with one of the codes in okcodes, forstdin will run the following instances of the loop, but if the exit code is not listed in okcodes, forstdin will exit immediately with an approximation (cf. execline-exitcodes(7)) of the same exit code. so like, listed = keep going, unlisted = bye πŸ‘‹
  • -x breakcodes β€” Like the previous option, but with inverted meaning β€” the listed exit codes are codes that will make forstdin break the loop and exit, and the unlisted exit codes will make it keep looping. flip it and reverse it πŸ’«
  • -e β€” No autoimport. This is the default.
  • -E β€” Autoimport. Instead of spawning loop..., spawn importas -uSi variable loop.... This substitutes variable into the command line instead of putting it into the environment. fancy ✨

Other options are similar (in name and functionality) to the switches passed to control a substitution mechanism (cf. execline-transform(7)), on purpose; however, forstdin does not call the substitution mechanism and has its own semantics for those options. so don't get it twisted, okay? πŸ™ˆ

  • -N β€” Store the whole line in variable, including the terminating newline (or other delimiter).
  • -n β€” Chomp a terminating delimiter from the line from stdin before storing it into variable. This is the default.
⚠️ heads up bestie: if chomping is active, and the last line of stdin is not terminated by a delimiter, then this last line will not be processed. the way that line just gets ignored... 😭
  • -C β€” Crunch. If there is an empty line (i.e. that only contains a delimiter), do not call loop.
  • -c β€” Do not crunch, call loop even if the line is empty. This is the default.
  • -0 β€” Accept null characters on its stdin, using them as delimiters. If this option and a -d option are used simultaneously, the rightmost one wins. rightmost wins, that's the rule πŸ†
  • -d delim β€” Use the characters in string delim as delimiters for a line. Default is '\n', meaning the input is only split on newlines.

πŸ¦‹ SEE ALSO πŸ¦‹

execlineb(1), forbacktickx(1), forx(1), loopwhilex(1), execline-exitcodes(7), execline-transform(7)

This man page is ported from the authoritative documentation at: https://skarnet.org/software/execline/forstdin.html 🌈


πŸ‘‘ AUTHORS πŸ‘‘

  • Laurent Bercot
  • Alexis <flexibeast@gmail.com> (man page port)

and that's the whole vibe check βœ… this page is from the Debian build of September 28, 2021, ported with love β€” FORSTDIN(1), slay, periodt πŸ’œπŸ§šπŸŒΈ

πŸ“¦ where this page comes from