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.5.0~506 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=ee262771516920c13681512631aac3899549ad40;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 0cd7ee3..5f5130f 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(f_const f_array_length argc, f_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 feaa3e9..5132d14 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(f_const f_array_length argc, f_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 1c27146..a8826cd 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(f_const f_array_length argc, f_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 af17f39..3af35be 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(f_const f_array_length argc, f_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 b79163a..ee3ed39 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(f_const f_array_length argc, f_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 ceacde7..969fc3c 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(f_const f_array_length argc, f_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 fe72b7d..9045889 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(f_const f_array_length argc, f_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 facd261..639ef61 100644 --- a/level_3/return_code/c/main.c +++ b/level_3/return_code/c/main.c @@ -7,5 +7,9 @@ int main(f_const f_array_length argc, f_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; }