From: Romano <me+unobe@fallglow.com>
To: 9front@9front.org
Subject: Re: [9front] Re: /bin/"" use of rc -c instead of eval
Date: Wed, 10 Jul 2024 23:02:19 -0700 [thread overview]
Message-ID: <BC0F019A63DF0DABDFE417A0E47199DC@smtp.pobox.com> (raw)
In-Reply-To: <c7e0dfee-ed51-4ba3-aa3b-cba2936b70e8@sirjofri.de>
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 <me+unobe@fallglow.com>
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
+}
+"" $*
prev parent reply other threads:[~2024-07-11 6:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-05 22:23 [9front] " Romano
2024-07-05 23:14 ` Stanley Lieber
2024-07-05 23:49 ` [9front] " Anthony Martin
2024-07-06 1:48 ` Romano
2024-07-06 8:00 ` sirjofri
2024-07-06 9:41 ` Romano
2024-07-06 14:05 ` sirjofri
2024-07-06 14:08 ` sirjofri
2024-07-11 6:02 ` Romano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BC0F019A63DF0DABDFE417A0E47199DC@smtp.pobox.com \
--to=me+unobe@fallglow.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).