9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] $ifs equivalent in mk?
@ 2014-06-12 11:05 dexen deVries
  2014-06-12 11:27 ` erik quanstrom
  0 siblings, 1 reply; 7+ messages in thread
From: dexen deVries @ 2014-06-12 11:05 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

i have a mkfile which does:

alljs=`{find -name '*.js'}

my_target:Q: ... $alljs
    my_recipe;

and it breaks for files with spaces in pathname -- each space-separated token 
of pathname is treated as separate prerequisite.

in Rc, i could set $ifs to bare LF and be done with it. can equivalent be done 
in Mk?

-- 
dexen deVries

[[[↓][→]]]




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

* Re: [9fans] $ifs equivalent in mk?
  2014-06-12 11:05 [9fans] $ifs equivalent in mk? dexen deVries
@ 2014-06-12 11:27 ` erik quanstrom
  2014-06-12 11:39   ` dexen deVries
  0 siblings, 1 reply; 7+ messages in thread
From: erik quanstrom @ 2014-06-12 11:27 UTC (permalink / raw)
  To: 9fans

> i have a mkfile which does:
>
> alljs=`{find -name '*.js'}
>
> my_target:Q: ... $alljs
>     my_recipe;
>
> and it breaks for files with spaces in pathname -- each space-separated token
> of pathname is treated as separate prerequisite.

if you rc-quote the terms, it should work.

; find|grep b
'./a b'
; cat mkfile
x=`{find|grep b}

all:
	echo $x|wc
	for(i in $x)
		echo $i
; mk
echo ./a b|wc
for(i in ./a b)
	echo $i
      1       2       6
./a b



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

* Re: [9fans] $ifs equivalent in mk?
  2014-06-12 11:27 ` erik quanstrom
@ 2014-06-12 11:39   ` dexen deVries
  2014-06-12 11:41     ` erik quanstrom
  0 siblings, 1 reply; 7+ messages in thread
From: dexen deVries @ 2014-06-12 11:39 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Thursday 12 of June 2014 07:27:18 erik quanstrom wrote:
> > i have a mkfile which does:
> > 
> > alljs=`{find -name '*.js'}
> > 
> > my_target:Q: ... $alljs
> > 
> >     my_recipe;
> > 
> > and it breaks for files with spaces in pathname -- each space-separated
> > token of pathname is treated as separate prerequisite.
> 
> if you rc-quote the terms, it should work.
> 
> ; find|grep b
> './a b'
> ; cat mkfile
> x=`{find|grep b}
> 
> all:
> 	echo $x|wc
> 	for(i in $x)
> 		echo $i
> ; mk
> echo ./a b|wc
> for(i in ./a b)
> 	echo $i
>       1       2       6
> ./a b


here the var is processed by Rc inside recipe; in my case i need it processed 
by Mk inside prerequisite list


-- 
dexen deVries

[[[↓][→]]]




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

* Re: [9fans] $ifs equivalent in mk?
  2014-06-12 11:39   ` dexen deVries
@ 2014-06-12 11:41     ` erik quanstrom
  2014-06-12 11:57       ` dexen deVries
  0 siblings, 1 reply; 7+ messages in thread
From: erik quanstrom @ 2014-06-12 11:41 UTC (permalink / raw)
  To: 9fans

> here the var is processed by Rc inside recipe; in my case i need it processed
> by Mk inside prerequisite list

i was demoing a technique that you might use.  have you tried it?

- erik



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

* Re: [9fans] $ifs equivalent in mk?
  2014-06-12 11:41     ` erik quanstrom
@ 2014-06-12 11:57       ` dexen deVries
  2014-06-12 11:59         ` erik quanstrom
  0 siblings, 1 reply; 7+ messages in thread
From: dexen deVries @ 2014-06-12 11:57 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Thursday 12 of June 2014 07:41:51 erik quanstrom wrote:
> 
> i was demoing a technique that you might use.  have you tried it?
> 


thanks, tried and works.


used sed for quoting; end result is perl-ugly:

alljs=`{find -name '*.js' | 9 sed 's/''/''''/g; s/^|$/''/g' }
or
alljs=`{find -name '*.js' | 9 sed 's/^|$|''/&''/g' }


-- 
dexen deVries

[[[↓][→]]]




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

* Re: [9fans] $ifs equivalent in mk?
  2014-06-12 11:57       ` dexen deVries
@ 2014-06-12 11:59         ` erik quanstrom
  2014-06-12 12:06           ` dexen deVries
  0 siblings, 1 reply; 7+ messages in thread
From: erik quanstrom @ 2014-06-12 11:59 UTC (permalink / raw)
  To: 9fans

> thanks, tried and works.
>
>
> used sed for quoting; end result is perl-ugly:
>
> alljs=`{find -name '*.js' | 9 sed 's/''/''''/g; s/^|$/''/g' }
> or
> alljs=`{find -name '*.js' | 9 sed 's/^|$|''/&''/g' }

great.  glad that worked.  though it is always a bit sad
when one has to outwit one's tools.

as you may have noticed from the example, there are
some pitfalls (echo $x|wc got the wrong answer).

- erik



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

* Re: [9fans] $ifs equivalent in mk?
  2014-06-12 11:59         ` erik quanstrom
@ 2014-06-12 12:06           ` dexen deVries
  0 siblings, 0 replies; 7+ messages in thread
From: dexen deVries @ 2014-06-12 12:06 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Thursday 12 of June 2014 07:59:45 erik quanstrom wrote:
> 
> great.  glad that worked.  though it is always a bit sad
> when one has to outwit one's tools.
> 

still better than managing an anthill^W^W a pile of .xml `build specs'

-- 
dexen deVries

[[[↓][→]]]




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

end of thread, other threads:[~2014-06-12 12:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12 11:05 [9fans] $ifs equivalent in mk? dexen deVries
2014-06-12 11:27 ` erik quanstrom
2014-06-12 11:39   ` dexen deVries
2014-06-12 11:41     ` erik quanstrom
2014-06-12 11:57       ` dexen deVries
2014-06-12 11:59         ` erik quanstrom
2014-06-12 12:06           ` dexen deVries

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