OSDN Git Service

merge in oc-release history after reset to master
[android-x86/external-toybox.git] / toys / posix / head.c
index 42f945b..f300760 100644 (file)
@@ -4,7 +4,7 @@
  *
  * See http://opengroup.org/onlinepubs/9699919799/utilities/head.html
 
-USE_HEAD(NEWTOY(head, "?n#<0=10", TOYFLAG_BIN))
+USE_HEAD(NEWTOY(head, "?n#<0=10", TOYFLAG_USR|TOYFLAG_BIN))
 
 config HEAD
   bool "head"
@@ -39,7 +39,7 @@ static void do_head(int fd, char *name)
 
   while (lines) {
     len = read(fd, toybuf, size);
-    if (len<0) perror_msg("%s",name);
+    if (len<0) perror_msg_raw(name);
     if (len<1) break;
 
     for(i=0; i<len;) if (toybuf[i++] == '\n' && !--lines) break;
@@ -56,6 +56,6 @@ void head_main(void)
   if (arg && *arg == '-' && arg[1]) {
     TT.lines = atolx(arg+1);
     toys.optc--;
-  }
+  } else arg = 0;
   loopfiles(toys.optargs+!!arg, do_head);
 }