[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A feature request regarding redirection to variables
From: |
Luke Tidd |
Subject: |
A feature request regarding redirection to variables |
Date: |
Sun, 17 Dec 2023 21:46:17 -0500 |
A very common thing I need to do when writing bash is to collect both
the stdout and stderr of a command. This can be done relatively
reasonably with files but it would be very attractive to be able to
redirect these directly to a variable some how.
cmd >@stdout 2>@stderr
exit_code=$?
where "stdout" and "stderr" here are variables.
This or equivalent would be very nice. currently I find myself reusing
this pattern over and over:
err_file="$(mktemp)"
var_stdout="$(cmd 2>"$err_file)"
exit_code=$?
var_stderr="$(<"$err_file")"
rm "$err_file"
and it just doesn't have the same ring to it! Is there a snowballs
chance? Thanks for your time!
- A feature request regarding redirection to variables,
Luke Tidd <=