summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-04-11 20:07:37 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-04-11 20:07:37 +0000
commitea778b6463b576bb12c851c8ee84b263a3bb64f9 (patch)
tree95d63000236703b24eb3e48870f701888f58bf90
parentcc4407f0fe07e25dab4aeef1a972401a15de047e (diff)
downloadcoreutils-ea778b6463b576bb12c851c8ee84b263a3bb64f9.tar.xz
(head_file): Don't assume open does not return 0.
-rw-r--r--src/head.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/head.c b/src/head.c
index b641f84a2..5c835b436 100644
--- a/src/head.c
+++ b/src/head.c
@@ -851,8 +851,9 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines,
{
int fd;
bool ok;
+ bool is_stdin = STREQ (filename, "-");
- if (STREQ (filename, "-"))
+ if (is_stdin)
{
have_read_stdin = true;
fd = STDIN_FILENO;
@@ -869,7 +870,7 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines,
}
ok = head (filename, fd, n_units, count_lines, elide_from_end);
- if (fd != STDIN_FILENO && close (fd) == -1)
+ if (!is_stdin && close (fd) != 0)
{
error (0, errno, _("closing %s"), quote (filename));
return false;