mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
Ls: Support multiple files
This commit is contained in:
parent
776a359a17
commit
4c410f3de6
Notes:
sideshowbarker
2024-07-19 13:54:50 +09:00
Author: https://github.com/faissaloo
Commit: 4c410f3de6
Pull-request: https://github.com/SerenityOS/serenity/pull/120
Reviewed-by: https://github.com/awesomekling
1 changed files with 26 additions and 10 deletions
|
@ -38,21 +38,37 @@ int main(int argc, char** argv)
|
|||
flag_show_inode = true;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "usage: ls [-%s] [path]\n", valid_option_characters);
|
||||
fprintf(stderr, "usage: ls [-%s] [paths...]\n", valid_option_characters);
|
||||
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)
|
||||
path = ".";
|
||||
else
|
||||
path = argv[optind];
|
||||
|
||||
if (flag_long)
|
||||
return do_dir(path);
|
||||
return do_dir_short(path);
|
||||
for (; optind < argc; optind++) {
|
||||
if (show_names) {
|
||||
printf("%s:\n", argv[optind]);
|
||||
}
|
||||
if (flag_long) {
|
||||
status = do_dir(argv[optind]);
|
||||
} else {
|
||||
status = do_dir_short(argv[optind]);
|
||||
}
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void get_geometry(int& rows, int& columns)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue