From c0da2b2a0e506f1c94c2b8b9b974ff5e3306dd31 Mon Sep 17 00:00:00 2001 From: Junbo Zheng Date: Mon, 23 Oct 2023 16:39:17 +0800 Subject: [PATCH] nshlib: correct `ls -l` command output format Since the output format will be messed up with a size of GB. before ``` ap> ls -l /dev: brw-rw-rw- 0 0314572800 app dr--r--r-- 0 0 0 audio/ crw-rw-rw- 0 0 0 buttons crw-rw-rw- 0 0 0 console brw-rw-rw- 0 0104857600 coredump crw-rw-rw- 0 0 0 crypto brw-rw-rw- 0 02214592512 data ``` after ``` ap> ls -l /dev: brw-rw-rw- 0 0 314572800 app dr--r--r-- 0 0 0 audio/ crw-rw-rw- 0 0 0 buttons crw-rw-rw- 0 0 0 console brw-rw-rw- 0 0 104857600 coredump crw-rw-rw- 0 0 0 crypto brw-rw-rw- 0 0 2214592512 data ``` Signed-off-by: Junbo Zheng --- nshlib/nsh_fscmds.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index 559fc31f1..237fa539a 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -290,20 +290,20 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath, { if (buf.st_size >= GB) { - nsh_output(vtbl, "%7.1fG", (float)buf.st_size / GB); + nsh_output(vtbl, "%11.1fG", (float)buf.st_size / GB); } else if (buf.st_size >= MB) { - nsh_output(vtbl, "%7.1fM", (float)buf.st_size / MB); + nsh_output(vtbl, "%11.1fM", (float)buf.st_size / MB); } else { - nsh_output(vtbl, "%7.1fK", (float)buf.st_size / KB); + nsh_output(vtbl, "%11.1fK", (float)buf.st_size / KB); } } else { - nsh_output(vtbl, "%8" PRIdOFF, buf.st_size); + nsh_output(vtbl, "%12" PRIdOFF, buf.st_size); } } }