1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/src/cmd/ksh93/bltins
Martijn Dekker 0a10e76ccc 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
2021-01-21 09:36:10 +00:00
..
alarm.c Revert "Fix SIGALRM core dump (Solaris patch 230-18229654)" 2021-01-09 13:18:00 +00:00
cd_pwd.c cd: add missing "test.h" include (re: 5ee290c7) 2021-01-20 22:13:32 +00:00
cflow.c Fix BUG_LOOPRET2 and related return/exit misbehaviour 2020-09-09 20:02:20 +02:00
enum.c '#if 0' cleanup 2020-08-30 04:51:20 +01:00
getopts.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
hist.c Reinstate 'r' and 'history' as preset aliases for interactive ksh 2020-09-11 21:35:45 +02:00
misc.c Turn off SH_INTERACTIVE state flag in subshells 2020-10-02 08:07:28 +02:00
mkservice.c '#if 0' cleanup 2020-08-30 04:51:20 +01:00
print.c Remove legacy code for older libast versions 2020-09-04 02:31:39 +02:00
read.c SHOPT_MULTIBYTE-related cleanup (re: 8477d2ce) 2020-08-30 04:50:57 +01:00
regress.c Fix 47 typos in user-facing help and error messages 2020-06-12 01:45:12 +02:00
sleep.c Fix how unrecognized options are handled in 'sleep' and 'suspend' (#93) 2020-07-26 02:18:49 +01:00
test.c -o posix: disable '[ -t ]' == '[ -t 1 ]' hack 2020-09-01 20:24:44 +01:00
trap.c Fix I/O redirection in -c script (Solaris patch 280-23332860) 2021-01-08 15:15:53 +00:00
typeset.c typeset: add error msgs for incompatible options; improve usage msg 2021-01-21 09:36:10 +00:00
ulimit.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
umask.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
whence.c whence -f: ignore functions (#137) 2020-09-26 19:26:18 +01:00