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=-0.8 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 C1EE425EA0 for ; Sat, 6 Jul 2024 03:49:46 +0200 (CEST) Received: from pb-smtp2.pobox.com ([64.147.108.71]) by 9front; Fri Jul 5 21:48:15 -0400 2024 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 5846D2D5D1 for <9front@9front.org>; Fri, 5 Jul 2024 21:48:14 -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=K48oNZx5EeY2UbDZ9pdsB9HLC GakoZvXm8ddqnXqGf4=; b=aI/C+jsFNgAdN+iIsLGMMFZHd97joP7gKK4ylPQdh HUr1e6eRrueFDhMTQdElk1bw9pxMaLbnSyR2P/ZkA2SGtfSY+SFRMfH2AGsaXkD0 N3La5BhtLxqkC9nlwlR5x0UHOp7O++deY5rAMzSph8Q+NR0Cjjm+StWccbhaxYW8 Lw= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 509832D5D0 for <9front@9front.org>; Fri, 5 Jul 2024 21:48:14 -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 935332D5CF for <9front@9front.org>; Fri, 5 Jul 2024 21:48:13 -0400 (EDT) (envelope-from me+unobe@fallglow.com) Message-ID: <0FA3013289FC138D02F16A45F7F68FDA@smtp.pobox.com> Date: Fri, 05 Jul 2024 18:48:11 -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: CE99EF6A-3B39-11EF-A3E0-965B910A682E-09620299!pb-smtp2.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: flexible encrypted method scripting-oriented JSON over SVG singleton deep-learning interface Subject: Re: [9front] Re: /bin/"" use of rc -c instead of eval Reply-To: 9front@9front.org Precedence: bulk On Fri Jul 5 16:52:25 -0700 2024, ality@pbrane.org wrote: > Romano once said: > > I use " and "" to review previous commands and execute them, and > > I was puzzled when a previous 'cd' command didn't work. I > > suspected it might be perhaps to 'cd' being a built-in, and > > looking at the source code for "" my suspicion was confirmed. The > > last line that executes the command is: rc -c $"_x > > > > Any reason why this isn't using eval instead so that rc built-ins > > work (eval $"_x) > > Did you try it? What happened? > > Hint: what you seem to want is not > > "" cd.*foo > > but > . <{" cd.*foo} > Thanks, Anthony, even eval won't work for what I want. I had lazily just tested: rc -c 'cd /sys/src' against: eval 'cd /sys/src' The above eval works if run directly, but not when within a shell script like "", so I'd have to think of some other way. One way that looks promising is defining "" as a function with the source of "" and changing 'rc -c' to 'eval': cpu% whatis "" fn "" { PROMPT='[^ ]*(%|;)+[ ]+' _x=`{ " $*|tail -1 } if(~ $#_x 0){ >[1=2]echo no such command found exit notfound } >[1=2]echo ' ' $_x _x=`{ echo -n 'eval '''; echo $_x|sed 's/^'^$PROMPT^'//; s/''/''''/g; s/$/''/' } eval $"_x } cpu% pwd / cpu% "" cd /sys cpu% cd /sys/src cpu% pwd /sys/src cpu%