I have read many threads on this topic, but none of the solutions have worked for me.
I am trying to do the following:
RELEASE_COMMAND_OUTPUT=$(exec ~/temp/execs/github-release release --user patick --repo $REPO_NAME --tag $RELEASE_VERSION --name $RELEASE_VERSION --description "$DESC")
but the output of ./github-release
is not stored in the RELEASE_COMMAND_OUTPUT
variable.
I'm aware of the concept of command substitution, but none of the solutions I've tried have worked. What am I doing wrong?
Best Answer
As explained in your question's comments, the variable
RELEASE_COMMAND_OUTPUT
will only get theSTDOUT
(standard output) of your command but not theSTDERR
(standard error), as it seems to be your case.When in doubt about the output of your command you can use process substitution to mark the
STDERR
in red as in the following example:Which is redirecting (the
2>
part) theSTDERR
of thecommand
as input to thewhile
block which will print it in red in the terminal.You can also do the opposite, marking the
STDOUT
as red with:Because grep act only in
STDOUT
NOTE: in some systems you may need to enable the color in grep using the flag
--color=auto
. On Macos and Linux usually it's enable by default.