Skip to content

Commit

Permalink
dropEmptyInitThenConcatStringsSep -> concatStringSep: PATH handling
Browse files Browse the repository at this point in the history
It's still wrong, but one step closer to correct.
Not that anyone should use "" or "." in their PATH, but that is not
for us to intervene.
  • Loading branch information
roberth committed Jul 13, 2024
1 parent 05159e8 commit cd85930
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/nix/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "command.hh"
#include "run.hh"
#include "strings.hh"

using namespace nix;

Expand Down Expand Up @@ -92,9 +93,10 @@ struct CmdShell : InstallablesCommand, MixEnvironment
}
}

// TODO: split losslessly; empty means .
auto unixPath = tokenizeString<Strings>(getEnv("PATH").value_or(""), ":");
unixPath.insert(unixPath.begin(), pathAdditions.begin(), pathAdditions.end());
auto unixPathString = dropEmptyInitThenConcatStringsSep(":", unixPath);
auto unixPathString = concatStringsSep(":", unixPath);
setEnv("PATH", unixPathString.c_str());

Strings args;
Expand Down

0 comments on commit cd85930

Please sign in to comment.