Commit 8557455 1 parent 1b403b8 commit 8557455 Copy full SHA for 8557455
File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -32,21 +32,26 @@ struct SetenvPass : public Pass {
32
32
log (" \n " );
33
33
log (" setenv name value\n " );
34
34
log (" \n " );
35
- log (" Set the given environment variable on the current process. String values must be \n " );
36
- log (" passed in double quotes (\" ).\n " );
35
+ log (" Set the given environment variable on the current process. Values containing \n " );
36
+ log (" whitespace must be passed in double quotes (\" ).\n " );
37
37
log (" \n " );
38
38
}
39
39
void execute (std::vector<std::string> args, [[maybe_unused]] RTLIL::Design *design) override
40
40
{
41
41
if (args.size () != 3 )
42
42
log_cmd_error (" Wrong number of arguments given.\n " );
43
+
44
+ std::string name = args[1 ];
45
+ std::string value = args[2 ];
46
+ if (value.front () == ' \" ' && value.back () == ' \" ' ) value = value.substr (1 , value.size () - 2 );
43
47
44
48
#if defined(_WIN32)
45
- _putenv_s (args[ 1 ] .c_str (), args[ 2 ] .c_str ());
49
+ _putenv_s (name .c_str (), value .c_str ());
46
50
#else
47
- setenv (args[1 ].c_str (), args[2 ].c_str (), 1 );
51
+ if (setenv (name.c_str (), value.c_str (), 1 ))
52
+ log_cmd_error (" Invalid name \" %s\" .\n " , name.c_str ());
48
53
#endif
49
-
54
+
50
55
}
51
56
} SetenvPass;
52
57
You can’t perform that action at this time.
0 commit comments