-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sat, Aug 11, 2018 at 06:08:34PM -0400, Jim Popovitch wrote: > Hello! > > What's the best way to grab anything that's in stdin into a variable > inside a bash script, but won't block if stdin is null?
I think read is your friend (at least in bash). It has an option - -t <timeout>, which you can set to zero, for it to just grab what's available at the moment without waiting (cf "help read" while in the bash for more details, like setting a delimiter, etc.) HTH - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAltvZ8gACgkQBcgs9XrR2kZ4XwCeKD4PgANQHP+QTuB+LtMPGdfP blYAn3ovvpi+8Cx+vlaQ/5oAafdxlgww =BWci -----END PGP SIGNATURE-----