This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Shell-style programming in Kawa
- From: Jamison Hope <jrh at theptrgroup dot com>
- To: "kawa at sourceware dot org list" <kawa at sourceware dot org>
- Date: Mon, 27 Jan 2014 13:20:46 -0500
- Subject: Re: Shell-style programming in Kawa
- Authentication-results: sourceware.org; auth=none
- References: <52C4B518 dot 5080000 at bothner dot com> <A72FB562-9459-4C69-B346-A6C94DBD22C4 at theptrgroup dot com> <52E3772D dot 50804 at bothner dot com> <4A37A2F8-76B0-421D-AFCB-62AA1EE78468 at theptrgroup dot com> <52E5995F dot 6000400 at bothner dot com> <52E67F60 dot 5090804 at bothner dot com>
On Jan 27, 2014, at 10:46 AM, Per Bothner <per@bothner.com> wrote:
> On 01/25/2014 11:46 PM, Jamison Hope wrote:
>> Is there a way to make this do what I intend?
>>
>> &`{ls &`{pwd}/..}
>
> This still doesn't work, but I checked in fixes so the
> following works:
>
> &`{ls &[&`{pwd}]/..}
> as does:
> &sh{ls &[&`{pwd}]/..}
>
> I'll fix the simpler version soon.
Great, thanks.
> On 01/26/2014 03:25 PM, Per Bothner wrote:
>
>> An alternative to to change the behavior of converting a Process
>> to a string to do the '\n'-stripping there instead. I.e. have:
>> (define str::string &`{echo foo bar})
>> bind "foo bar" to str. rather than "foo bar\n".
>>
>> The latter (change the string conversion) may be a more useful
>> behavior; I have to mull it some more. Reactions?
>
> I decided this wasn't a good idea, even though it is probably simpler.
> The biggest concern is that converting to bytevector and then to
> string gives a different result than converting directly to string,
> which seems dubious. Also, if we're stripping final newlines when
> converting to a string, this complicates pipes and other "streaming"
> contexts.
I was less sure about this, too. The nearest thing to DWIM behavior
that I could think of would be to strip the final newline if the output
was a single line (i.e. that was the only \n in the string), otherwise
to leave it intact. But that's probably still wrong half the time.
I agree that the string and bytevector representations should match.
--
Jamison Hope
The PTR Group
www.theptrgroup.com