From 64aade1a523c8d7bd2e993edcc1384c8565022c9 Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 2 Jul 2011 17:57:24 +0000 Subject: [PATCH] add new experimental "global" command --- funcs.c | 5 +++-- mksh.1 | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/funcs.c b/funcs.c index eb37fad..1f9843e 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #endif #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.190 2011/06/21 21:11:19 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.191 2011/07/02 17:57:23 tg Exp $"); #if HAVE_KILLPG /* @@ -103,6 +103,7 @@ const struct builtin mkshbuiltins[] = { {"*=export", c_typeset}, {"+fc", c_fc}, {"+getopts", c_getopts}, + {"=global", c_typeset}, {"+jobs", c_jobs}, {"+kill", c_kill}, {"let", c_let}, @@ -597,7 +598,7 @@ c_command(const char **wp) return (c_whence(wp)); } -/* typeset, export, and readonly */ +/* typeset, global, export, and readonly */ int c_typeset(const char **wp) { diff --git a/mksh.1 b/mksh.1 index 7fb1c35..de4f39f 100644 --- a/mksh.1 +++ b/mksh.1 @@ -1,4 +1,4 @@ -.\" $MirOS: src/bin/mksh/mksh.1,v 1.265 2011/06/21 22:02:09 tg Exp $ +.\" $MirOS: src/bin/mksh/mksh.1,v 1.266 2011/07/02 17:57:24 tg Exp $ .\" $OpenBSD: ksh.1,v 1.140 2011/04/23 10:14:59 sobrado Exp $ .\"- .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, @@ -72,7 +72,7 @@ .\" with -mandoc, it might implement .Mx itself, but we want to .\" use our own definition. And .Dd must come *first*, always. .\" -.Dd $Mdocdate: June 21 2011 $ +.Dd $Mdocdate: July 2 2011 $ .\" .\" Check which macro package we use .\" @@ -4553,7 +4553,7 @@ traps in functions are not yet implemented. A command that exits with a zero value. .Pp .It Xo -.Ic typeset +.Ic global .Oo Op Ic +\-alpnrtUux .Op Fl L Ns Op Ar n .Op Fl R Ns Op Ar n @@ -4564,6 +4564,16 @@ A command that exits with a zero value. .Op Ns = Ns Ar value .Ar ... Oc .Xc +.It Xo +.Ic typeset +.Oo Op Ic +\-alpnrtUux +.Op Fl LRZ Ns Op Ar n +.Op Fl i Ns Op Ar n +.No \*(Ba Fl f Op Fl tux Oc +.Oo Ar name +.Op Ns = Ns Ar value +.Ar ... Oc +.Xc Display or set parameter attributes. With no .Ar name @@ -4587,10 +4597,12 @@ Values for parameters may optionally be specified. For .Ar name Ns \&[*] , the change affects the entire array, and no value may be specified. +.Pp If .Ic typeset -is used inside a function, any newly created parameters are local to the -function. +is used inside a function, any parameters specified are localised. +This is not done by the otherwise identical +.Ic global . .Pp When .Fl f