put the hyphen-minus back into the allowed alias name characters, for

Steffen Nurpmeso <steffen@sdaoden.eu>, except disallow it at the start
This commit is contained in:
tg 2017-04-06 19:02:07 +00:00
parent 6f991beb90
commit cadc884008
3 changed files with 8 additions and 7 deletions

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.336 2017/04/06 01:59:55 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.337 2017/04/06 19:02:05 tg Exp $");
#if HAVE_KILLPG
/*
@ -850,7 +850,7 @@ c_alias(const char **wp)
strndupx(xalias, alias, val++ - alias, ATEMP);
alias = xalias;
}
if (!valid_alias_name(alias)) {
if (!valid_alias_name(alias) || *alias == '-') {
bi_errorf(Tinvname, alias, Talias);
afree(xalias, ATEMP);
return (1);

6
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.438 2017/04/06 00:53:33 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.439 2017/04/06 19:02:05 tg Exp $
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
.\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
@ -3063,8 +3063,8 @@ For any name without a value, the existing alias is listed.
Any name with a value defines an alias (see
.Sx Aliases
above).
.Li \&[A\-Za\-z0\-9_!%,@]
are valid in names.
.Li \&[A\-Za\-z0\-9_!%,@\-]
are valid in names except they may not begin with a hyphen-minus.
.Pp
When listing aliases, one of two formats is used.
Normally, aliases are listed as

5
sh.h
View File

@ -175,7 +175,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.805 2017/04/06 01:59:56 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.806 2017/04/06 19:02:07 tg Exp $");
#endif
#define MKSH_VERSION "R54 2017/04/05"
@ -1277,7 +1277,8 @@ extern unsigned char chtypes[];
#define ord(c) ((int)(unsigned char)(c))
#define ksh_issubop2(c) tobool((c) == ord('#') || (c) == ord('%'))
#define ksh_isalias(c) (ctype((c), C_ALPHX | C_DIGIT) || (c) == ord('!') || \
(c) == ord('%') || (c) == ord(',') || (c) == ord('@'))
(c) == ord('%') || (c) == ord(',') || \
(c) == ord('@') || (c) == ord('-'))
#define ksh_isalpha(c) (ctype((c), C_ALPHX) && (c) != ord('_'))
#define ksh_isalphx(c) ctype((c), C_ALPHX)
#define ksh_isalnux(c) ctype((c), C_ALPHX | C_DIGIT)