From 67d39f0d29bcd982a2976d9c1649cd891ab5405c Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sat, 6 Mar 2010 15:13:36 -0800 Subject: [PATCH] dir.c32: allow "dir" without an argument to mean "dir ." People logically expect "dir" to display the current directory. Signed-off-by: H. Peter Anvin --- com32/modules/dir.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/com32/modules/dir.c b/com32/modules/dir.c index cb83f97..10fa5c2 100644 --- a/com32/modules/dir.c +++ b/com32/modules/dir.c @@ -147,19 +147,25 @@ nomem: int main(int argc, char *argv[]) { + int rv; + openconsole(&dev_rawcon_r, &dev_stdcon_w); - if (argc != 2) { - printf("Usage: dir directory\n"); - return 0; - } - if (getscreensize(1, &rows, &cols)) { /* Unknown screen size? */ rows = 24; cols = 80; } - return display_directory(argv[1]); + if (argc < 2) + rv = display_directory("."); + else if (argc == 2) + rv = display_directory(argv[1]); + else { + printf("Usage: dir directory\n"); + rv = 1; + } + + return rv ? 1 : 0; } -- 2.7.4