From f28da0c7cea5aba6c85475695e2e8f7c0d8df4ca Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 17 May 2011 15:16:56 +0000 Subject: [PATCH] New flag bit1 of API call Xorriso_prescan_args() reports unknown commands --- xorriso/parse_exec.c | 20 +++++++++++--------- xorriso/xorriso.h | 2 ++ xorriso/xorriso_main.c | 10 ++++++++-- xorriso/xorriso_timestamp.h | 2 +- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/xorriso/parse_exec.c b/xorriso/parse_exec.c index 57a96279..45197531 100644 --- a/xorriso/parse_exec.c +++ b/xorriso/parse_exec.c @@ -1624,15 +1624,17 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv, "stdio:/dev/fd/1" is interpreted as drive address. */ protect_stdout:; - Xorriso_protect_stdout(xorriso, 0); - sprintf(xorriso->info_text, + ret= Xorriso_protect_stdout(xorriso, 0); + if(ret == 1) { + sprintf(xorriso->info_text, "Encountered - or stdio:/dev/fd/1 as possible write target."); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); - sprintf(xorriso->info_text, + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + sprintf(xorriso->info_text, "Redirecting nearly all text message output to stderr."); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); - sprintf(xorriso->info_text, "Disabling use of libreadline."); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + sprintf(xorriso->info_text, "Disabling use of libreadline."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } } else if(strcmp(cmd,"abort_on")==0 && was_dashed == 1) { i++; @@ -1691,8 +1693,8 @@ protect_stdout:; ret= Xorriso_count_args(xorriso, argc - i, argv + i, &arg_count, 1); if(ret == 1) { i+= arg_count; - } else if((was_dashed && xorriso->add_plainly <= 1) || - xorriso->add_plainly <= 0) { + } else if((flag & 2) && ((was_dashed && xorriso->add_plainly <= 1) || + xorriso->add_plainly <= 0)) { sprintf(xorriso->info_text, "Not a known option: '%s'\n", original_cmd); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); diff --git a/xorriso/xorriso.h b/xorriso/xorriso.h index 5da50198..0f07f3ad 100644 --- a/xorriso/xorriso.h +++ b/xorriso/xorriso.h @@ -252,6 +252,8 @@ int Xorriso_destroy(struct XorrisO **xorriso, int flag); *idx will iterate over commands and parameters until this function aborts or until argc is reached. @param flag bit0= do not interpret argv[1] + bit1= produce FAILURE events on unknown commands + @since 1.1.0 @return <0 error 0 end program 1 ok, go on diff --git a/xorriso/xorriso_main.c b/xorriso/xorriso_main.c index b2666d2c..c861709d 100644 --- a/xorriso/xorriso_main.c +++ b/xorriso/xorriso_main.c @@ -226,14 +226,20 @@ int main(int argc, char **argv) /* The prescan of arguments performs actions which have to happen before the normal processing of startup files and arguments. + Among them are -help and -prog_help which end the program without + yelling its name and version. */ ret= Xorriso_prescan_args(xorriso,argc,argv,0); if(ret == 0) goto end_successfully; + /* Put out program name and version to stderr only if not done already now */ + yell_xorriso(); + if(ret < 0) + exit(5); + /* After having yelled xorriso, prescan again for unknown arguments */ + ret= Xorriso_prescan_args(xorriso, argc, argv, 2); if(ret < 0) exit(5); - - yell_xorriso(); /* The following command interpreters are allowed only after this initialization. diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index de4a2a56..d627c181 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2011.05.16.134341" +#define Xorriso_timestamP "2011.05.17.151719"