Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All possible exit codes for cp

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?

like image 918
András Hummer Avatar asked May 10 '14 09:05

András Hummer


People also ask

What is exit code 255 in C?

Depending on our shell, exit code 255 might mean that the returned exit code is outside of the 0-255 range.

What is exit code 139 in C?

exit(139): It indicates Segmentation Fault which means that the program was trying to access a memory location not allocated to it. This mostly occurs while using pointers or trying to access an out-of-bounds array index.

What is exit 10 in shell script?

Exit Codes. Exit codes are a number between 0 and 255, which is returned by any Unix command when it returns control to its parent process. Other numbers can be used, but these are treated modulo 256, so exit -10 is equivalent to exit 246 , and exit 257 is equivalent to exit 1 .

What is exit code 11 in C?

Under Linux and most other Unix variants, the signal number 11 indicates a segmentation fault, as remarked by Kerrek SB.


2 Answers

Here is how cp from coreutils-8.21 exits:

exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);

There's nothing else than 0 or 1.

like image 125
Grapsus Avatar answered Oct 03 '22 14:10

Grapsus


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
like image 25
Krassi Fotev Avatar answered Oct 03 '22 14:10

Krassi Fotev