From 4f3c05851c892abaae96a21144b9e1453792c5d8 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 6 Oct 2024 01:38:43 +0300 Subject: [PATCH] Shell: Expand ~ to home if its at the start of non quoted argument --- userspace/programs/Shell/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/userspace/programs/Shell/main.cpp b/userspace/programs/Shell/main.cpp index 90abee777c..41b745a382 100644 --- a/userspace/programs/Shell/main.cpp +++ b/userspace/programs/Shell/main.cpp @@ -254,6 +254,12 @@ static PipedCommand parse_piped_command(BAN::StringView command_view) MUST(result.commands.push_back(current_command)); current_command.arguments.clear(); } + else if (c == '~' && (i == 0 || isspace(command_view[i - 1]))) + { + const char* home_env = getenv("HOME"); + if (home_env) + MUST(current_argument.append(home_env)); + } else if (!isspace(c)) MUST(current_argument.push_back(c)); else