Summary: Like we have Stdout Stderr, I would like to create Stdstatus. Stdout can be stored in array and Stdstatus can be printed for user. I didn't know that stderr could be used for other messages also. But, for the sake of implementing Stdstatus, is it possible?
I have:
SomeFunction(){
PrintForArray
echo "Status"
}
mapfile -t SomeArray < <(SomeFunction)
The output of PrintForArray
is to be stored in SomeArray
, but I also want to print some Status
to the command line. The Status
must not be stored in the array!
Any suggestions?
Note:
This might be useful: What does "3>&1 1>&2 2>&3" do in a script? - Unix & Linux Stack Exchange, but I am not sure how to use this for function
Status is meant to be read by the user.
It may or may not be stored in a log file (both suggestions are welcomed).
I don't want to send it to standard error as the Status is not Error, I just want the User to be informed what is going on!
I don't want to send it to standard error as the Status is not Error
-- stderr is for anything that is not the actual output. It doesn't have to be error information. Diagnostic information may belong to stderr as well. So it's not about "isStatus
an error?"; it's about "isStatus
not output?". – Kamil Maciorowski May 13 '21 at 09:52&3
as in my answer) is if you want normal handling of stderr (e.g. display on your tty, or redirect it to a logfile or something). If you're absolutely certain that the function or whatever isn't going to print any warnings or error messages on stderr then stderr is OK to use for this kind of back-channel communication. – cas May 13 '21 at 10:25