From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17680 invoked by alias); 21 Aug 2015 03:59:12 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36256 Received: (qmail 5661 invoked from network); 21 Aug 2015 03:59:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:to:subject:mime-version :content-type; bh=eLasDRgobijbEhH/yx3zwSrcn6yI6jwf2lSEysfMPT4=; b=RJ+WhftmzJnYFP46oM6pwoijtnmsq8pmUL03ZpGAWHoc1V2GLleXt8Tg0yuzwvuUaT 7XieDIVJ6UhwtYbK/tt/CA5cOHcxy9iJIJ2n/6JQ+dXOFrqMQUb5YAFFVbWU0qphUZfF yQ/IAYjH8l9JphBKop4lIhr7Vm2EB0nUG6zDeTpnMeEjD6bGvHZ49mORZ4WOT1NhJ2vN J6WWW1I1FZ/Vphtz3LG4EaMGhVZaLmyt63dqlCll1eeJJeapYve2IzXcUzVsD561IAi9 LCuyZq3KPerVWq/RGqsrw3T+aRnXGpZ87aG0p4x/d2ec0UF91QUaaZQtSxFYHr4XaN4A B2gA== X-Gm-Message-State: ALoCoQkxR23h/f3UQnHYl8IaEfLndSTYuTLZ2gvgBH7pbyxlXsZUmHw086I0OkGe4gEl8wIAMv9Y X-Received: by 10.202.225.136 with SMTP id y130mr5712812oig.16.1440129547971; Thu, 20 Aug 2015 20:59:07 -0700 (PDT) From: Bart Schaefer Message-Id: <150820205904.ZM29615@torch.brasslantern.com> Date: Thu, 20 Aug 2015 20:59:04 -0700 X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Is this a bug in "emulate"? And is this the right fix? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii The syntax is emulate [ -LR ] [ {zsh|sh|ksh|csh} [ FLAGS ... ] ] where FLAGS are any of the usual things you can pass to "set". There is a notation: The -L switch is mutually exclusive with the use of -c in FLAGS. In fact it appears the -L switch is mutually incompatible with any FLAGS at all: torch% diff =(emulate -L sh ; set -o) =(emulate -L sh -e ; set -o) 50c50 < errexit off --- > errexit on 106,108c106,108 < localoptions on < localpatterns on < localtraps on --- > localoptions off > localpatterns off > localtraps off I would have expected the only difference to be errexit on/off. diff --git a/Src/builtin.c b/Src/builtin.c index 572a0dd..6411faa 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5465,8 +5465,8 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func)) /* with single argument set current emulation */ if (!argv[1]) { - emulate(shname, OPT_ISSET(ops,'R'), &emulation, opts); - if (OPT_ISSET(ops,'L')) + emulate(shname, opt_R, &emulation, opts); + if (opt_L) opts[LOCALOPTIONS] = opts[LOCALTRAPS] = opts[LOCALPATTERNS] = 1; clearpatterndisables(); return 0; @@ -5476,7 +5476,7 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func)) memcpy(saveopts, opts, sizeof(opts)); memcpy(new_opts, opts, sizeof(opts)); savehackchar = keyboardhackchar; - emulate(shname, OPT_ISSET(ops,'R'), &new_emulation, new_opts); + emulate(shname, opt_R, &new_emulation, new_opts); optlist = newlinklist(); if (parseopts("emulate", &argv, new_opts, &cmd, optlist)) { ret = 1; @@ -5508,8 +5508,11 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func)) goto restore2; } *--argv = cmd; /* on stack, never free()d, see execbuiltin() */ - } else + } else { + if (opt_L) + opts[LOCALOPTIONS] = opts[LOCALTRAPS] = opts[LOCALPATTERNS] = 1; return 0; + } save_sticky = sticky; sticky = hcalloc(sizeof(*sticky)); -- Barton E. Schaefer