Commit b4c6759
committed
copy: fix file concatenation when invoked via COMMAND /C
The COPY command with file concatenation (e.g., `copy /b a+b dest`)
fails with "Source and destination cannot match" when invoked via
`COMMAND /C`, such as when nmake executes makefile commands.
Root cause: The /C handler builds cmd_line by concatenating argv
elements with spaces, always adding a trailing space after the last
argument. In expand_pluses(), `strrchr(cmd_args, ' ')` then finds
this trailing space instead of the space before the destination
filename, causing the destination to be effectively empty.
Example with trailing space from /C:
Input: "/b msload.com+msbio.cl1 io.sys "
last_arg = strrchr(..., ' ') -> points to trailing " "
Output: "/b msload.com ;msbio.cl1 io.sys "
Result: first file group has no destination, defaults to source
This bug was introduced in commit 234e221 ("copy: support any amount
of pluses [fixes #94]"). The previous implementation was immune to
trailing spaces because it used forward-searching (strchr from after
the +) rather than backward-searching (strrchr from end of string).
Fix: Strip trailing spaces from cmd_args_bkp before finding last_arg.1 parent 57f199e commit b4c6759
1 file changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2162 | 2162 | | |
2163 | 2163 | | |
2164 | 2164 | | |
| 2165 | + | |
| 2166 | + | |
2165 | 2167 | | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
2166 | 2171 | | |
2167 | 2172 | | |
2168 | 2173 | | |
| |||
0 commit comments