From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10763 invoked from network); 2 Jul 2022 22:11:17 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Jul 2022 22:11:17 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1656799877; b=Q1HNcW8jA7WepdT76xirinfhELwHIpZC+acFUVw8aq/iz4BIPUvA7t8n8keDcta4ZWekBjWpmm MpufYqkPzlbErVw9TNW66yOQVDqX3HqgDDQlqvwcCLEOXCvvPGxiZ5lCeW2xdo6KlNH6HGvZi4 MTpmB8EXDPLXqd09dVSnCh3GM5oRD69WkqlgClhhazDmmPRcDMoCXvDgFoMDObVTJWpO0gSxFr +INIdyB9ESTqtTi3ixAwvx8Fhmz9vn5S9eSTRMarygEUI5I7gVnoW12B8z4ortR8qGhbeikYQc Ld3XKR0jhT3ffR1K6L2N2hpEs1i9vqdwvNN4YXpQQwHbfw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f52.google.com) smtp.remote-ip=209.85.218.52; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1656799877; bh=RdPYIvVB2pk3HDgLY9UdwGleBGPLktQgwoYB5/MQYxA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=Ewk9LEzvv/zdlLYSEolY2UsxzOG+9Z2TJ0K/WIfT9quEu6EMPvmoywWXNOYjEC4Ky8JR6yZKtf GadbJm5OTwyb1K61Uk1Pv97EBLOxK4QQBn6H/qArsXCMiITL4v8mkyGfKSUa41KztY2C3GIRoM zFv/Cuj/Vcu7D0EHOqsPq2FHDFvvqHvl9G4eKaBFcaxvAlZDhFPRmqrK8SeyRrHH+kBYaA6766 vUks2VjZhnGw4w+3h5FoPjzvfZKl6zA09FZy2IeBNyK+9y+u75I3Twl20/QdQNSbCGnUXdLu4u 28AMy7EXCs+0rrKPEAgQ2LQ6/tJ7Jm97SJ5xLEi+nebD5Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Bjt9Vo3Vu1bLcU1qFygcp8qvNnttSpZRYaveRU0JgNI=; b=Xuagw2O4jm8QssSB0w0wpkLJ2e 8IQYhmsUlBybkTzS7yVG25E3eHqrYMAwMTn3b3tqzSVIGJof1Cqbgz+l+mEK6wl5/0UD/SIGqu270 I/VYf469RrJTnyS8pbc4wN7/U/p0nqOXK5DPfkXjBHfxoKNe3kL2OeNP27N/4P5gdMP9JZMIOGYCI VF1vyaM1JtgLl1qvha2ALq2zG2HKI8qF21EtZ9UzNLQeWrVwmn9FhV87Z7d3XA+rn5HS03bOR4BIS HvVqj5jTqem8LTVvqgYe41GWThhdEl/WBOoWO/3N2/VeonY3HUE/xZVvmbGURUhJY/oNOix52wBPr oiGzj7vA==; Received: from authenticated user by zero.zsh.org with local id 1o7lKd-0001mX-A0; Sat, 02 Jul 2022 22:11:15 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f52.google.com) smtp.remote-ip=209.85.218.52; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f52.google.com ([209.85.218.52]:46840) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1o7lFU-0001LH-Oy; Sat, 02 Jul 2022 22:05:57 +0000 Received: by mail-ej1-f52.google.com with SMTP id q6so10055180eji.13 for ; Sat, 02 Jul 2022 15:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Bjt9Vo3Vu1bLcU1qFygcp8qvNnttSpZRYaveRU0JgNI=; b=rqfNGSkdb/oQ6MyRx7tc9gVC24ol7ISOQ1/PA3Ni31XUrl0GKD1DZO9bIlWCBtFgaZ 4MPb00a7cS96fYm7dDq+2sgGV99eO4usyHI8JOD384EPR5jUCOHxByFY+P6ggYYaoVfs WAa5ofRr5MAqF5EpotT1kReYKhEGoFC5IOWkQQE/Sx0E8BT80y2YUyPn6admxhyNQ1Yg pqRNdikyfdr+cwhqHhMfnuWNcclmCUcQflUOONo/hYNWvcdUtJIx9ohhUJi3g0nvzfno T9yk02bZ+Yf5IEjcR9s2j3eeDphmm4qGwDAjFXLQi7U8XABY/w4iom2iq+2c1cj7lMPe J6DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Bjt9Vo3Vu1bLcU1qFygcp8qvNnttSpZRYaveRU0JgNI=; b=GiOAFokEXemmpc7AJxHEn7juD4ZB9WGHfZLhADfR78E6VC4CKrzz8S9MTJS7vJvfjt NrojXlYNZ6QiwhdJWuassXwk8JtcAXwZ+UEydom1EFhYG2yNq1ABmkBV9ekGqWLfe5GM xZ4IQnHu0SJMMx5yoNxNhv1d/mUJpdfYwqkZB+mTd2QwPcRBDZuZ5Wgz5r2qpLhdE2Y7 v8Gmi3c0g5y1FDLW/XoqpXjBmbTKahwWoIS6O36VBmIhzxSDHJAPinVFujpiMMLnTJ9D aKkI9ELFbxiUnJaHn+4QgHy1aju66R+6EpQ9YGT7QYBCUhFkQ4IQoLf9Aop1HqIct7oU w3zw== X-Gm-Message-State: AJIora9JVGGsuUruHC3F/hMo/uBDdCTvlRk7SnBmnzXhOMSvbZtWm9oc 9iHcY/e+DXhYhumlJPFl9yuIM4JG09mnBJNwT9CnfA== X-Google-Smtp-Source: AGRyM1sbDOyqUZm7mCNO1atP10bA9bQIG8/oKhPuvpx46qKb4U/kV/W1SW3hVGlIZVtpKclhbAKR2i6dsThuAhCjZno= X-Received: by 2002:a17:906:749b:b0:722:d9ce:fac3 with SMTP id e27-20020a170906749b00b00722d9cefac3mr20391985ejl.699.1656799556263; Sat, 02 Jul 2022 15:05:56 -0700 (PDT) MIME-Version: 1.0 References: <3accd9cb-aede-41ce-96e6-f3e175392b9d@www.fastmail.com> <8d72c021-e5db-469d-b5ec-886248c26e46@www.fastmail.com> <5f14e266-e12c-474b-9366-48ed035de392@www.fastmail.com> In-Reply-To: <5f14e266-e12c-474b-9366-48ed035de392@www.fastmail.com> From: Bart Schaefer Date: Sat, 2 Jul 2022 15:05:44 -0700 Message-ID: Subject: Re: Bug: 'export FOO' not idempotent To: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= Cc: Roman Perepelitsa , Michael Smith , Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 50396 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Mon, Jun 27, 2022 at 3:39 PM Lawrence Vel=C3=A1zquez wr= ote: > > On Mon, Jun 27, 2022, at 5:58 PM, Roman Perepelitsa wrote: > > The problem is that `export FOO` doesn't export anything. You're seeing the intersection of two historic behaviors. "export FOO" doesn't export anything because it's not possible to have an environment string that has no value (more on this below). "typeset -p" outputs a statement containing an assignment with an empty string because FOO is not unset ($+FOO is 1) and there's no other way to represent that in a typeset command. Historically, it would have output typeset -gx FOO=3D'' instead of export FOO=3D'' but that was changed at https://www.zsh.org/workers/39704 after a discussion similar to this discussion. In 39704: >>>There has previously been discussion of the fact that zsh differs in >>>this regard -- namely, that declaring a variable implies that it has >>>become set, and you must thereafter explicitly unset it -- but zsh >>>also handles environment variables differently, in that the value is >>>not actually exported until it is explicitly assigned, even though >>>the variable appears to be set. Incidentally, also refer https://www.zsh.org/workers/39758 and thread. > > Moreover, the subsequent `typeset -p FOO` says that FOO *is* exported. The actual *envp C-string can't contain "...:FOO:..." (each colon-separated element must have an equal sign). So in your example here -- > > % typeset -p FOO > > typeset: no such variable: FOO > > % export FOO > > % typeset -p FOO > > export FOO=3D'' > > % env | grep FOO > > FOO -- what might actually be printed at the last step is FOO=3D > I agree that that would make more sense. The current behavior is > rather odd. Possibly, but it's that way because "not actually exported until explicitly assigned", which if I try to reconstruct past decisions was probably an attempt to make the environment behave as if (the now new option) TYPESET_TO_UNSET was in effect even though the shell internally did not do so.