News for hackers. Stuff that matters.
Re:Bash functions are better than I thought by gpderetta on Sunday October 31, 2021 @04:30PM (#29060117)
Well you can use arbitrary file descriptors to get things out of a subshell, not just stdout. I had to do it when I had to get something out of band, while redirecting stdout through a pipeline.

Mind, if possible, it is even uglier than using stdout.

Re:Bash functions are better than I thought by Groxx on Sunday October 31, 2021 @05:49PM (#29060777)
yeah, I was wondering if there was some reason that something like this wouldn't work:

  err_f="$(mktemp)"
  third_f="$(mktemp)"
  out="$(cmd 2>"$err_f" 3>"$third_f")"
  err="$(cat "$err_f")"
  third="$(cat "$third_f")"
Seems like that should work fine, and it's not even that odd looking or hard to understand. But I haven't tried, not sure if there's some surprise lurking in the depths of tempfiles or something.
Re:Bash functions are better than I thought by gpderetta on Monday November 01, 2021 @06:56AM (#29065120)
Normally I use mkfifo then immediately rm it after opening the file with exec.

The fact that there isn't a good way to open an anonymous pipe and get its two file descriptors in bash is very annoying.

Re:Bash functions are better than I thought by cryptonector on Sunday October 31, 2021 @10:55PM (#29062627)
Few people know about `{varname}` I/O redirection...
Re:Bash functions are better than I thought by gpderetta on Monday November 01, 2021 @06:58AM (#29065135)
Yes. The fact that shell scripting is both so powerful and yet such an ugly language is painful.