bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"trap" output from "if" statement redirected wrongly


From: Frank Heckenbach
Subject: "trap" output from "if" statement redirected wrongly
Date: Wed, 13 Apr 2022 14:58:30 +0200

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fstack-protector-strong -Wformat 
-Werror=format-security -Wall 
uname output: Linux mars 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) 
x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.1
Patch Level: 16
Release Status: release

Description:

This script writes "foo" to bar rather than stdout as I'd expect.

It's triggered by the "if" statement (which doesn't even cause
running in a subshell, so it's not that).

#!/bin/bash
set -e
trap 'echo foo' 0
#false > bar  # "foo" written to stdout correctly
if true; then false; else false; fi > bar  # "foo" written to bar



reply via email to

[Prev in Thread] Current Thread [Next in Thread]