KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I recently discovered some bash code that used the little-known (well, little known to me anyway) feature of function redirection, such as the greatly simplified: function xyzzy () { echo hello } >/dev/null When you call the function with a simple xyzzy , it automatically applies the redirections attached to the function regardless of what you've done when calling it. What I'd like to know is if there's any way to override this behaviour in the call to the function itself, to see the message being generated. I'm reticent to change the file containing all the functions since (1) it's large, (2) it changes regularly, and (3) it's heavily protected by the group that supports it. I've tried: xyzzy >&1 to try to override it but the output still doesn't show up (possibly because >&1 may be considered a no-op). In other words, given the script: function xyzzy () { echo hello } >/tmp/junk rm -f /tmp/junk echo ================ echo Standard output echo ---------------- xyzzy # something else here echo ================ echo Function capture echo ---------------- cat /tmp/junk echo ================ it currently outputs: ================ Standard output ---------------- ================ Function capture ---------------- hello ================ What can I change the xyzzy call to, so as to get hello printed in the standard output section rather than the function capture section? And this needs to be without trying to read the file /tmp/junk after it's created since the actual redirections may be to /dev/null so they won't be in a file.
Tags (comma-separated)
Save Edits
Cancel