mirror of
https://github.com/simh/simh.git
synced 2026-01-14 07:39:29 +00:00
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
14
scp.c
14
scp.c
@ -4575,8 +4575,20 @@ if (sim_switches & SWMASK ('P')) {
|
||||
else
|
||||
cptr = deflt;
|
||||
}
|
||||
else
|
||||
else {
|
||||
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);
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user