Fix ls command parser (#3593)

This commit is contained in:
dvertx 2023-06-21 21:09:45 +07:00 committed by GitHub
parent 8bc33bae5c
commit c9ef508bf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -147,20 +147,15 @@ RZ_API RZ_OWN char *rz_syscmd_ls(RZ_NONNULL const char *input) {
eprintf("Usage: ls ([-e,-l,-j,-q]) ([path]) # long, json, quiet\n");
} else if ((!strncmp(input, "-e", 2))) {
printfmt = 'e';
path = rz_str_trim_head_ro(path + 1);
path = rz_str_trim_head_ro(input + 2);
} else if ((!strncmp(input, "-q", 2))) {
printfmt = 'q';
path = rz_str_trim_head_ro(path + 1);
path = rz_str_trim_head_ro(input + 2);
} else if ((!strncmp(input, "-l", 2)) || (!strncmp(input, "-j", 2))) {
// mode = 'l';
if (input[2]) {
printfmt = (input[2] == 'j') ? FMT_JSON : FMT_RAW;
path = rz_str_trim_head_ro(input + 2);
if (!*path) {
path = ".";
}
} else {
printfmt = FMT_RAW;
printfmt = (input[1] == 'j') ? FMT_JSON : FMT_RAW;
path = rz_str_trim_head_ro(input + 2);
if (!*path) {
path = ".";
}
} else {
path = input;