diff options
author | Richard Lowe <richlowe@richlowe.net> | 2013-10-24 17:16:16 -0400 |
---|---|---|
committer | Richard Lowe <richlowe@richlowe.net> | 2013-11-22 22:26:44 -0500 |
commit | c5accfb2728453a874214835d99897e09a0cf3f2 (patch) | |
tree | 8482fea0fead9c4e85f0edaacde928e95a519107 /usr/src/cmd | |
parent | 44a646f1952df7a26e3bea7984f7a6c05d45eb0a (diff) | |
download | illumos-joyent-c5accfb2728453a874214835d99897e09a0cf3f2.tar.gz |
4270 ld(1) argument error reporting is still pretty bad
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Diffstat (limited to 'usr/src/cmd')
-rw-r--r-- | usr/src/cmd/sgs/libld/common/args.c | 15 | ||||
-rw-r--r-- | usr/src/cmd/sgs/libld/common/libld.msg | 1 | ||||
-rw-r--r-- | usr/src/cmd/sgs/libld/common/util.c | 20 | ||||
-rw-r--r-- | usr/src/cmd/sgs/packages/common/SUNWonld-README | 1 |
4 files changed, 30 insertions, 7 deletions
diff --git a/usr/src/cmd/sgs/libld/common/args.c b/usr/src/cmd/sgs/libld/common/args.c index 2b1ad39c54..1080168bbd 100644 --- a/usr/src/cmd/sgs/libld/common/args.c +++ b/usr/src/cmd/sgs/libld/common/args.c @@ -1679,8 +1679,19 @@ parseopt_pass1(Ofl_desc *ofl, int argc, char **argv, int *usage) case '?': DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL)); - eprintf(ofl->ofl_lml, ERR_FATAL, - MSG_INTL(MSG_ARG_UNKNOWN), optopt); + /* + * If the option character is '-', we're looking at a + * long option which couldn't be translated, display a + * more useful error. + */ + if (optopt == '-') { + eprintf(ofl->ofl_lml, ERR_FATAL, + MSG_INTL(MSG_ARG_LONG_UNKNOWN), + argv[optind-1]); + } else { + eprintf(ofl->ofl_lml, ERR_FATAL, + MSG_INTL(MSG_ARG_UNKNOWN), optopt); + } (*usage)++; break; diff --git a/usr/src/cmd/sgs/libld/common/libld.msg b/usr/src/cmd/sgs/libld/common/libld.msg index 761a293aed..ea111c0c2f 100644 --- a/usr/src/cmd/sgs/libld/common/libld.msg +++ b/usr/src/cmd/sgs/libld/common/libld.msg @@ -932,6 +932,7 @@ @ MSG_ARG_UNSUPPORTED "option %s is no longer supported; ignored" @ MSG_MARG_ONLY "option %s can only be used with a %s" @ MSG_ARG_UNKNOWN "unrecognized option '-%c'" +@ MSG_ARG_LONG_UNKNOWN "unrecognized option '%s'" @ MSG_ARG_USEHELP "use the -z help option for usage information" diff --git a/usr/src/cmd/sgs/libld/common/util.c b/usr/src/cmd/sgs/libld/common/util.c index d53df1b1e9..d9aaed59bc 100644 --- a/usr/src/cmd/sgs/libld/common/util.c +++ b/usr/src/cmd/sgs/libld/common/util.c @@ -301,9 +301,9 @@ str2chr_wrap_cb(int c) } /* - * Determine whether this string, possibly with an associated option, should be - * translated to an option character. If so, update the optind and optarg - * as described for short options in getopt(3c). + * Determine whether this string, possibly with an associated option, should + * be translated to an option character. If so, update the optind and optarg + * and optopt as described for short options in getopt(3c). * * entry: * lml - Link map list for debug messages @@ -329,6 +329,7 @@ str2chr(Lm_list *lml, int ndx, int argc, char **argv, char *arg, int c, if (strcmp(arg, opt) == 0) { DBG_CALL(Dbg_args_str2chr(lml, ndx, opt, c)); optind += 1; + optopt = c; return (c); } } else if ((strcmp(arg, opt) == 0) || @@ -345,8 +346,15 @@ str2chr(Lm_list *lml, int ndx, int argc, char **argv, char *arg, int c, * Make sure an optarg is available, and if not return * a failure to prevent any fall-through to the generic * getopt() processing. + * + * Since we'll be completely failing this option we + * don't want to update optopt with the translation, + * but also need to set it to _something_. Setting it + * to the '-' of the argument causes us to behave + * correctly. */ if ((++optind + 1) > argc) { + optopt = arg[0]; return ('?'); } optarg = argv[optind]; @@ -360,14 +368,16 @@ str2chr(Lm_list *lml, int ndx, int argc, char **argv, char *arg, int c, optarg = &arg[optsz]; optind++; if (*optarg == '=') { - if (*(++optarg) == '\0') + if (*(++optarg) == '\0') { + optopt = arg[0]; return ('?'); + } } } if (cbfunc != NULL) c = (*cbfunc)(c); - + optopt = c; return (c); } return (0); diff --git a/usr/src/cmd/sgs/packages/common/SUNWonld-README b/usr/src/cmd/sgs/packages/common/SUNWonld-README index 71f4a981a5..4ef9326cc8 100644 --- a/usr/src/cmd/sgs/packages/common/SUNWonld-README +++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README @@ -1651,3 +1651,4 @@ Bugid Risk Synopsis 3999 libld extended section handling is broken 4003 dldump() can't deal with extended sections 4227 ld --library-path is translated to -l-path, not -L +4270 ld(1) argument error reporting is still pretty bad |