mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
Ls: Support multiple files
This commit is contained in:
parent
776a359a17
commit
4c410f3de6
1 changed files with 26 additions and 10 deletions
|
@ -38,21 +38,37 @@ int main(int argc, char** argv)
|
||||||
flag_show_inode = true;
|
flag_show_inode = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "usage: ls [-%s] [path]\n", valid_option_characters);
|
fprintf(stderr, "usage: ls [-%s] [paths...]\n", valid_option_characters);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* path;
|
int status;
|
||||||
|
if (optind >= argc) {
|
||||||
|
if (flag_long) {
|
||||||
|
status = do_dir(".");
|
||||||
|
} else {
|
||||||
|
status = do_dir_short(".");
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
} else {
|
||||||
|
bool show_names = !(optind+1 >= argc);
|
||||||
|
|
||||||
if (optind >= argc)
|
for (; optind < argc; optind++) {
|
||||||
path = ".";
|
if (show_names) {
|
||||||
else
|
printf("%s:\n", argv[optind]);
|
||||||
path = argv[optind];
|
}
|
||||||
|
if (flag_long) {
|
||||||
if (flag_long)
|
status = do_dir(argv[optind]);
|
||||||
return do_dir(path);
|
} else {
|
||||||
return do_dir_short(path);
|
status = do_dir_short(argv[optind]);
|
||||||
|
}
|
||||||
|
if (status != 0) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_geometry(int& rows, int& columns)
|
void get_geometry(int& rows, int& columns)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue