lab5: 指令参数匹配可能缺少空格

This commit is contained in:
KAAAsS 2022-04-21 14:28:39 +08:00
parent 9f3a58f966
commit 495c7c195f
Signed by: KAAAsS
GPG Key ID: D22F53AF662411FE

View File

@ -148,6 +148,9 @@ static char *match_builtin_command_param(char *complement, int complement_time,
if (matched) { if (matched) {
// 如果匹配到,就进行拼接 // 如果匹配到,就进行拼接
memcpy(buf, complement, start_pos); memcpy(buf, complement, start_pos);
if (buf[start_pos - 1] != ' ') {
buf[start_pos++] = ' ';
}
strcpy(buf + start_pos, matched); strcpy(buf + start_pos, matched);
return buf; return buf;
} }