-
Notifications
You must be signed in to change notification settings - Fork 9
fix(redirect): 2>/dev/null does not suppress stderr from builtins #1116
Copy link
Copy link
Closed
Description
Summary
Redirecting stderr to /dev/null via 2>/dev/null does not suppress error output from builtin commands. The stderr content still appears on the terminal.
Reproduction
echo "error msg" 2>/dev/null
# Expected: "error msg" on stdout only, stderr suppressed
# Actual: works for echo (stdout), but...
ls /nonexistent 2>/dev/null
# Expected: no output
# Actual: error message still visibleAlso affects &> combined redirect:
ls /nonexistent &> /dev/null
# Expected: no output at all
# Actual: error still shows (exit code 2 is correct)Context
Discovered while running bashblog via bashkit CLI. Bashblog uses &> /dev/null and 2>/dev/null extensively to suppress expected errors:
ls ./*.html &> /dev/nullcp .backup.tar.gz .yesterday.tar.gz &> /dev/nullrm ./"$prefix_tags"*.html &> /dev/null
Expected behavior
2>/dev/null should discard all stderr output. &>/dev/null should discard both stdout and stderr.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels