mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
typeset: add error msgs for incompatible options; improve usage msg
This adds informative error messages if incompatible options are
given. It also documents the exclusive -m, -n and -T options on
separate usage lines, as was already done with -f. The usage
message for incompatible options now looks something like this:
| $ ksh -c 'typeset -L10 -F -f -i foo'
| ksh: typeset: -i/-F/-E/-X cannot be used with -L/-R/-Z
| ksh: typeset: -f cannot be used with other options
| Usage: typeset [-bflmnprstuxACHS] [-a[type]] [-i[base]] [-E[n]]
| [-F[n]] [-L[n]] [-M[mapping]] [-R[n]] [-X[n]]
| [-h string] [-T[tname]] [-Z[n]] [name[=value]...]
| Or: typeset -f [name...]
| Or: typeset -m [name=name...]
| Or: typeset -n [name=name...]
| Or: typeset -T [tname[=(type definition)]...]
| Help: typeset [ --help | --man ] 2>&1
(see also the previous commit, e21a053e
)
Unfortunately the first "Usage" line has some redundancies with the
"Or:" lines showing separate usages. It doesn't seem to be possible
to avoid this; it's a flaw in how libast generates everything
(usage, help, manual) from one huge getopt(3) string. I still think
the three added "Or:" lines are an improvement as it wasn't
previously shown that these options need to be used on their own.
src/cmd/ksh93/bltins/typeset.c: b_typeset():
- Instead of only showing a generic usage message, add an
informative error message if incompatible options were given.
- Conflicting options detection was failing because NV_LJUST and
NV_EXPNOTE have the same bitmask value. Use a new 'isadjust'
flag for -L/-R/-Z to remember if one of these was set.
- Detect conflict between -L/-R/-Z and a float option, not just -i.
src/cmd/ksh93/include/name.h, src/cmd/ksh93/data/msg.c:
- Add the two new error messages for incompatible options.
src/cmd/ksh93/data/builtins.c: sh_opttypeset[]:
- Add a space after 'float' in in "[+float?\btypeset -lE\b]" as
this makes 'float' appear on its own line, improving formatting.
- Show -m, -n, -T on separate usage lines like -f, as none of these
can be combined with other options.
- Remove "cannot be combined with other options" from -m and -n
descriptions, as that should now be clear from the separate usage
lines -- and even if not, the error message is now informative.
src/cmd/ksh93/sh.1, src/cmd/ksh93/COMPATIBILITY:
- Update.
src/cmd/ksh93/tests/types.sh:
- Remove obsolete test: 'typeset -RF' is no longer accepted.
(It crashed in 93u+, so this is not an incompatibility...)
Resolves: https://github.com/ksh93/ksh/issues/48
This commit is contained in:
parent
e21a053e19
commit
0a10e76ccc
8 changed files with 58 additions and 17 deletions
|
@ -7799,13 +7799,30 @@ cannot be exported.
|
|||
.PD
|
||||
.PP
|
||||
The
|
||||
.B \-i
|
||||
attribute cannot be specified along with
|
||||
.BR \-i ,
|
||||
.BR \-F ,
|
||||
.BR \-E ,
|
||||
and
|
||||
.B \-X
|
||||
options cannot be specified along with
|
||||
.BR \-R ,
|
||||
.BR \-L ,
|
||||
.BR \-Z ,
|
||||
or
|
||||
.BR \-f .
|
||||
.BR \-Z .
|
||||
The
|
||||
.B \-b
|
||||
option cannot be specified along with
|
||||
.BR \-L ,
|
||||
.BR \-u ,
|
||||
or
|
||||
.BR \-l .
|
||||
The
|
||||
.BR \-f ,
|
||||
.BR \-m ,
|
||||
.BR \-n ,
|
||||
and
|
||||
.B \-T
|
||||
options cannot be used together with any other option.
|
||||
.PP
|
||||
Using
|
||||
.B \+
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue