summaryrefslogtreecommitdiff
path: root/text-utils/line.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2012-11-02 20:15:39 +0400
committerIgor Pashev <pashev.igor@gmail.com>2012-11-02 20:15:39 +0400
commitb13154de3eca5ba28fbb4854d916cd0be5febeed (patch)
tree30f2e9e89ab71a2df837076ac68c3ba770230294 /text-utils/line.c
downloadutil-linux-upstream/2.22.tar.gz
Imported Upstream version 2.22upstream/2.22upstream
Diffstat (limited to 'text-utils/line.c')
-rw-r--r--text-utils/line.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/text-utils/line.c b/text-utils/line.c
new file mode 100644
index 0000000..636122e
--- /dev/null
+++ b/text-utils/line.c
@@ -0,0 +1,45 @@
+/*
+ * line - read one line
+ *
+ * Gunnar Ritter, Freiburg i. Br., Germany, December 2000.
+ *
+ * Public Domain.
+ */
+
+/*
+ * This command is deprecated. The utility is in maintenance mode,
+ * meaning we keep them in source tree for backward compatibility
+ * only. Do not waste time making this command better, unless the
+ * fix is about security or other very critical issue.
+ *
+ * See Documentation/deprecated.txt for more information.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+
+static int status; /* exit status */
+
+static void
+doline(int fd)
+{
+ char c;
+
+ for (;;) {
+ if (read(fd, &c, 1) <= 0) {
+ status = 1;
+ break;
+ }
+ if (c == '\n')
+ break;
+ putchar(c);
+ }
+ putchar('\n');
+}
+
+int
+main(void)
+{
+ doline(0);
+ return status;
+}