This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new c0da2b2a0 nshlib: correct `ls -l` command output format
c0da2b2a0 is described below

commit c0da2b2a0e506f1c94c2b8b9b974ff5e3306dd31
Author: Junbo Zheng <[email protected]>
AuthorDate: Mon Oct 23 16:39:17 2023 +0800

    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 <[email protected]>
---
 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);
             }
         }
     }

Reply via email to