문제

Looking at the man pages for cp, I only found that the command exits with 0 when copy succeeds with no error, and with a number greater than 0 on any error. However I couldn't find any detailed description on specific exit codes mapped to specific cases. Is there such a description anywhere, is it even standardized, or each Unix/Linux distribution has its own exit code set for different scenarios?

도움이 되었습니까?

해결책

Here is how cp from coreutils-8.21 exits:

exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);

There's nothing else than 0 or 1.

다른 팁

On Mac (10.12.5 (16F73)) there are additional codes. For instance:

Mac$ cp -W 1 2; echo $?
cp: illegal option -- W
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
64
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top