mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-24 15:04:13 +00:00
Following a community discussion, it became clear that 'r' is particularly problematic as a regular builtin, as the name can and does conflict with at least one legit external command by that name. There was a consensus against removing it altogether and letting users set the alias in their login scripts. However, aliases are easier to bypass, remove or rename than builtins are. My compromise is to reinstate 'r' as a preset alias on interactive shells only, along with 'history', as was done in17f81ebe
before they were converted to builtins in03224ae3
. So this reintroduces the notion of predefined aliases to ksh 93u+m, but only for interactive shells that are not initialised in POSIX mode. src/cmd/ksh93/Makefile, src/cmd/ksh93/Mamfile, src/cmd/ksh93/include/shtable.h, src/cmd/ksh93/data/aliases.c: - Restore aliases.c containing shtab_aliases[], a table specifying the preset aliases. src/cmd/ksh93/include/shtable.h, src/cmd/ksh93/sh/init.c: - Rename inittree() to sh_inittree() and make it extern, because we need to use it in main.c (sh_main()). src/cmd/ksh93/sh/main.c: sh_main(): - Init preset aliases from shtab_aliases[] only if the shell is interactive and not in POSIX mode. src/cmd/ksh93/bltins/typeset.c, src/cmd/ksh93/tests/alias.sh: - unall(): When unsetting an alias, pass on the NV_NOFREE attribute to nv_delete() to avoid an erroneous attempt to free a preset alias from read-only memory. See:5d50f825
src/cmd/ksh93/data/builtins.c: - Remove "history" and "r" entries from shtab_builtins[]. - Revert changes to inline fc/hist docs in sh_opthist[]. src/cmd/ksh93/bltins/hist.c: b_hist(): - Remove handling for 'history' and 'r' as builtins. src/cmd/ksh93/sh.1: - Update accordingly. Resolves: https://github.com/ksh93/ksh/issues/125
66 lines
2.4 KiB
C
66 lines
2.4 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 _SHTABLE_H
|
|
|
|
/*
|
|
* David Korn
|
|
* AT&T Labs
|
|
*
|
|
* Interface definitions read-only data tables for shell
|
|
*
|
|
*/
|
|
|
|
#define _SHTABLE_H 1
|
|
|
|
typedef struct shtable1
|
|
{
|
|
const char *sh_name;
|
|
const unsigned sh_number;
|
|
} Shtable_t;
|
|
|
|
struct shtable2
|
|
{
|
|
const char *sh_name;
|
|
const unsigned sh_number;
|
|
const char *sh_value;
|
|
};
|
|
|
|
struct shtable3
|
|
{
|
|
const char *sh_name;
|
|
const unsigned sh_number;
|
|
int (*sh_value)(int, char*[], Shbltin_t*);
|
|
};
|
|
|
|
#define sh_lookup(name,value) (sh_locate(name,(Shtable_t*)(value),sizeof(*(value)))->sh_number)
|
|
extern const Shtable_t shtab_testops[];
|
|
extern const Shtable_t shtab_options[];
|
|
extern const Shtable_t shtab_attributes[];
|
|
extern const struct shtable2 shtab_variables[];
|
|
extern const struct shtable2 shtab_aliases[];
|
|
extern const struct shtable2 shtab_signals[];
|
|
extern const struct shtable3 shtab_builtins[];
|
|
extern const Shtable_t shtab_reserved[];
|
|
extern const Shtable_t *sh_locate(const char*, const Shtable_t*, int);
|
|
extern int sh_lookopt(const char*, int*);
|
|
extern Dt_t *sh_inittree(Shell_t*, const struct shtable2*);
|
|
|
|
#endif /* SH_TABLE_H */
|