what's checked in now still doesn't work in the regular file case though...


Subject: [PATCH] Fix file "cannot open".

We don't want to _always_ fall through.
---
 toys/pending/file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

On Mon, Feb 29, 2016 at 1:15 PM, Rob Landley <[email protected]> wrote:
> Already checked these two in before I saw this. (I checked in the
> architecture name list redo last night because the changes to file were
> turning into a rathole, but "I tested this and it worked" only means
> something if you haven't changed it since. Sigh...)
>
> It should be working now. And I can make test cases that check /dev is a
> directory, /dev/zero is a char device, /dev/loop0 is a block device (as
> standard of one as we're likely to get anyway), mkfifo a fifo, ln -s
> makes a symlink...
>
> Huh,
>
> $ file /usr/lib/firefox/firefox.sh
> /usr/lib/firefox/firefox.sh: POSIX shell script, ASCII text executable
>
> According to posix that should reply "commands text". Once again, posix
> is completely ignored in practice.
>
> Sigh,
>
> Rob



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
From 78f1813b143bcfe1a39766d9fd918296ab03865c Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Mon, 29 Feb 2016 16:23:05 -0800
Subject: [PATCH] Fix file "cannot open".

We don't want to _always_ fall through.
---
 toys/pending/file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/toys/pending/file.c b/toys/pending/file.c
index 49f987c..637402b 100644
--- a/toys/pending/file.c
+++ b/toys/pending/file.c
@@ -247,10 +247,11 @@ void file_main(void)
         int fd = !strcmp(name, "-") ? 0 : open(name, O_RDONLY);
 
         if (fd!=-1) {
-          if (sb.st_size == 0) what = "empty";
+          if (sb.st_size == 0) xputs("empty");
           else do_regular_file(fd, name);
         }
         if (fd>0) close(fd);
+        continue;
       } else if (S_ISBLK(sb.st_mode)) what = "block special";
       else if (S_ISCHR(sb.st_mode)) what = "character special";
       else if (S_ISDIR(sb.st_mode)) what = "directory";
-- 
2.7.0.rc3.207.g0ac5344

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to