From 97505583b1a4b2f0ba48debad8e6189d95414a22 Mon Sep 17 00:00:00 2001 From: Aleksandr Lebedev Date: Tue, 21 Apr 2026 17:52:39 +0200 Subject: [PATCH] Help message (-h or --help) --- main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.c b/main.c index 3c31164..0493c78 100644 --- a/main.c +++ b/main.c @@ -1054,6 +1054,18 @@ char* generate_ps1_prompt() int main(int argc, const char* argv[]) { + const bool show_help = argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0); + if(show_help) + { + printf("Arsh is a simple shell for Unix-like systems written in C, that has a funny name (for germans).\n\n"); + printf("Usage:\n"); + printf("- Start %s without arguments to use arsh shell interactively\n", argv[0]); + printf("- Start %s with a path to a script to launch it\n", argv[0]); + printf("- Start %s with a '-c' argument and a command afterwards to execute a specific command\n", argv[0]); + printf("- Start %s with a '-h' or '--help' argument to see this message\n", argv[0]); + exit(0); + } + setenv("SHELL", argv[0], 1); FILE* stream = stdin; char* prompt = generate_ps1_prompt();