Skip to content

Commit

Permalink
why it doesn't work now??????
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Sep 26, 2024
1 parent 3571fea commit c96d4d0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,19 @@ void ctrl_d_handler(const std::istream& cin)
*/
std::string expandVar(std::string ret)
{
if (ret.empty())
return ret;

const char* env;
if (ret[0] == '~')
if (ret.front() == '~')
{
env = std::getenv("HOME");
if (env == nullptr)
die("FATAL: $HOME enviroment variable is not set (how?)");

ret.replace(0, 1, env); // replace ~ with the $HOME value
}
else if (ret[0] == '$')
else if (ret.front() == '$')
{
ret.erase(0, 1);

Expand Down

0 comments on commit c96d4d0

Please sign in to comment.