SCP: Add quoted string argument to SET ENV otherwise trim whitespace
Previously, unexpected values might end up being set when using SET ENV if there were trailing whitespace on the line being parsed. Any such white space is now explicitly trimmed before the environment variable is set. Once we do that, we need to provide a way to deliberately set an environment variable with trailing spaces. This is now achieved by using a quoted string value specified as: SET ENV -S var="value " The quotes are removed prior to setting the environment variable value. The contents of the quoted string are parsed the same as EXPECT and SEND arguments.
This commit is contained in:
parent
c8beee2d0f
commit
adedce8556
1 changed files with 13 additions and 1 deletions
14
scp.c
14
scp.c
|
@ -4575,8 +4575,20 @@ if (sim_switches & SWMASK ('P')) {
|
||||||
else
|
else
|
||||||
cptr = deflt;
|
cptr = deflt;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
cptr = get_glyph (cptr, varname, '='); /* get environment variable name */
|
cptr = get_glyph (cptr, varname, '='); /* get environment variable name */
|
||||||
|
strlcpy (cbuf, cptr, sizeof(cbuf));
|
||||||
|
sim_trim_endspc (cbuf);
|
||||||
|
cptr = cbuf;
|
||||||
|
if (sim_switches & SWMASK ('S')) { /* Quote String argument? */
|
||||||
|
uint32 str_size;
|
||||||
|
|
||||||
|
get_glyph_quoted (cptr, cbuf, 0);
|
||||||
|
if (SCPE_OK != sim_decode_quoted_string (cbuf, (uint8 *)cbuf, &str_size))
|
||||||
|
return sim_messagef (SCPE_ARG, "Invalid quoted string: %s\n", cbuf);
|
||||||
|
cbuf[str_size] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
setenv(varname, cptr, 1);
|
setenv(varname, cptr, 1);
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue