Fix substituion

This commit is contained in:
Jalal El Mansouri 2020-07-17 14:16:33 -04:00 committed by Ivo List
parent e5c008b55a
commit 38369f10dd
2 changed files with 3 additions and 3 deletions

View File

@ -56,7 +56,7 @@ int PW_MAIN(int argc, const CharType* argv[], const CharType* envp[]) {
<< ToUtf8(subst) << "\".\n";
return -1;
}
System::StrType value = subst.substr(equal_pos, subst.size());
System::StrType value = subst.substr(equal_pos + 1, subst.size());
if (value == PW_SYS_STR("${pwd}")) {
value = System::GetWorkingDirectory();
}

View File

@ -29,7 +29,7 @@ void basic_part2_test(std::string current_dir, const char* envp[]) {
}
void subst_pwd_test(std::string current_dir, const char* envp[]) {
if (current_dir == "${pwd}") {
if (current_dir.find("${pwd}") != std::string::npos) {
std::cerr << "error: argument ${pwd} substitution failed.\n";
std::exit(1);
}
@ -38,7 +38,7 @@ void subst_pwd_test(std::string current_dir, const char* envp[]) {
const std::string env = envp[i];
if (env.rfind("CURRENT_DIR", 0) == 0) {
found = true;
if (env.find("${pwd}") == 0) {
if (env.find("${pwd}") != std::string::npos) {
std::cerr << "error: environment variable ${pwd} substitution failed.\n";
std::exit(1);
}