dropEmptyInitThenConcatStringsSep -> concatStringSep: PATH handling

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.
This commit is contained in:
Robert Hensing 2024-07-13 01:49:34 +02:00
parent 9ca42d5da2
commit 76b2d5ef3d

View file

@ -3,6 +3,7 @@
#include "command.hh"
#include "run.hh"
#include "strings.hh"
using namespace nix;
@ -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;