9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] Problem with rc script
@ 2000-07-25 14:41 tad
  0 siblings, 0 replies; 4+ messages in thread
From: tad @ 2000-07-25 14:41 UTC (permalink / raw)
  To: 9fans

> I want to see the line count in $wco(1), word count in $wco(2), etc., and 4
> for $#wco.
	% wco=`{wc wmsetup}
	% echo $wco
	26 53 887 wmsetup
	% echo $wco(1)
	26
	% echo $wco(2)
	53
	% echo $wco(3)
	887
	% echo $wco(4)
	wmsetup
	% echo $#wco
	4
	% 

> This script extracts the size from /dev/vgactl and places it in an array.
> (Using a cat, grep and sed pipe.) I want v_size to contain (width height
> depth)

	% v_size=`{cat '#v/vgactl' | grep '^size' | awk '{print $2}' | sed 's/x/ /g'}
	% echo $v_size
	1600 1200 8
	% echo $v_size(1)
	1600
	% echo $v_size(2)
	1200
	% echo $v_size(3)
	8
	%
 
> BTW, what is an equivalent to od(1), with or without unicode interpretation.

	xd(1)

-Tad


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

* Re: [9fans] Problem with rc script
  2000-07-25 12:56 rob pike
@ 2000-07-26  8:42 ` Doug Henderson
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Henderson @ 2000-07-26  8:42 UTC (permalink / raw)
  To: 9fans

Thanks, Rob. My script was actually working right, except that $ifs was
getting trashed.

The wloc script is broken. It changes $ifs, but does not reset it.
Subsequently, your example fails, too.

wloc needs to correctly save $ifs in $oifs and restore it, or it needs an
"rfork e" so its $ifs is private.

"rob pike" <rob@plan9.bell-labs.com> wrote in message
news:200007251256.IAA22425@cse.psu.edu...
<snip>
> % x= 'a b c'
> % echo $#x
> 1
> % x = `{eval echo $x}
> % echo $#x
> 3
> %


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

* Re: [9fans] Problem with rc script
@ 2000-07-25 12:56 rob pike
  2000-07-26  8:42 ` Doug Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: rob pike @ 2000-07-25 12:56 UTC (permalink / raw)
  To: 9fans

The replacement for od is xd.

As for the rc problem, I can't reproduce it, but try this:

% x= 'a b c'
% echo $#x
1
% x = `{eval echo $x}
% echo $#x
3
% 


-rob



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

* [9fans] Problem with rc script
@ 2000-07-25  8:42 Doug Henderson
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Henderson @ 2000-07-25  8:42 UTC (permalink / raw)
  To: 9fans

I ran into some problems with rc and array variables.

I can create an array in a script using:
    ab=(a b)
and reference $ab(1) and $ab(2) to see 'a' and 'b'. When I look at /env/ab,
I see
    'a' '\000' 'b'
contrary to the doc which suggests that the elements of an array are
separated by '\001'.


So, I have been trying to create an array variable from program output: e.g.
    wco=`{wc foo}
or
    wco=(`{wc foo})
or
    something using eval, or playing with $ifs?
I want to see the line count in $wco(1), word count in $wco(2), etc., and 4
for $#wco.
How do I cause rc to parse the output of the command into an array? Is this
possible? Does it do this correctly? Can it get messed up by using ape/psh
or by a connection to telnetd running on a term?

To confuse the issue, sometimes the array seems to be created correctly.
Specifically, my riostart script calls another script (called wide_screen)
to create an initial window as wide as the display and filling all but the
top 100 pixels of the screen. The window is created with the correct size
and placement. Later, when I run the wide_screen script interactively, it
fails.
This script extracts the size from /dev/vgactl and places it in an array.
(Using a cat, grep and sed pipe.) I want v_size to contain (width height
depth). The vga size should extracted so that it looks like I entered
    v_size=(1024 768 8)
My reference to $v_size(1) returns '10247688'. $v_size(2) returns '' (an
empty string). The subsequent window command fails.

BTW, what is an equivalent to od(1), with or without unicode interpretation.

--
Doug Henderson, Calgary, Alberta, Canada


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

end of thread, other threads:[~2000-07-26  8:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-25 14:41 [9fans] Problem with rc script tad
  -- strict thread matches above, loose matches on Subject: below --
2000-07-25 12:56 rob pike
2000-07-26  8:42 ` Doug Henderson
2000-07-25  8:42 Doug Henderson

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