Skip to content

Commit

Permalink
query: user: fix shell_version
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Jun 27, 2024
1 parent 1df718c commit 24f7fda
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ std::string User::name() {

std::string User::shell() {
std::string shell = this->shell_path();
shell.erase(0, shell.find_last_of('/'));
shell.erase(0, shell.find_last_of('/')+1);

return shell;
}
Expand All @@ -33,17 +33,18 @@ std::string User::shell_version() {
switch (fnv1a32::hash(shell)) {
case "bash"_fnv1a32:
case "osh"_fnv1a32:
case "zsh"_fnv1a32:
ret = shell_exec(fmt::format("{} -c \"printf %s \"${}_VERSION\"\"", shell, str_toupper(shell))); break;
case "zsh"_fnv1a32:
ret = shell_exec(fmt::format("{} -c 'echo \"${}_VERSION\"'", shell, str_toupper(shell))); break;

case "nu"_fnv1a32:
ret = shell_exec("nu -c \"version | get version\""); break;

default:
ret = shell_exec(fmt::format("{} --version", shell));
ret.erase(0, ret.find(shell));
//ret.erase(0, ret.find(shell));
}

debug("ret = {}", ret);
strip(ret);
return ret;
}

0 comments on commit 24f7fda

Please sign in to comment.