[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"cmd | cat > file" does not create 'file' before running 'cmd'
From: |
Alexis Huxley |
Subject: |
"cmd | cat > file" does not create 'file' before running 'cmd' |
Date: |
Tue, 24 Sep 2002 10:02:28 +0200 |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-pc-linux-gnu'
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H -I.
-I/home/packages/bash/bash-2.05b -I/home/packages/bash/bash-2.05b/include
-I/home/packages/bash/bash-2.05b/lib -g -O2
uname output: Linux dione 2.4.16 #1 Sat Mar 9 19:04:14 CET 2002 i686 unknown
unknown GNU/Linux
Machine Type: i386-pc-linux-gnu
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
File created by stdout redirection not created before
command execution if command uses pipe.
Repeat-By:
rm -f fred
ls fred > fred
cat fred
This gives expected result:
fred
However, adding a pipe to the command like this:
rm -f fred
ls fred | cat > fred
cat fred
gives an unexpected failure:
ls: fred: No such file or directory
Surely the output file should *still* be created
before the command runs, and so the 'ls' should
find it when it is executed, and so there should
not be an error?
Alexis
- "cmd | cat > file" does not create 'file' before running 'cmd',
Alexis Huxley <=