From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id ca47b64b for ; Sat, 19 Oct 2019 09:49:22 +0000 (UTC) Received: (qmail 29542 invoked by alias); 19 Oct 2019 09:49:14 -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: List-Unsubscribe: X-Seq: 44854 Received: (qmail 5415 invoked by uid 1010); 19 Oct 2019 09:49:14 -0000 X-Qmail-Scanner-Diagnostics: from mail-vk1-f195.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25601. spamassassin: 3.4.2. Clear:RC:0(209.85.221.195):SA:0(-2.0/5.0):. Processed in 2.844392 secs); 19 Oct 2019 09:49:14 -0000 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.221.195 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=VYtmN4eqFyCky9RnqfmhynIw57pk6I44TZ8N/5+9Tsc=; b=MowI+aEwxevOcZ6y2wANSLZkh6Og2OGC/IbnUX91448MFtlSqQF81wu2dsrbROvVum W2lDM3chbhSz+vywzRXMNQCBebC5mb8kRhAQesgoUTmIVwiMxhiurdWoencrFlGjbpD8 paoVZJr5Cm2avcmLPfOqdRa8pLLEi4y5w1BtBKlXpGPceC01fkuxw2dXJF4DkYLlPs+x BL0fgTdu2r67+sNlkw/M42xMn9VVQIKerrNFjCg+Lo3q/esVau7ItLYThM6v0oTdKUxA 2nchVY2tNdwyJ7oeFEIm2DGHc3blZQrDdQ/8gcD0LcpnFWW/mKQ246Fab3057D4PgzXl K/CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=VYtmN4eqFyCky9RnqfmhynIw57pk6I44TZ8N/5+9Tsc=; b=HK4R7fHLZZXxpIXrJcARp/xuSOnue4SZVRPIrrio9pal7P0dLRL+r2cWJ8e3Yen1J2 vfvmAe0vUgwBYJ2TqKFpVAKzQctQbsU5wTW5O09sXYl1J5mIZlfpR1rHFldnuSyNKvpl IzX9ykPiJYn8UxkqUVfn9ESdRQTWNzk8Wrv/LVP85MIG40+7kNj+W8bohudEy0bTT08n wyrOhiHV5kpp6zFFZpOpmr7C2mJDSzAU31kYUmuPaOFKandWITMWsqxQzZA97sp+Nkgn kk9UPoI1jrF3oNzI7JokD4xh5egopr/BjoC6tkhd0zx/VwU2O1v755o7+ethacCZGyrG qOOQ== X-Gm-Message-State: APjAAAX17q+nl9UpqYgP0OHssa0/T0aUSyYWE2tl+8TNeHVp0oe1hBwk Q5aJHhuwbX6RMC6qd1wBY1KkIXE4guE3sdX/dCiVIw== X-Google-Smtp-Source: APXvYqzRFgdBF3ZMecjDEFBX6tyLOB44zX7VNCCt1b6aFE57h3qxqhOxsbdadx8OJEoI18UJXdiT8OQdJ8mjP6hiBvM= X-Received: by 2002:a1f:8d4c:: with SMTP id p73mr7715578vkd.77.1571478517757; Sat, 19 Oct 2019 02:48:37 -0700 (PDT) MIME-Version: 1.0 References: <8724321571463531@myt3-a2a42ac8caa6.qloud-c.yandex.net> In-Reply-To: <8724321571463531@myt3-a2a42ac8caa6.qloud-c.yandex.net> From: Sebastian Gniazdowski Date: Sat, 19 Oct 2019 11:48:28 +0200 Message-ID: Subject: Re: broken random variable To: ". ." Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 19 Oct 2019 at 07:39, . . wrote: > > Hello, zsh-workers > > I found a bug in the $RANDOM variable; on OpenBSD, the command "echo $RAN= DOM | tee" will print the same number > across different executions of the same command, and the value of "echo $= RANDOM" will be the same as the last value. That's because Zsh is different from other shells in one regard: for the pi= pe: A | B it runs A in a subshell and B in the current shell, while other shells like Bash run A in the current shell and B in the subshell. This is a very nice feature, as it allows to do: cat /some/file | while read line; do some_var=3D=E2=80=A6; done print $some_var and the side-effects of this pipe will survive to the `print'. So, the `echo $RANDOM | tee` will print the same value because the $RANDOM will be read in a subshell, meaning that a fork() will be done and the random-seed will be left unchanged in the outer process. --=20 Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org