From cadc884008526419f85c40773ac6623e2bd166c5 Mon Sep 17 00:00:00 2001 From: tg Date: Thu, 6 Apr 2017 19:02:07 +0000 Subject: [PATCH] put the hyphen-minus back into the allowed alias name characters, for Steffen Nurpmeso , except disallow it at the start --- funcs.c | 4 ++-- mksh.1 | 6 +++--- sh.h | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/funcs.c b/funcs.c index 8fc3ec3..afdcbf5 100644 --- a/funcs.c +++ b/funcs.c @@ -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); diff --git a/mksh.1 b/mksh.1 index 196798d..ae4e919 100644 --- a/mksh.1 +++ b/mksh.1 @@ -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 diff --git a/sh.h b/sh.h index 7b88eaf..40f5d0d 100644 --- a/sh.h +++ b/sh.h @@ -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)