From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <9front-bounces@9front.inri.net> X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from 9front.inri.net (9front.inri.net [168.235.81.73]) by inbox.vuxu.org (Postfix) with ESMTP id 7013829D38 for ; Thu, 11 Jul 2024 08:03:11 +0200 (CEST) Received: from pb-smtp2.pobox.com ([64.147.108.71]) by 9front; Thu Jul 11 02:02:22 -0400 2024 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id AC52439E93 for <9front@9front.org>; Thu, 11 Jul 2024 02:02:21 -0400 (EDT) (envelope-from me+unobe@fallglow.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=message-id :date:from:to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding; s=sasl; bh=MhIdhECUWpx2fwSgCiAf8+m83 kbsvdxD4yj0M0ulJuI=; b=SXdyouLkTNFVnRS1iKyOXpqn/LBEyurl/Yt7FVdIE bdSlQNn7vpBSh+8zxgL7rSj2421qPwz3Gx2kfOlcOyoFdl71osD5IO10qlgrBls/ X8rx8w1hR2BHDtj3qvr8H9oOOq/iFcob1EcYMagQMJwK62P4karqaseyYvsy0gOH VU= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id A53D339E92 for <9front@9front.org>; Thu, 11 Jul 2024 02:02:21 -0400 (EDT) (envelope-from me+unobe@fallglow.com) Received: from strider.localdomain (unknown [97.131.57.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id DBEBD39E91 for <9front@9front.org>; Thu, 11 Jul 2024 02:02:20 -0400 (EDT) (envelope-from me+unobe@fallglow.com) Message-ID: Date: Wed, 10 Jul 2024 23:02:19 -0700 From: Romano To: 9front@9front.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Pobox-Relay-ID: 22C66DD8-3F4B-11EF-BE1B-965B910A682E-09620299!pb-smtp2.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: webscale virtualized cloud-aware solution Subject: Re: [9front] Re: /bin/"" use of rc -c instead of eval Reply-To: 9front@9front.org Precedence: bulk On Sat Jul 6 07:11:12 -0700 2024, sirjofri+ml-9front@sirjofri.de wrote: > To add on that, I would vote for changing everything to make cd work. It's about consistency. > > The question is if it's better to have it in /bin/"" or as /env/fn#"". I think that /bin/"" makes more sense for various reasons. > > Also a good question would be: do we create an extra case for cd commands, or do we use eval? An extra case for cd commands would imply that the cd part of custom programs (including shell scripts) wouldn't work, so eval would be the most consistent, as OP suggested. I don't know about the downsides of eval though. I noticed there was a bigger issue with rc, and so sent the mailing list a suggested patch to address. With that in place, the below patch makes "" works for built-ins by defining itself as a function, which then updates the parent since it's called with a shared environment. From: Romano Date: Thu, 11 Jul 2024 05:56:24 +0000 Subject: [PATCH] make "" use a fn that will then work with built-ins currently "" does not work with built-ins, so re-running built-ins might not have the desired effect (e.g., setting environment variables, cd). This updates "" to be defined internally as a function, which then updates the parent environment after being called. --- diff 23b40c5aa93bb205423c8c40d02eef825011b215 7637f8f5fd6490d07ba64bcf404321028e698ed9 --- a/rc/bin/"" +++ b/rc/bin/"" @@ -1,5 +1,5 @@ -#!/bin/rc - +#!/bin/rc -b +fn "" { PROMPT='[^ ]*(%|;)+[ ]+' _x = `{" $* | tail -1} @@ -10,4 +10,6 @@ echo ' ' $_x >[1=2] _x=`{ echo -n 'eval '''; echo $_x | sed 's/^'$PROMPT'//; s/''/''''/g; s/$/''/'} -rc -c $"_x +eval $"_x +} +"" $*