All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>
Cc: Vladimir Serbinenko <phcoder@gmail.com>,
	Glenn Washburn <development@efficientek.com>
Subject: [PATCH v6 0/6] More ls improvements
Date: Sat,  1 Mar 2025 23:15:31 -0600	[thread overview]
Message-ID: <cover.1740892196.git.development@efficientek.com> (raw)

Considering Daniel's feedback on the v2 of this patch series, I've broken up
patches #1 and #2 and dropped patch #3 from the original series. These changes
make the output of the ls command a little more like the GNU ls output.

Glenn Washburn

v6:
 * Rebase onto current master
 * Change ctx->filename to ctx->filename != NULL in tertiary conditional in
   patch 5 and add a comment explaining why ctx->filename is needed

v4: Add missing parenthesis

Glenn Washburn (6):
  commands/ls: Return proper GRUB_ERR_* for functions returning type
    grub_err_t
  commands/ls: Merge print_files_long and print_files into print_file
  commands/ls: Show modification time for file paths
  commands/ls: Output path for single file arguments given with path
  commands/ls: Print full paths for file args
  commands/ls: Add directory header for dir args

 grub-core/commands/ls.c | 103 +++++++++++++++++++++-------------------
 1 file changed, 54 insertions(+), 49 deletions(-)

Range-diff against v4:
1:  9086cccd8a0f = 1:  f8081dbd262d commands/ls: Return proper GRUB_ERR_* for functions returning type grub_err_t
2:  3192dc2471d0 = 2:  310a52b42d6d commands/ls: Merge print_files_long and print_files into print_file
3:  889e1e05a355 ! 3:  01532280401b commands/ls: Show modification time for file paths
    @@ grub-core/commands/ls.c: grub_ls_list_files (char *dirname, int longlist, int al
      
     -	  grub_file_close (file);
     -
    --	  p = grub_strrchr (dirname, '/') + 1;
    --	  ctx.dirname = grub_strndup (dirname, p - dirname);
    +-	  p = grub_strrchr (dirname, '/');
    +-	  if (p == NULL)
     +	  /* PATH might be a regular file.  */
    -+	  ctx.filename = grub_strrchr (dirname, '/') + 1;
    ++	  ctx.filename = grub_strrchr (dirname, '/');
    ++	  if (ctx.filename == NULL)
    + 	    goto fail;
    +-	  ++p;
    ++	  ++(ctx.filename);
    + 
    +-	  ctx.dirname = grub_strndup (dirname, p - dirname);
     +	  ctx.dirname = grub_strndup (dirname, ctx.filename - dirname);
      	  if (ctx.dirname == NULL)
      	    goto fail;
4:  d63e007f635b = 4:  fd4378a9302a commands/ls: Output path for single file arguments given with path
5:  39adcb21e320 ! 5:  16c2203f04dc commands/ls: Print full paths for file args
    @@ grub-core/commands/ls.c: print_file (const char *filename, const struct grub_dir
      		     datetime.minute, datetime.second);
          }
     -  grub_printf ("%s%s\n", filename, info->dir ? "/" : "");
    -+  grub_printf ("%s%s\n", (ctx->filename) ? pathname : filename,
    ++  /*
    ++   * Only print the full path when listing a file path given as an argument
    ++   * to ls (ie. when ctx->filename != NULL). File listings that are printed
    ++   * due to showing the contents of a directory do not need a full path because
    ++   * the full path to the directory will have already been printed.
    ++   */
    ++  grub_printf ("%s%s\n", (ctx->filename != NULL) ? pathname : filename,
     +			 info->dir ? "/" : "");
     +
     +  grub_free (pathname);
6:  0ebbfd3b0e15 ! 6:  ec9120ac52b0 commands/ls: Add directory header for dir args
    @@ grub-core/commands/ls.c: grub_ls_list_files (char *dirname, int longlist, int al
      
      	  /* PATH might be a regular file.  */
     +	  ctx.print_dirhdr = 0;
    - 	  ctx.filename = grub_strrchr (dirname, '/') + 1;
    - 	  ctx.dirname = grub_strndup (dirname, ctx.filename - dirname);
    - 	  if (ctx.dirname == NULL)
    + 	  ctx.filename = grub_strrchr (dirname, '/');
    + 	  if (ctx.filename == NULL)
    + 	    goto fail;
     @@ grub-core/commands/ls.c: grub_cmd_ls (grub_extcmd_context_t ctxt, int argc, char **args)
          grub_ls_list_devices (state[0].set);
        else
-- 
2.34.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2025-03-02  5:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-02  5:15 Glenn Washburn [this message]
2025-03-02  5:15 ` [PATCH v6 1/6] commands/ls: Return proper GRUB_ERR_* for functions returning type grub_err_t Glenn Washburn
2025-03-02  5:15 ` [PATCH v6 2/6] commands/ls: Merge print_files_long and print_files into print_file Glenn Washburn
2025-03-02  5:15 ` [PATCH v6 3/6] commands/ls: Show modification time for file paths Glenn Washburn
2025-03-02  5:15 ` [PATCH v6 4/6] commands/ls: Output path for single file arguments given with path Glenn Washburn
2025-03-02  5:15 ` [PATCH v6 5/6] commands/ls: Print full paths for file args Glenn Washburn
2025-03-02  5:15 ` [PATCH v6 6/6] commands/ls: Add directory header for dir args Glenn Washburn
2025-03-04 13:11 ` [PATCH v6 0/6] More ls improvements Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1740892196.git.development@efficientek.com \
    --to=development@efficientek.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=phcoder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.