9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] sam and 'here documents' on Unix [WAS: Re: Making multiple changes to dot using sam -d]
@ 2022-05-12 17:47 Mart Zirnask
  2022-05-12 19:24 ` umbraticus
  0 siblings, 1 reply; 3+ messages in thread
From: Mart Zirnask @ 2022-05-12 17:47 UTC (permalink / raw)
  To: 9fans

A related question:
9front sam has the ^ command, which makes it easy to apply multiple
sam commands to the dot from a script, e.g:

#!/bin/rc
cat << END
,x/red/ c/blue/
,x/yellow/ c/green/
END

How does one accomplish this in oldschool Unix sam -d without the ^
command, and also without using ssam?

'Here dcuments' work, because the following works fine on my shell
(Busybox sh, not rc):

$ sam -d file.txt << END
,x/red/ c/blue/
,x/yellow/ c/green/
w
q
END

However, piping dot to that script from within sam -d (using the |
command) ends up with:
sh: script.sh: not found
?warning: exit status not 0

...and also an empty (deleted) sam buffer.

Replacing 'cat' with other options, e.g. 'sam -d "$*"', eventually
gave a "broken pipe" message. And, again, in all cases, an empty
buffer.

So, no ^ command, no ssam, but want to use substitutions from 'here
documents' -- where am I going wrong?
Many thanks,
Mart

On 11/05/2022, revcomninos@gmail.com <revcomninos@gmail.com> wrote:
> Thank you! I was erring in that I failed to repeat x.

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tcf06324837558cea-M5ef5eba93c3c87f8333b2b8e
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] sam and 'here documents' on Unix [WAS: Re: Making multiple changes to dot using sam -d]
  2022-05-12 17:47 [9fans] sam and 'here documents' on Unix [WAS: Re: Making multiple changes to dot using sam -d] Mart Zirnask
@ 2022-05-12 19:24 ` umbraticus
  2022-05-17  5:54   ` Mart Zirnask
  0 siblings, 1 reply; 3+ messages in thread
From: umbraticus @ 2022-05-12 19:24 UTC (permalink / raw)
  To: 9fans

hmm, interesting. ^ is indeed very useful;
making it work in sam -d is probably the
correct thing to do but here's a quick hack.
(9front specific, tho you can probably figure
out another way to pretend you typed.)

umbraticus

; fn f{echo ,x/red/c/blue >/dev/kbdin}
; sam -d
 -. 
a
I hired a red
redemptionist
.
!f
,x/red/c/blue
,
I hiblue a blue
blueemptionist

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tcf06324837558cea-M37afd51dab499eefb093aa10
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] sam and 'here documents' on Unix [WAS: Re: Making multiple changes to dot using sam -d]
  2022-05-12 19:24 ` umbraticus
@ 2022-05-17  5:54   ` Mart Zirnask
  0 siblings, 0 replies; 3+ messages in thread
From: Mart Zirnask @ 2022-05-17  5:54 UTC (permalink / raw)
  To: 9fans

Sorry for the late reply -- great hint, thanks very much.

In a perfect world, I would need a solution that also works on Windows
(with the ported unix/p9 tools), but I'll probably build the
sam9f-unix port by iru- [1] for now.

Btw, can anybody point me to the initial ^ and/or _ command patch?
In which 9front release were they added?

1: https://github.com/iru-/sam9f-unix

Thanks and best,
Mart

On 12/05/2022, umbraticus@prosimetrum.com <umbraticus@prosimetrum.com> wrote:
> hmm, interesting. ^ is indeed very useful;
> making it work in sam -d is probably the
> correct thing to do but here's a quick hack.
> (9front specific, tho you can probably figure
> out another way to pretend you typed.)
> 
> umbraticus
> 
> ; fn f{echo ,x/red/c/blue >/dev/kbdin}
> ; sam -d
>  -.
> a
> I hired a red
> redemptionist
> .
> !f
> ,x/red/c/blue
> ,
> I hiblue a blue
> blueemptionist

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tcf06324837558cea-M8814cbe0749f46c6bd3477d8
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-17  5:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 17:47 [9fans] sam and 'here documents' on Unix [WAS: Re: Making multiple changes to dot using sam -d] Mart Zirnask
2022-05-12 19:24 ` umbraticus
2022-05-17  5:54   ` Mart Zirnask

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).