Shell: Expand ~ to home if its at the start of non quoted argument

This commit is contained in:
Bananymous 2024-10-06 01:38:43 +03:00
parent 4b13055125
commit 4f3c05851c
1 changed files with 6 additions and 0 deletions

View File

@ -254,6 +254,12 @@ static PipedCommand parse_piped_command(BAN::StringView command_view)
MUST(result.commands.push_back(current_command)); MUST(result.commands.push_back(current_command));
current_command.arguments.clear(); 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)) else if (!isspace(c))
MUST(current_argument.push_back(c)); MUST(current_argument.push_back(c));
else else