1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-24 06:54:13 +00:00
cde/src/cmd/ksh93/data/options.c
Martijn Dekker 921bbcaeb7 Remove SHOPT_BASH; keep &> redir operator, '-o posix' option
On 16 June there was a call for volunteers to fix the bash
compatibility mode; it has never successfully compiled in 93u+.
Since no one showed up, it is now removed due to lack of interest.

A couple of things are kept, which are now globally enabled:

1. The &>file redirection shorthand (for >file 2>&1). As a matter
   of fact, ksh93 already supported this natively, but only while
   running rc/profile/login scripts, and it issued a warning. This
   makse it globally available and removes the warning, bringing
   ksh93 in line with mksh, bash and zsh.

2. The '-o posix' standard compliance option. It is now enabled on
   startup if ksh is invoked as 'sh' or if the POSIXLY_CORRECT
   variable exists in the environment. To begin with, it disables
   the aforementioned &> redirection shorthand. Further compliance
   tweaks will be added in subsequent commits. The differences will
   be fairly minimal as ksh93 is mostly compliant already.

In all changed files, code was removed that was compiled (more
precisely, failed to compile/link) if the SHOPT_BASH preprocessor
identifier was defined. Below are other changes worth mentioning:

src/cmd/ksh93/sh/bash.c,
src/cmd/ksh93/data/bash_pre_rc.sh:
- Removed.

src/cmd/ksh93/data/lexstates.c,
src/cmd/ksh93/include/shlex.h,
src/cmd/ksh93/sh/lex.c:
- Globally enable &> redirection operator if SH_POSIX not active.
- Remove warning that was issued when &> was used in rc scripts.

src/cmd/ksh93/data/options.c,
src/cmd/ksh93/include/defs.h,
src/cmd/ksh93/sh/args.c:
- Keep SH_POSIX option (-o posix).
- Replace SH_TYPE_BASH shell type by SH_TYPE_POSIX.

src/cmd/ksh93/sh/init.c:
- sh_type(): Return SH_TYPE_POSIX shell type if ksh was invoked
  as sh (or rsh, restricted sh).
- sh_init(): Enable posix option if the SH_TYPE_POSIX shell type
  was detected, or if the CONFORMANCE ast config variable was set
  to "standard" (which libast sets on init if POSIXLY_CORRECT
  exists in the environment).

src/cmd/ksh93/tests/options.sh,
src/cmd/ksh93/tests/io.sh:
- Replace regression tests for &> and move to io.sh. Since &> is
  now for general use, no longer test in an rc script, and don't
  check that a warning is issued.

Closes: #9
Progresses: #20
2020-09-01 06:19:19 +01:00

100 lines
3.3 KiB
C

/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* http://www.eclipse.org/org/documents/epl-v10.html *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include "defs.h"
#include "name.h"
#include "shtable.h"
/*
* This is the list of invocation and set options
* This list must be in in ascii sorted order
*/
const Shtable_t shtab_options[] =
{
"allexport", SH_ALLEXPORT,
"bgnice", SH_BGNICE,
"braceexpand", SH_BRACEEXPAND,
"noclobber", SH_NOCLOBBER,
"emacs", SH_EMACS,
"errexit", SH_ERREXIT,
"noexec", SH_NOEXEC,
"noglob", SH_NOGLOB,
"globstar", SH_GLOBSTARS,
"gmacs", SH_GMACS,
#if SHOPT_HISTEXPAND
"histexpand", SH_HISTEXPAND,
#endif
"ignoreeof", SH_IGNOREEOF,
"interactive", SH_INTERACTIVE|SH_COMMANDLINE,
"keyword", SH_KEYWORD,
"letoctal", SH_LETOCTAL,
"nolog", SH_NOLOG,
"login_shell", SH_LOGIN_SHELL|SH_COMMANDLINE,
"markdirs", SH_MARKDIRS,
"monitor", SH_MONITOR,
"multiline", SH_MULTILINE,
"notify", SH_NOTIFY,
"pipefail", SH_PIPEFAIL,
"posix", SH_POSIX,
"privileged", SH_PRIVILEGED,
#if SHOPT_PFSH
"profile", SH_PFSH|SH_COMMANDLINE,
#endif
"rc", SH_RC|SH_COMMANDLINE,
"restricted", SH_RESTRICTED,
"showme", SH_SHOWME,
"trackall", SH_TRACKALL,
"nounset", SH_NOUNSET,
"verbose", SH_VERBOSE,
"vi", SH_VI,
"viraw", SH_VIRAW,
"xtrace", SH_XTRACE,
"", 0
};
const Shtable_t shtab_attributes[] =
{
{"-Sshared", NV_REF|NV_TAGGED},
{"-nnameref", NV_REF},
{"-xexport", NV_EXPORT},
{"-rreadonly", NV_RDONLY},
{"-ttagged", NV_TAGGED},
{"-Aassociative array", NV_ARRAY},
{"-aindexed array", NV_ARRAY},
{"-llong", (NV_DOUBLE|NV_LONG)},
{"-Eexponential",(NV_DOUBLE|NV_EXPNOTE)},
{"-Xhexfloat", (NV_DOUBLE|NV_HEXFLOAT)},
{"-Ffloat", NV_DOUBLE},
{"-llong", (NV_INTEGER|NV_LONG)},
{"-sshort", (NV_INTEGER|NV_SHORT)},
{"-uunsigned", (NV_INTEGER|NV_UNSIGN)},
{"-iinteger", NV_INTEGER},
{"-Hfilename", NV_HOST},
{"-bbinary", NV_BINARY},
{"-ltolower", NV_UTOL},
{"-utoupper", NV_LTOU},
{"-Zzerofill", NV_ZFILL},
{"-Lleftjust", NV_LJUST},
{"-Rrightjust", NV_RJUST},
{"++namespace", NV_TABLE},
{"", 0}
};