From: Pablo Neira Ayuso Date: Sat, 8 Apr 2023 18:16:07 +0000 (+0200) Subject: main: Error out when combining -i/--interactive and -f/--file X-Git-Tag: v1.0.8~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3915af337a8c7d8366131a00acb294dd4688e436;p=thirdparty%2Fnftables.git main: Error out when combining -i/--interactive and -f/--file These two options are mutually exclusive, display error in that case: # nft -i -f test.nft Error: -i/--interactive and -f/--file options cannot be combined Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/main.c b/src/main.c index 9bd25db8..cb20850b 100644 --- a/src/main.c +++ b/src/main.c @@ -405,9 +405,19 @@ int main(int argc, char * const *argv) nft_ctx_set_dry_run(nft, true); break; case OPT_FILE: + if (interactive) { + fprintf(stderr, + "Error: -i/--interactive and -f/--file options cannot be combined\n"); + exit(EXIT_FAILURE); + } filename = optarg; break; case OPT_INTERACTIVE: + if (filename) { + fprintf(stderr, + "Error: -i/--interactive and -f/--file options cannot be combined\n"); + exit(EXIT_FAILURE); + } interactive = true; break; case OPT_INCLUDEPATH: