k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit 8ac5f0b74e410ba0e6b5dde0a7ec8e7d89668d50
parent 8c81a09bafcbe6c38175b0bb430dea4ff78ed3fb
Author: qorg11 <qorg@vxempire.xyz>
Date:   Mon, 15 Jun 2020 19:16:48 +0200

Add -a flag for ls.

Diffstat:
Msrc/ls.c | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/ls.c b/src/ls.c @@ -1,10 +1,20 @@ #include <stdio.h> #include <dirent.h> #include <unistd.h> +#include <getopt.h> int -main(void) +main(int argc, char *argv[]) { + int c = getopt(argc,argv,"a"); + int all; + switch(c) + { + case 'a': + all = 1; + break; + } + DIR *dir = opendir("."); struct dirent *ent; @@ -12,7 +22,7 @@ main(void) { while((ent = readdir(dir)) != NULL) { - if(ent->d_name[0] == '.') + if(ent->d_name[0] == '.' && !all) continue; printf("%s ",ent->d_name); /* TODO: sort, and do not display . and .. */ }