I recently discovered some bash code that used a little-known (well, little-known to me anyway) function redirection function, such as a much simplified one:
function xyzzy () { echo hello } >/dev/null
When you call a function using simple xyzzy , it automatically applies the redirects associated with the function, regardless of what you did when you called it.
What I would like to know is if there is a way to override this behavior in a function call to see how the message is generated. I am restrained to modify a file containing all the functions, because (1) it is large, (2) it changes regularly and (3) it is strongly protected by the group that supports it.
I tried:
xyzzy >&1
to try to override it, but the output is still not displayed (perhaps because >&1 can be considered no-op).
In other words, given the script:
function xyzzy () { echo hello } >/tmp/junk rm -f /tmp/junk echo ================ echo Standard output echo ---------------- xyzzy
currently issues:
What can I change to call xyzzy to get hello printed in the standard output section and not in the function capture section?
And that should be without trying to read the /tmp/junk file after it was created, since the actual redirects can be in /dev/null , so they won't be in the file.
source share