add new experimental "global" command

This commit is contained in:
tg 2011-07-02 17:57:24 +00:00
parent 0785c2d71c
commit 64aade1a52
2 changed files with 20 additions and 7 deletions

View File

@ -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)
{

22
mksh.1
View File

@ -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