From 60550a315269fbc2e1a2b989482eca69f350ab00 Mon Sep 17 00:00:00 2001 From: Damian Loewnau Date: Wed, 5 Oct 2022 18:21:01 +0200 Subject: [PATCH 1/3] psh: history: fix passing double dash PD-303 --- psh/pshapp/pshapp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psh/pshapp/pshapp.c b/psh/pshapp/pshapp.c index 786f0be8..5cb6adba 100644 --- a/psh/pshapp/pshapp.c +++ b/psh/pshapp/pshapp.c @@ -945,7 +945,7 @@ int psh_history(int argc, char **argv) } /* History command doesn't take any arguments */ - if (optind < argc) { + if (optind <= argc && !help && !clear) { psh_historyhelp(); return EXIT_FAILURE; } From 7e1b727ddb4905052e7b55637c08cb60d31edb13 Mon Sep 17 00:00:00 2001 From: Damian Loewnau Date: Wed, 5 Oct 2022 18:21:40 +0200 Subject: [PATCH 2/3] psh: mem: fix passing double dash PD-303 --- psh/mem/mem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/psh/mem/mem.c b/psh/mem/mem.c index ff584416..0f241dee 100644 --- a/psh/mem/mem.c +++ b/psh/mem/mem.c @@ -319,7 +319,7 @@ static int psh_sharedMaps(void) static int psh_mem(int argc, char **argv) { - int c; + int c, ind; if (argc == 1) return psh_mem_summary() < 0 ? EXIT_FAILURE : EXIT_SUCCESS; @@ -343,8 +343,9 @@ static int psh_mem(int argc, char **argv) } } - if (optind < argc) { - fprintf(stderr, "mem: unknown argument: %s\n", argv[optind]); + if (optind <= argc) { + ind = (optind == argc) ? optind - 1 : optind; + fprintf(stderr, "mem: unknown argument: %s\n", argv[ind]); return EXIT_FAILURE; } From 71dc3376149ee5bf3589652bb6c9037fa5691938 Mon Sep 17 00:00:00 2001 From: Damian Loewnau Date: Wed, 5 Oct 2022 18:21:51 +0200 Subject: [PATCH 3/3] psh: echo: fix passing double dash PD-303 --- psh/echo/echo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/psh/echo/echo.c b/psh/echo/echo.c index 8310cd15..ad54f60d 100644 --- a/psh/echo/echo.c +++ b/psh/echo/echo.c @@ -90,8 +90,8 @@ static int psh_echo(int argc, char **argv) } } - for (i = optind; i < argend; ++i) { - if (i != optind) { + for (i = 1; i < argend; ++i) { + if (i != 1) { fputc(' ', output); }