Op 17-03-17 om 20:53 schreef Thorsten Glaser: > Even mksh’s “global” builtin does not access the global scope. > It’s simply a “typeset” that’s not also “local”.
But why the separate builtin (which is unique to mksh, if I'm not mistaken) rather than 'typeset -g' as in zsh, bash 4 and yash? Please consider adding 'typeset -g' as a synonym for 'global' for those of us who target multiple shells: Index: funcs.c =================================================================== RCS file: /cvs/src/bin/mksh/funcs.c,v retrieving revision 1.327 diff -u -r1.327 funcs.c --- funcs.c 12 Mar 2017 02:31:26 -0000 1.327 +++ funcs.c 17 Mar 2017 21:42:39 -0000 @@ -784,7 +784,7 @@ } /* see comment below regarding possible opions */ - opts = istset ? "L#R#UZ#afi#lnprtux" : "p"; + opts = istset ? "L#R#UZ#agfi#lnprtux" : "p"; builtin_opt.flags |= GF_PLUSOPT; /* @@ -829,6 +829,9 @@ case 'f': func = true; break; + case 'g': + localv = false; + break; case 'i': flag = INTEGER; basestr = builtin_opt.optarg; Index: mksh.1 =================================================================== RCS file: /cvs/src/bin/mksh/mksh.1,v retrieving revision 1.427 diff -u -r1.427 mksh.1 --- mksh.1 12 Mar 2017 02:35:19 -0000 1.427 +++ mksh.1 17 Mar 2017 21:42:41 -0000 @@ -4803,7 +4803,7 @@ .Pp .It Xo .Ic global -.Oo Op Ic +\-alpnrtUux +.Oo Op Ic +\-aglnprtUux .Op Fl L Ns Op Ar n .Op Fl R Ns Op Ar n .Op Fl Z Ns Op Ar n @@ -4815,7 +4815,7 @@ .Xc .It Xo .Ic typeset -.Oo Op Ic +\-alpnrtUux +.Oo Op Ic +\-aglnprtUux .Op Fl LRZ Ns Op Ar n .Op Fl i Ns Op Ar n .No \*(Ba Fl f Op Fl tux Oc @@ -4880,6 +4880,11 @@ .It Fl f Function mode. Display or set functions and their attributes, instead of parameters. +.It Fl g +Disable the local scope for parameters. +Equivalent to using the +.Ic global +command. .It Fl i Ns Op Ar n Integer attribute. .Ar n