aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-08-29 12:47:52 -0700
committerRob Landley <rob@landley.net>2019-08-30 13:17:14 -0500
commitfe60afd4b7b7d4ee6bd271d5aee2d2ff088b563c (patch)
tree12d786ab4e619b48bcf6d36672be87e3c3c05f32 /toys/posix
parent3437f30ae9a24740bf3e9dd2b5db7482a5c1dfb8 (diff)
downloadtoybox-fe60afd4b7b7d4ee6bd271d5aee2d2ff088b563c.tar.gz
ls: fix recent regression.
Commit c26870dab3462c6176936384b090df6b9ba46dee broke ls' error reporting for files that don't exist. `ls $F` is used by some as an equivalent of `test -e $F`. This patch also adds a regression test.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/ls.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index fbd2405c..4ae352af 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -583,9 +583,13 @@ void ls_main(void)
dt = dirtree_add_node(0, *s, DIRTREE_STATLESS|DIRTREE_SYMFOLLOW*sym);
- // note: double_list->prev temporarirly goes in dirtree->parent
- if (dt) dlist_add_nomalloc((void *)&TT.files->child, (void *)dt);
- else toys.exitval = 1;
+ // note: double_list->prev temporarily goes in dirtree->parent
+ if (dt) {
+ if (!dt->st.st_blksize && !dt->st.st_dev && !dt->st.st_ino) {
+ perror_msg_raw(*s);
+ free(dt);
+ } else dlist_add_nomalloc((void *)&TT.files->child, (void *)dt);
+ } else toys.exitval = 1;
}
// Convert double_list into dirtree.