[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 5/6] commands/ls: Print full paths for file args
From: |
Glenn Washburn |
Subject: |
[PATCH v4 5/6] commands/ls: Print full paths for file args |
Date: |
Mon, 6 Jan 2025 01:02:43 -0600 |
For arguments that are paths to files, print the full path of the file.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/commands/ls.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
index e33c16158d63..384d3e3cede8 100644
--- a/grub-core/commands/ls.c
+++ b/grub-core/commands/ls.c
@@ -98,6 +98,7 @@ static int
print_file (const char *filename, const struct grub_dirhook_info *info,
void *data)
{
+ char *pathname = NULL;
struct grub_ls_list_files_ctx *ctx = data;
if ((! ctx->all) && (filename[0] == '.'))
@@ -117,7 +118,6 @@ print_file (const char *filename, const struct
grub_dirhook_info *info,
if (! info->dir)
{
grub_file_t file;
- char *pathname;
if (ctx->dirname[grub_strlen (ctx->dirname) - 1] == '/')
pathname = grub_xasprintf ("%s%s", ctx->dirname, filename);
@@ -143,7 +143,6 @@ print_file (const char *filename, const struct
grub_dirhook_info *info,
else
grub_xputs ("????????????");
- grub_free (pathname);
grub_errno = GRUB_ERR_NONE;
}
else
@@ -165,7 +164,10 @@ print_file (const char *filename, const struct
grub_dirhook_info *info,
datetime.day, datetime.hour,
datetime.minute, datetime.second);
}
- grub_printf ("%s%s\n", filename, info->dir ? "/" : "");
+ grub_printf ("%s%s\n", (ctx->filename) ? pathname : filename,
+ info->dir ? "/" : "");
+
+ grub_free (pathname);
return 0;
}
--
2.34.1
- [PATCH v4 0/6] More ls improvements, Glenn Washburn, 2025/01/06
- [PATCH v4 1/6] commands/ls: Return proper GRUB_ERR_* for functions returning type grub_err_t, Glenn Washburn, 2025/01/06
- [PATCH v4 3/6] commands/ls: Show modification time for file paths, Glenn Washburn, 2025/01/06
- [PATCH v4 2/6] commands/ls: Merge print_files_long and print_files into print_file, Glenn Washburn, 2025/01/06
- [PATCH v4 4/6] commands/ls: Output path for single file arguments given with path, Glenn Washburn, 2025/01/06
- [PATCH v4 5/6] commands/ls: Print full paths for file args,
Glenn Washburn <=
- [PATCH v4 6/6] commands/ls: Add directory header for dir args, Glenn Washburn, 2025/01/06