Fergus Daly wrote: > If you try > $ cp -v existingfile existingdirectory > you get feedback > 'existingfile' -> 'existingdirectory/existingfile' > which is just fine. (Omitting the switch -v silences the feedback: also fine.) > Whereas: if you try > $ cp -v existingfile nonexistingdirectory > you get feedback (two lines) > 'existingfile' -> 'nonexistingdirectory' > /bin/cp: cannot create regular file: No such file or directory > of which the 2nd line is useful advice but the 1st line is just a bit > misleading / irritating / .. difficult to ignore .. whatever. > (Try the same / similar thing with any other command e.g. rm e.g. md5sum and > you just get the 2nd line advice.) > Try > $ cp -v existingfile nonexistingdirectory 2> /dev/null > then you suppress line 2 as required; but you still get line 1 which now is > _very_ misleading / _very_ irritating! > This "feature" is matched in Linux. > Maybe a small thing but not to me. (Where it occurs it rather screws up the > smooth evolution of session logs.) > Does anybody know of a way of suppressing the 1st line feedback? > Thank you!
Cygwin's "cp" command is provided by the GNU Coreutils package, currently version 9.0. The two-line output you describe doesn't occur with the command "cp -v existingfile nonexistingdirectory". Since "nonexistingdirectory" doesn't exist, the cp command has no way to know whether it's expected to be a directory or a file. It's not a nonexisting directory; it's just a nonexisting *thing*. If the current directory is writable, that command will copy "existingfile" to a new file named "nonexistingdirectory". But you would get that output with: "cp -v existingfile nonexistingdirectory/" where the trailing / requires the target to be a directory. The `info cp` description of the -v / --verbose option is "Print the name of each file before copying it" (which is a little misleading; it actually prints both the source and the target). The `man cp` description is "explain what is being done", which is vague enough to be accurate. Experiment shows that it actually prints (to stdout) the source and target of the copy that it's *about* to perform, and then attempts to perform the copy. If an error occurs, a message is then printed to stderr. Apparently the FreeBSD version of "cp" doesn't print the verbose message if the copy operation fails. Both behaviors strike me as reasonable. I don't think there's any way (other than rebuilding coreutils from source or ) to get "cp" to behave the way you want. -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple