Command For SVN Diff Redirect To a Patch Failed

When execute the svn command to redirect to a patch file in shell, like powershell, svn diff > rb.diff, it will be successfully create a patch file. But when i call the same command in Command in Rust like following: Command::new("svn").arg("diff > rb.diff").output().expect("Failed to execute command!);

The error will be reported as follow:
svn: E020024: Error resolving case of '>'

So, i wanna know what wrong with that call in rust?

The redirection seems to be done by the shell and not the SVN itself. Try simply executing Command::new("svn").arg("diff") and processing its stdout manually.

Yes, the stdout can be captured and return the correct diff information. But i wonder why it does not work when combined the svn command with windows redirection command?

> is interpreted by your shell, not by svn, when you do Command::new you directly create a subprocess, not using the shell.

You can use your shell as command and provide the actual command as arg, but you need to figure out then how to pass a command via argument. For bash it's the switch -c.

1 Like

There isn't a "Windows redirection command". There is a redirection operator in the cmd shell, and one in powershell, but those are aspects of those specific shells, not of windows.

1 Like