allow : and [ in alias names (but forbid [[ explicitly)

to make 'enable' completely work again
This commit is contained in:
tg
2017-04-27 23:33:22 +00:00
parent 8db6d22188
commit 9db3cb57b9
4 changed files with 19 additions and 15 deletions

View File

@ -38,7 +38,7 @@
#endif #endif
#endif #endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.346 2017/04/27 23:18:05 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.347 2017/04/27 23:33:18 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -747,6 +747,8 @@ valid_alias_name(const char *cp)
{ {
if (ord(*cp) == ord('-')) if (ord(*cp) == ord('-'))
return (false); return (false);
if (ord(cp[0]) == ord('[') && ord(cp[1]) == ord('[') && !cp[2])
return (false);
while (*cp) while (*cp)
if (ctype(*cp, C_ALIAS)) if (ctype(*cp, C_ALIAS))
++cp; ++cp;

10
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.444 2017/04/21 19:08:18 tg Exp $ .\" $MirOS: src/bin/mksh/mksh.1,v 1.445 2017/04/27 23:33:19 tg Exp $
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $ .\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
.\"- .\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
@ -76,7 +76,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to .\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always. .\" use our own definition. And .Dd must come *first*, always.
.\" .\"
.Dd $Mdocdate: April 21 2017 $ .Dd $Mdocdate: April 27 2017 $
.\" .\"
.\" Check which macro package we use, and do other -mdoc setup. .\" Check which macro package we use, and do other -mdoc setup.
.\" .\"
@ -3069,8 +3069,10 @@ For any name without a value, the existing alias is listed.
Any name with a value defines an alias; see Any name with a value defines an alias; see
.Sx Aliases .Sx Aliases
above. above.
.Li \&[A\-Za\-z0\-9_!%,.@\-] .Li \&[][A\-Za\-z0\-9_!%,.@:\-]
are valid in names except they may not begin with a hyphen-minus. are valid in names, except they may not begin with a hyphen-minus, and
.Ic \&[[
is not a valid alias name.
.Pp .Pp
When listing aliases, one of two formats is used. When listing aliases, one of two formats is used.
Normally, aliases are listed as Normally, aliases are listed as

14
sh.h
View File

@ -175,7 +175,7 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.818 2017/04/27 23:12:48 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.819 2017/04/27 23:33:20 tg Exp $");
#endif #endif
#define MKSH_VERSION "R55 2017/04/27" #define MKSH_VERSION "R55 2017/04/27"
@ -1319,7 +1319,7 @@ EXTERN bool really_exit;
#define CiCOLON BIT(26) /* : */ #define CiCOLON BIT(26) /* : */
#define CiEQUAL BIT(27) /* = */ #define CiEQUAL BIT(27) /* = */
#define CiQUEST BIT(28) /* ? */ #define CiQUEST BIT(28) /* ? */
#define CiCBRK BIT(29) /* ] */ #define CiBRACK BIT(29) /* ] */
#define CiUNDER BIT(30) /* _ */ #define CiUNDER BIT(30) /* _ */
#define CiGRAVE BIT(31) /* ` */ #define CiGRAVE BIT(31) /* ` */
@ -1332,8 +1332,8 @@ EXTERN char ifs0;
/* external types */ /* external types */
/* !%,-.0‥9@A‥Z_a‥z valid characters in alias name */ /* !%,-.0‥9:@A‥Z[]_a‥z valid characters in alias names */
#define C_ALIAS (CiALIAS | CiDIGIT | CiLOWER | CiMINUS | CiOCTAL | CiPERCT | CiUNDER | CiUPPER) #define C_ALIAS (CiALIAS | CiBRACK | CiCOLON | CiDIGIT | CiLOWER | CiMINUS | CiOCTAL | CiPERCT | CiUNDER | CiUPPER)
/* 0‥9A‥Za‥z alphanumerical */ /* 0‥9A‥Za‥z alphanumerical */
#define C_ALNUM (CiDIGIT | CiLOWER | CiOCTAL | CiUPPER) #define C_ALNUM (CiDIGIT | CiLOWER | CiOCTAL | CiUPPER)
/* 0‥9A‥Z_a‥z alphanumerical plus underscore (“word character”) */ /* 0‥9A‥Z_a‥z alphanumerical plus underscore (“word character”) */
@ -1369,7 +1369,7 @@ EXTERN char ifs0;
/* a‥z lowercase letters */ /* a‥z lowercase letters */
#define C_LOWER CiLOWER #define C_LOWER CiLOWER
/* not alnux or dollar separator for motion */ /* not alnux or dollar separator for motion */
#define C_MFS (CiALIAS | CiANGLE | CiCBRK | CiCNTRL | CiCOLON | CiCR | CiCURLY | CiEQUAL | CiGRAVE | CiHASH | CiMINUS | CiNL | CiNUL | CiPERCT | CiPLUS | CiQC | CiQCL | CiQCM | CiQCX | CiQUEST | CiSP | CiSPX | CiTAB) #define C_MFS (CiALIAS | CiANGLE | CiBRACK | CiCNTRL | CiCOLON | CiCR | CiCURLY | CiEQUAL | CiGRAVE | CiHASH | CiMINUS | CiNL | CiNUL | CiPERCT | CiPLUS | CiQC | CiQCL | CiQCM | CiQCX | CiQUEST | CiSP | CiSPX | CiTAB)
/* 0‥7 octal digit */ /* 0‥7 octal digit */
#define C_OCTAL CiOCTAL #define C_OCTAL CiOCTAL
/* \x20!*+?@ pattern magical operator */ /* \x20!*+?@ pattern magical operator */
@ -1377,9 +1377,9 @@ EXTERN char ifs0;
/* \x20‥~ POSIX printable characters (graph plus space) */ /* \x20‥~ POSIX printable characters (graph plus space) */
#define C_PRINT (C_GRAPH | CiSP) #define C_PRINT (C_GRAPH | CiSP)
/* !"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ POSIX punctuation */ /* !"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ POSIX punctuation */
#define C_PUNCT (CiALIAS | CiANGLE | CiCBRK | CiCOLON | CiCURLY | CiEQUAL | CiGRAVE | CiHASH | CiMINUS | CiPERCT | CiPLUS | CiQC | CiQCL | CiQCM | CiQCX | CiQUEST | CiSS | CiUNDER) #define C_PUNCT (CiALIAS | CiANGLE | CiBRACK | CiCOLON | CiCURLY | CiEQUAL | CiGRAVE | CiHASH | CiMINUS | CiPERCT | CiPLUS | CiQC | CiQCL | CiQCM | CiQCX | CiQUEST | CiSS | CiUNDER)
/* \x09\x0A"#$&'()*;<=>?[\\]`| characters requiring quoting, minus space */ /* \x09\x0A"#$&'()*;<=>?[\\]`| characters requiring quoting, minus space */
#define C_QUOTE (CiANGLE | CiCBRK | CiEQUAL | CiGRAVE | CiHASH | CiNL | CiQC | CiQCL | CiQCX | CiQUEST | CiSS | CiTAB) #define C_QUOTE (CiANGLE | CiBRACK | CiEQUAL | CiGRAVE | CiHASH | CiNL | CiQC | CiQCL | CiQCX | CiQUEST | CiSS | CiTAB)
/* 0‥9A‥Fa‥f hexadecimal digit */ /* 0‥9A‥Fa‥f hexadecimal digit */
#define C_SEDEC (CiDIGIT | CiHEXLT | CiOCTAL) #define C_SEDEC (CiDIGIT | CiHEXLT | CiOCTAL)
/* \x09‥\x0D\x20 POSIX space class */ /* \x09‥\x0D\x20 POSIX space class */

6
shf.c
View File

@ -25,7 +25,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.83 2017/04/27 23:12:49 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/shf.c,v 1.84 2017/04/27 23:33:22 tg Exp $");
/* flags to shf_emptybuf() */ /* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */ #define EB_READSW 0x01 /* about to switch to reading */
@ -1191,8 +1191,8 @@ const uint32_t tpl_ctypes[128] = {
/* 0x50 */ /* 0x50 */
CiUPPER, CiUPPER, CiUPPER, CiUPPER, CiUPPER, CiUPPER, CiUPPER, CiUPPER,
CiUPPER, CiUPPER, CiUPPER, CiUPPER, CiUPPER, CiUPPER, CiUPPER, CiUPPER,
CiUPPER, CiUPPER, CiUPPER, CiQCX, CiUPPER, CiUPPER, CiUPPER, CiQCX | CiBRACK,
CiQCX, CiCBRK, CiQCM, CiUNDER, CiQCX, CiBRACK, CiQCM, CiUNDER,
/* 0x60 */ /* 0x60 */
CiGRAVE, CiLOWER | CiHEXLT, CiGRAVE, CiLOWER | CiHEXLT,
CiLOWER | CiHEXLT, CiLOWER | CiHEXLT, CiLOWER | CiHEXLT, CiLOWER | CiHEXLT,