zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: zsh-3.1.5-pws-7: emulate locally
@ 1999-02-10 16:54 Peter Stephenson
  1999-02-10 17:24 ` PATCH: 3.0.5: " Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 1999-02-10 16:54 UTC (permalink / raw)
  To: Zsh hackers list

When using `emulate' in a shell function to ensure the correct
environment, it's a good habit to make sure the effect is local by
setting localoptions.  To encourage this good habit, I thought perhaps
it might be sensible to have an option -L to emulate itself to do
this.  Certainly you can just add `setopt localoptions', but it's easy
to forget.  If you always use `emulate -LR zsh', then you don't
forget.  I tried to clarify the manual entry a bit.
 
--- Doc/Zsh/builtins.yo.emloc	Thu Feb  4 17:50:30 1999
+++ Doc/Zsh/builtins.yo	Wed Feb 10 17:51:56 1999
@@ -215,13 +215,19 @@
 cindex(sh, compatibility)
 cindex(ksh, compatibility)
 cindex(csh, compatibility)
-item(tt(emulate) [ tt(-R) ] {tt(zsh)|tt(sh)|tt(ksh)|tt(csh)})(
+item(tt(emulate) [ tt(-LR) ] {tt(zsh)|tt(sh)|tt(ksh)|tt(csh)})(
 Set up zsh options to emulate the specified shell as much as possible.
 bf(csh) will never be fully emulated.
 If the argument is not one of the shells listed above, tt(zsh)
 will be used as a default.  If the tt(-R) option is given, all options
 are reset to their default value corresponding to the specified emulation
-mode.
+mode, except for certain options describing the interactive
+environment; otherwise, only those options likely to cause portability
+problems in scripts and functions are altered.  If the tt(-L) option
+is given, the option tt(LOCAL_OPTIONS) will be set as well, causing
+the effect of the tt(emulate) command to be local to the immediately
+surrounding shell function, if any; normally this is turned off in all
+emulation modes except tt(ksh).
 )
 findex(enable)
 cindex(enabling commands)
--- Src/builtin.c.emloc	Mon Feb  8 09:59:10 1999
+++ Src/builtin.c	Wed Feb 10 17:35:28 1999
@@ -56,7 +56,7 @@
     BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL),
     BUILTIN("echo", BINF_PRINTOPTS | BINF_ECHOPTS, bin_print, 0, -1, BIN_ECHO, "neE", "-"),
     BUILTIN("echotc", 0, bin_echotc, 1, -1, 0, NULL, NULL),
-    BUILTIN("emulate", 0, bin_emulate, 1, 1, 0, "R", NULL),
+    BUILTIN("emulate", 0, bin_emulate, 1, 1, 0, "LR", NULL),
     BUILTIN("enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmr", NULL),
     BUILTIN("eval", BINF_PSPECIAL, bin_eval, 0, -1, BIN_EVAL, NULL, NULL),
     BUILTIN("exit", BINF_PSPECIAL, bin_break, 0, 1, BIN_EXIT, NULL, NULL),
@@ -3051,6 +3051,8 @@
 bin_emulate(char *nam, char **argv, char *ops, int func)
 {
     emulate(*argv, ops['R']);
+    if (ops['L'])
+	dosetopt(LOCALOPTIONS, 1, 0);
     return 0;
 }
 
-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 2+ messages in thread

* PATCH: 3.0.5: Re: PATCH: zsh-3.1.5-pws-7: emulate locally
  1999-02-10 16:54 PATCH: zsh-3.1.5-pws-7: emulate locally Peter Stephenson
@ 1999-02-10 17:24 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1999-02-10 17:24 UTC (permalink / raw)
  To: Zsh hackers list

On Feb 10,  5:54pm, Peter Stephenson wrote:
} Subject: PATCH: zsh-3.1.5-pws-7: emulate locally
}
} When using `emulate' in a shell function to ensure the correct
} environment, it's a good habit to make sure the effect is local by
} setting localoptions.  To encourage this good habit, I thought perhaps
} it might be sensible to have an option -L to emulate itself

Here's the same patch against 3.0.5 (lacking doc, unfortunately).

Index: Src/builtin.c
===================================================================
--- builtin.c	1999/01/15 16:39:06	1.11
+++ builtin.c	1999/02/10 17:21:08
@@ -4768,6 +4768,8 @@
 bin_emulate(char *nam, char **argv, char *ops, int func)
 {
     emulate(*argv, ops['R']);
+    if (ops['L'])
+	dosetopt(LOCALOPTIONS, 1, 0);
     return 0;
 }
 
Index: Src/hashtable.h
===================================================================
--- hashtable.h	1997/06/27 19:18:21	1.3
+++ hashtable.h	1999/02/10 17:21:22
@@ -271,7 +271,7 @@
     {NULL, "disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL},
     {NULL, "echo", BINF_PRINTOPTS | BINF_ECHOPTS, bin_print, 0, -1, BIN_ECHO, "neE", "-"},
     {NULL, "echotc", 0, bin_echotc, 1, -1, 0, NULL, NULL},
-    {NULL, "emulate", 0, bin_emulate, 1, 1, 0, "R", NULL},
+    {NULL, "emulate", 0, bin_emulate, 1, 1, 0, "LR", NULL},
     {NULL, "enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmr", NULL},
     {NULL, "eval", BINF_PSPECIAL, bin_eval, 0, -1, BIN_EVAL, NULL, NULL},
     {NULL, "exit", BINF_PSPECIAL, bin_break, 0, 1, BIN_EXIT, NULL, NULL},

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-02-10 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-10 16:54 PATCH: zsh-3.1.5-pws-7: emulate locally Peter Stephenson
1999-02-10 17:24 ` PATCH: 3.0.5: " Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).