From c9ef508bf4d78d136a53aa0a4e4bc18321405372 Mon Sep 17 00:00:00 2001 From: dvertx Date: Wed, 21 Jun 2023 21:09:45 +0700 Subject: [PATCH] Fix `ls` command parser (#3593) --- librz/util/syscmd.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/librz/util/syscmd.c b/librz/util/syscmd.c index 47155d8ea55..08326943ca2 100644 --- a/librz/util/syscmd.c +++ b/librz/util/syscmd.c @@ -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;