mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
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
213 lines
7.7 KiB
C
213 lines
7.7 KiB
C
/***********************************************************************
|
|
* *
|
|
* This software is part of the ast package *
|
|
* Copyright (c) 1982-2012 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
|
|
|
|
#ifndef SYSDECLARE
|
|
|
|
#include <option.h>
|
|
#include "FEATURE/options"
|
|
#include "FEATURE/dynamic"
|
|
#include "shtable.h"
|
|
|
|
/*
|
|
* IDs for the parser (parse.c) and parse tree executer (xec.c)
|
|
* to implement special handling for the corresponding builtins.
|
|
* IMPORTANT: The offsets on these macros must be synchronous
|
|
* with the order of shtab_builtins[] in data/builtins.c!
|
|
*/
|
|
#define SYSEXEC (shgd->bltin_cmds) /* exec */
|
|
#define SYSREDIR (shgd->bltin_cmds+1) /* redirect */
|
|
#define SYSSET (shgd->bltin_cmds+2) /* set */
|
|
/* : */
|
|
#define SYSTRUE (shgd->bltin_cmds+4) /* true */
|
|
#define SYSCOMMAND (shgd->bltin_cmds+5) /* command */
|
|
#define SYSCD (shgd->bltin_cmds+6) /* cd */
|
|
#define SYSBREAK (shgd->bltin_cmds+7) /* break */
|
|
#define SYSCONT (shgd->bltin_cmds+8) /* continue */
|
|
|
|
#define SYSTYPESET (shgd->bltin_cmds+9) /* typeset \ */
|
|
/* autoload | */
|
|
#define SYSCOMPOUND (shgd->bltin_cmds+11) /* compound | */
|
|
/* float >typeset range */
|
|
/* functions | */
|
|
/* integer | */
|
|
#define SYSNAMEREF (shgd->bltin_cmds+15) /* nameref | */
|
|
#define SYSTYPESET_END (shgd->bltin_cmds+15) /* / */
|
|
|
|
#define SYSTEST (shgd->bltin_cmds+16) /* test */
|
|
#define SYSBRACKET (shgd->bltin_cmds+17) /* [ */
|
|
#define SYSLET (shgd->bltin_cmds+18) /* let */
|
|
#define SYSEXPORT (shgd->bltin_cmds+19) /* export */
|
|
#define SYSDOT (shgd->bltin_cmds+20) /* . */
|
|
#define SYSSOURCE (shgd->bltin_cmds+21) /* source */
|
|
#define SYSRETURN (shgd->bltin_cmds+22) /* return */
|
|
|
|
/* entry point for shell special builtins */
|
|
|
|
#if _BLD_shell && defined(__EXPORT__)
|
|
# define extern __EXPORT__
|
|
#endif
|
|
|
|
extern int b_alias(int, char*[],Shbltin_t*);
|
|
extern int b_break(int, char*[],Shbltin_t*);
|
|
extern int b_dot_cmd(int, char*[],Shbltin_t*);
|
|
extern int b_enum(int, char*[],Shbltin_t*);
|
|
extern int b_exec(int, char*[],Shbltin_t*);
|
|
extern int b_eval(int, char*[],Shbltin_t*);
|
|
extern int b_return(int, char*[],Shbltin_t*);
|
|
extern int B_login(int, char*[],Shbltin_t*);
|
|
extern int b_true(int, char*[],Shbltin_t*);
|
|
extern int b_false(int, char*[],Shbltin_t*);
|
|
extern int b_readonly(int, char*[],Shbltin_t*);
|
|
extern int b_set(int, char*[],Shbltin_t*);
|
|
extern int b_shift(int, char*[],Shbltin_t*);
|
|
extern int b_trap(int, char*[],Shbltin_t*);
|
|
extern int b_typeset(int, char*[],Shbltin_t*);
|
|
extern int b_unset(int, char*[],Shbltin_t*);
|
|
extern int b_unalias(int, char*[],Shbltin_t*);
|
|
|
|
/* The following are for job control */
|
|
#if defined(SIGCLD) || defined(SIGCHLD)
|
|
extern int b_jobs(int, char*[],Shbltin_t*);
|
|
extern int b_kill(int, char*[],Shbltin_t*);
|
|
# ifdef SIGTSTP
|
|
extern int b_bg(int, char*[],Shbltin_t*);
|
|
# endif /* SIGTSTP */
|
|
# ifdef SIGSTOP
|
|
extern int b_suspend(int, char*[],Shbltin_t*);
|
|
# endif /* SIGSTOP */
|
|
#endif
|
|
|
|
/* The following utilities are built-in because of side-effects */
|
|
extern int b_builtin(int, char*[],Shbltin_t*);
|
|
extern int b_cd(int, char*[],Shbltin_t*);
|
|
extern int b_command(int, char*[],Shbltin_t*);
|
|
extern int b_getopts(int, char*[],Shbltin_t*);
|
|
extern int b_hist(int, char*[],Shbltin_t*);
|
|
extern int b_let(int, char*[],Shbltin_t*);
|
|
extern int b_read(int, char*[],Shbltin_t*);
|
|
extern int b_ulimit(int, char*[],Shbltin_t*);
|
|
extern int b_umask(int, char*[],Shbltin_t*);
|
|
#ifdef _cmd_universe
|
|
extern int b_universe(int, char*[],Shbltin_t*);
|
|
#endif /* _cmd_universe */
|
|
extern int b_wait(int, char*[],Shbltin_t*);
|
|
extern int b_whence(int, char*[],Shbltin_t*);
|
|
|
|
extern int b_alarm(int, char*[],Shbltin_t*);
|
|
extern int b_print(int, char*[],Shbltin_t*);
|
|
extern int b_printf(int, char*[],Shbltin_t*);
|
|
extern int b_pwd(int, char*[],Shbltin_t*);
|
|
extern int b_sleep(int, char*[],Shbltin_t*);
|
|
extern int b_test(int, char*[],Shbltin_t*);
|
|
extern int b_times(int, char*[],Shbltin_t*);
|
|
#if !SHOPT_ECHOPRINT
|
|
extern int B_echo(int, char*[],Shbltin_t*);
|
|
#endif /* SHOPT_ECHOPRINT */
|
|
|
|
#undef extern
|
|
|
|
extern const char e_alrm1[];
|
|
extern const char e_alrm2[];
|
|
extern const char e_badfun[];
|
|
extern const char e_baddisc[];
|
|
extern const char e_nofork[];
|
|
extern const char e_nosignal[];
|
|
extern const char e_nolabels[];
|
|
extern const char e_notimp[];
|
|
extern const char e_nosupport[];
|
|
extern const char e_badbase[];
|
|
extern const char e_overlimit[];
|
|
|
|
extern const char e_eneedsarg[];
|
|
extern const char e_oneoperand[];
|
|
extern const char e_toomanyops[];
|
|
extern const char e_toodeep[];
|
|
extern const char e_badname[];
|
|
extern const char e_badsyntax[];
|
|
#ifdef _cmd_universe
|
|
extern const char e_nouniverse[];
|
|
#endif /* _cmd_universe */
|
|
extern const char e_histopen[];
|
|
extern const char e_condition[];
|
|
extern const char e_badrange[];
|
|
extern const char e_trap[];
|
|
extern const char e_direct[];
|
|
extern const char e_defedit[];
|
|
extern const char e_cneedsarg[];
|
|
extern const char e_defined[];
|
|
|
|
/* for option parsing */
|
|
extern const char sh_set[];
|
|
extern const char sh_optalarm[];
|
|
extern const char sh_optalias[];
|
|
extern const char sh_optbreak[];
|
|
extern const char sh_optbuiltin[];
|
|
extern const char sh_optcd[];
|
|
extern const char sh_optcommand[];
|
|
extern const char sh_optcont[];
|
|
extern const char sh_optdot[];
|
|
#ifndef ECHOPRINT
|
|
extern const char sh_optecho[];
|
|
#endif /* !ECHOPRINT */
|
|
extern const char sh_opteval[];
|
|
extern const char sh_optexec[];
|
|
extern const char sh_optredirect[];
|
|
extern const char sh_optexit[];
|
|
extern const char sh_optexport[];
|
|
extern const char sh_optgetopts[];
|
|
extern const char sh_optbg[];
|
|
extern const char sh_optdisown[];
|
|
extern const char sh_optfg[];
|
|
extern const char sh_opthash[];
|
|
extern const char sh_opthist[];
|
|
extern const char sh_optjobs[];
|
|
extern const char sh_optkill[];
|
|
#if defined(JOBS) && defined(SIGSTOP)
|
|
extern const char sh_optstop[];
|
|
extern const char sh_optsuspend[];
|
|
#endif /* defined(JOBS) && defined(SIGSTOP) */
|
|
extern const char sh_optksh[];
|
|
extern const char sh_optlet[];
|
|
extern const char sh_optprint[];
|
|
extern const char sh_optprintf[];
|
|
extern const char sh_optpwd[];
|
|
extern const char sh_optread[];
|
|
extern const char sh_optreadonly[];
|
|
extern const char sh_optreturn[];
|
|
extern const char sh_optset[];
|
|
extern const char sh_optshift[];
|
|
extern const char sh_optsleep[];
|
|
extern const char sh_opttrap[];
|
|
extern const char sh_opttypeset[];
|
|
extern const char sh_optulimit[];
|
|
extern const char sh_optumask[];
|
|
extern const char sh_optunalias[];
|
|
extern const char sh_optwait[];
|
|
#ifdef _cmd_universe
|
|
extern const char sh_optuniverse[];
|
|
#endif /* _cmd_universe */
|
|
extern const char sh_optunset[];
|
|
extern const char sh_optwhence[];
|
|
#endif /* SYSDECLARE */
|
|
extern const char sh_opttimes[];
|
|
|
|
extern const char e_dict[];
|
|
|