From: Kevin Day Date: Fri, 26 Jul 2019 01:49:29 +0000 (-0500) Subject: Bugfix: bash/linux does not support setting high bits on return codes X-Git-Tag: 0.4.3~12 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=bfb268f695c80c6bc72974b91ae0246b20858710;p=fll Bugfix: bash/linux does not support setting high bits on return codes These bits are generally reserved for process-specific behavior. Explicitly return 0 for success and 1 for failure. The firewall program already does this. The return codes from the main functions of each project will continue to utilize all of the bits as designed. This will allow for projects that link to the library to get the actual return codes while simultaneously being compatible with Linux and Bash. Later versions may provide alternative ways to get the error code from within the shell. For example, if a specific return code environment variable is set, then the program could populate that environment variable on exit (clearing it on start). --- diff --git a/level_3/fss_basic_list_read/c/main.c b/level_3/fss_basic_list_read/c/main.c index 0339ab0..9b2cc1c 100644 --- a/level_3/fss_basic_list_read/c/main.c +++ b/level_3/fss_basic_list_read/c/main.c @@ -7,5 +7,9 @@ int main(const f_array_length argc, const f_string argv[]) { data.process_pipe = f_true; } - return fss_basic_list_read_main(argc, argv, &data); + if (f_error_is_error(fss_basic_list_read_main(argc, argv, &data))) { + return 1; + } + + return 0; } diff --git a/level_3/fss_basic_list_write/c/main.c b/level_3/fss_basic_list_write/c/main.c index e83c8e4..88d1dc4 100644 --- a/level_3/fss_basic_list_write/c/main.c +++ b/level_3/fss_basic_list_write/c/main.c @@ -7,5 +7,9 @@ int main(const f_array_length argc, const f_string argv[]) { data.process_pipe = f_true; } - return fss_basic_list_write_main(argc, argv, &data); + if (f_error_is_error(fss_basic_list_write_main(argc, argv, &data))) { + return 1; + } + + return 0; } diff --git a/level_3/fss_basic_read/c/main.c b/level_3/fss_basic_read/c/main.c index a7df3e9..245e51f 100644 --- a/level_3/fss_basic_read/c/main.c +++ b/level_3/fss_basic_read/c/main.c @@ -7,5 +7,9 @@ int main(const f_array_length argc, const f_string argv[]) { data.process_pipe = f_true; } - return fss_basic_read_main(argc, argv, &data); + if (f_error_is_error(fss_basic_read_main(argc, argv, &data))) { + return 1; + } + + return 0; } diff --git a/level_3/fss_basic_write/c/main.c b/level_3/fss_basic_write/c/main.c index 842b604..1b0d77c 100644 --- a/level_3/fss_basic_write/c/main.c +++ b/level_3/fss_basic_write/c/main.c @@ -7,5 +7,9 @@ int main(const f_array_length argc, const f_string argv[]) { data.process_pipe = f_true; } - return fss_basic_write_main(argc, argv, &data); + if (f_error_is_error(fss_basic_write_main(argc, argv, &data))) { + return 1; + } + + return 0; } diff --git a/level_3/fss_extended_read/c/main.c b/level_3/fss_extended_read/c/main.c index 0d69a85..51420d1 100644 --- a/level_3/fss_extended_read/c/main.c +++ b/level_3/fss_extended_read/c/main.c @@ -7,5 +7,9 @@ int main(const f_array_length argc, const f_string argv[]) { data.process_pipe = f_true; } - return fss_extended_read_main(argc, argv, &data); + if (f_error_is_error(fss_extended_read_main(argc, argv, &data))) { + return 1; + } + + return 0; } diff --git a/level_3/fss_extended_write/c/main.c b/level_3/fss_extended_write/c/main.c index d929719..e209051 100644 --- a/level_3/fss_extended_write/c/main.c +++ b/level_3/fss_extended_write/c/main.c @@ -7,5 +7,9 @@ int main(const f_array_length argc, const f_string argv[]) { data.process_pipe = f_true; } - return fss_extended_write_main(argc, argv, &data); + if (f_error_is_error(fss_extended_write_main(argc, argv, &data))) { + return 1; + } + + return 0; } diff --git a/level_3/fss_return_code/c/main.c b/level_3/fss_return_code/c/main.c index 266212f..2291ea5 100644 --- a/level_3/fss_return_code/c/main.c +++ b/level_3/fss_return_code/c/main.c @@ -7,5 +7,9 @@ int main(const f_array_length argc, const f_string argv[]) { data.process_pipe = f_true; } - return fss_return_code_main(argc, argv, &data); + if (f_error_is_error(fss_return_code_main(argc, argv, &data))) { + return 1; + } + + return 0; } diff --git a/level_3/return_code/c/main.c b/level_3/return_code/c/main.c index 2476a69..13218b8 100644 --- a/level_3/return_code/c/main.c +++ b/level_3/return_code/c/main.c @@ -7,5 +7,9 @@ int main(const f_array_length argc, const f_string argv[]) { data.process_pipe = f_true; } - return return_code_main(argc, argv, &data); + if (f_error_is_error(return_code_main(argc, argv, &data))) { + return 1; + } + + return 0; }