[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
shell redirection documentation
From: |
Eric Blake |
Subject: |
shell redirection documentation |
Date: |
Tue, 27 May 2008 17:11:50 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
This bit me in the M4 testsuite (tests of behavior on closed fd's failed on
Solaris 8 since the output leaked to the wrong fd, rather than generating the
expected invalid redirection error), so I'm documenting it.
>From f15bc5b04c7acc65f321ed3875e741000d0ce409 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 27 May 2008 11:07:01 -0600
Subject: [PATCH] Document Solaris /bin/sh redirection pitfall.
* doc/autoconf.texi (File Descriptors): Mention redirection bug.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 5 +++++
doc/autoconf.texi | 13 +++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 15adde0..5d2c610 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-05-27 Eric Blake <address@hidden>
+
+ Document Solaris /bin/sh redirection pitfall.
+ * doc/autoconf.texi (File Descriptors): Mention redirection bug.
+
2008-05-14 Eric Blake <address@hidden>
Improve documentation of ! issues.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index ee1ede5..cef2d3b 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -12698,6 +12698,19 @@ $
Within the process which runs the @samp{descrips} script, file
descriptor 5 is closed.
+Don't rely on redirection to a closed file descriptor to cause an
+error. With Solaris @command{/bin/sh}, when the redirection fails, the
+output goes to the original file descriptor.
+
address@hidden
+$ @kbd{bash -c 'echo hi >&3' 3>&-; echo $?}
+bash: 3: Bad file descriptor
+1
+$ @kbd{/bin/sh -c 'echo hi >&3' 3>&-; echo $?}
+hi
+0
address@hidden example
+
@acronym{DOS} variants cannot rename or remove open files, such as in
@samp{mv foo bar >foo} or @samp{rm foo >foo}, even though this is
perfectly portable among Posix hosts.
--
1.5.5.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- shell redirection documentation,
Eric Blake <=