bash fails to redirect standard output of a pipeline to the input file of the fist pipeline's command

Bug #1737846 reported by Arbiel Perlacremaz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
New
Undecided
Unassigned

Bug Description

In a non-interactive bash session, redirecting the standard output to the file read by the pipeline's first command leads to random resuts : the redirection sometimes works, but generally the file is overwriten by an empty file.
In an interactive session, the redirection works, which leads the user to look somewhere else to find a bug.

However, when the last command is a user-writen function which simulates "cat", the resulting file is correct, as in an interactive session.

Bash documentation does not prohibit such processing.

Arbiel

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: bash 4.3-7ubuntu1.5
ProcVersionSignature: Ubuntu 3.13.0-106.153-generic 3.13.11-ckt39
Uname: Linux 3.13.0-106-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.23
Architecture: amd64
CurrentDesktop: Unity
Date: Tue Dec 12 23:51:22 2017
InstallationDate: Installed on 2014-05-30 (1292 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Release amd64 (20140417)
ProcEnviron:
 LANGUAGE=fr_FR
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=fr_FR.UTF-8
 SHELL=/bin/bash
SourcePackage: bash
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Arbiel Perlacremaz (arbiel-perlacremaz) wrote :
Revision history for this message
Arbiel Perlacremaz (arbiel-perlacremaz) wrote :

Don't consider this as a bash bug. It's a misunderstanding by myself of the pipeline operation.

Maybe a comment should be included in the reference manual to cleary explain that the last command may try to open for writing the file still open for reading by the first command, and that such a situation obviously fails.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.