List Info

Thread: Re: Command built-in questions (was Re: Executing shell command, save results to variable)




Re: Command built-in questions (was Re: Executing shell command, save results to variable)
user name
2007-03-21 14:55:18
What are examples of when people would use 'words' ?

I can imagine many examples of using 'lines' since so many
commandline
tools are line-oriented, and as Sanel mentioned, you often
know on
what line the info you want exists, though not necessarily
what
particular word(s).

That said, I'm fairly ambivalent - the 'words' behavior
seems more
elegant and jam-esque.
Either one can be accomplished by setting environment
variables from a
wrapper script.

Too bad Jam doesn't have multidimensional arrays, then you
could have
an array of lines, each being an array of words...

-John



On 3/21/07, Sanel Zukan <sanelzgmail.com> wrote:
> > ok, I've tested it yesterday night on my build. It
seems that "popen" is
> > an issue in Win32 with at least Watcom C++ and
Digital Mars C++ which don't
> > I think we're going to need a proper Win32
implementation in the sources.
>
> AFAIK, it is been problem on Win32 for an ages, and no
one provided an good
> alternative for unix implementation. I didn't used it
on Win32 side and
> not sure what are pros/cons of current implementation,
but after quick
> search I found some alternative on qt list:
> http://lists.trolltech.com/qt-interest/1999-09/
thread00282-0.html
>
> I am not able to decipher german comments, but hoping
this can be good
> starting point.
>
> > - is there some serious use to the
"mixed" and "lines" cases ? we really
don't want
> >   to turn Jamfiles into parsing programs, don't
we.
>
> For "lines" (thought): for example we know
that program outputs our
> interested data on second or third line (gcc -v for
example). But this
> is probably better to be handled via external script,
keeping jam source
> simple.
>
> > - which default behaviour would you prefer ? (I'm
for "words", but YMMV)
>
> I am for "words" too (and only
"words" ).
>
> --
> Sanel
> _______________________________________________
> jamming mailing list  -  jammingperforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming
>
_______________________________________________
jamming mailing list  -  jammingperforce.com
http://maillist.perforce.com/mailman/listinfo/jamming

Re: Command built-in questions (was Re: Executing shellcommand, save results to variable)
country flaguser name
United States
2007-03-21 15:20:09
True, but from that point, my argument would be that 'lines'
should be the 
default behavior. It's trivial to parse a given line (from
an array of 
lines) into the words using the Match rule.

It's VERY difficult to take an array of words (that might
have been multiple 
lines), and split them into sub-lists that are the original
lines.

-Brian

----- Original Message ----- 
From: "John Waugh" <john.waughgmail.com>
To: "Sanel Zukan" <sanelzgmail.com>
Cc: <jammingperforce.com>
Sent: Wednesday, March 21, 2007 3:55 PM
Subject: Re: [jamming] Command built-in questions (was Re:
Executing 
shellcommand, save results to variable)


> What are examples of when people would use 'words' ?
>
> I can imagine many examples of using 'lines' since so
many commandline
> tools are line-oriented, and as Sanel mentioned, you
often know on
> what line the info you want exists, though not
necessarily what
> particular word(s).
>
> That said, I'm fairly ambivalent - the 'words' behavior
seems more
> elegant and jam-esque.
> Either one can be accomplished by setting environment
variables from a
> wrapper script.
>
> Too bad Jam doesn't have multidimensional arrays, then
you could have
> an array of lines, each being an array of words...
>
> -John
>
>
>
> On 3/21/07, Sanel Zukan <sanelzgmail.com> wrote:
>> > ok, I've tested it yesterday night on my
build. It seems that "popen" 
>> > is
>> > an issue in Win32 with at least Watcom C++ and
Digital Mars C++ which 
>> > don't
>> > I think we're going to need a proper Win32
implementation in the 
>> > sources.
>>
>> AFAIK, it is been problem on Win32 for an ages, and
no one provided an 
>> good
>> alternative for unix implementation. I didn't used
it on Win32 side and
>> not sure what are pros/cons of current
implementation, but after quick
>> search I found some alternative on qt list:
>> http://lists.trolltech.com/qt-interest/1999-09/
thread00282-0.html
>>
>> I am not able to decipher german comments, but
hoping this can be good
>> starting point.
>>
>> > - is there some serious use to the
"mixed" and "lines" cases ? we 
>> > really don't want
>> >   to turn Jamfiles into parsing programs,
don't we.
>>
>> For "lines" (thought): for example we
know that program outputs our
>> interested data on second or third line (gcc -v for
example). But this
>> is probably better to be handled via external
script, keeping jam source
>> simple.
>>
>> > - which default behaviour would you prefer ?
(I'm for "words", but 
>> > YMMV)
>>
>> I am for "words" too (and only
"words" ).
>>
>> --
>> Sanel
>> _______________________________________________
>> jamming mailing list  -  jammingperforce.com
>> http://maillist.perforce.com/mailman/listinfo/jamming
>>
> _______________________________________________
> jamming mailing list  -  jammingperforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming
>
> 
_______________________________________________
jamming mailing list  -  jammingperforce.com
http://maillist.perforce.com/mailman/listinfo/jamming

Re: Command built-in questions (was Re: Executing shell command, save results to variable)
user name
2007-03-21 15:40:51
If I recall correctly (this was about a year ago, and rather rushed, so my memory of it is a bit hazy), in the first implementation (which was different from what it is now), ; I needed to 'echo -n $?' in order to get "if $(rc) = 0" to test true (now I can just 'echo $?'). So I think I left in what you're calling the "words" behaviour to accommodate the fact that I still had those echo -n's in my rules and needed them to still work, because I couldn';t update my rules until everyone had the new executable, and everyone having the new executable wasn't guaranteed to happen all at once. I don't need (or have) the echo -n's anymore. Personally, I'd go with "lines", since you can always Strtok each line if you want to break it down into words, but you couldn';t put each line back together if it came in already broken down. (I assume everyone has a Strtok rule by now, or something like it... don't recall now where I got it - maybe it was posted on this list?)

Diane

On 3/21/07, John Waugh < john.waughgmail.com">john.waughgmail.com> wrote:
What are examples of when people would use 'words' ?

I can imagine many examples of using 'lines' since so many commandline
tools are line-oriented, and as Sanel mentioned, you often know on
what line the info you want exists, though not necessarily what
particular word(s).

That said, I'm fairly ambivalent - the 'words' behavior seems more
elegant and jam-esque.
Either one can be accomplished by setting environment variables from a
wrapper script.

Too bad Jam doesn't have multidimensional arrays, then you could have
an array of lines, each being an array of words...

-John



On 3/21/07, Sanel Zukan < sanelzgmail.com"> sanelzgmail.com> wrote:
>; > ok, I've tested it yesterday night on my build. It seems that "popen" is
> > an issue in Win32 with at least Watcom C++ and Digital Mars C++ which don't
> > I think we're going to need a proper Win32 implementation in the sources.
&gt;
> AFAIK, it is been problem on Win32 for an ages, and no one provided an good
> alternative for unix implementation. I didn't used it on Win32 side and
> not sure what are pros/cons of current implementation, but after quick
> search I found some alternative on qt list:
> http://lists.trolltech.com/qt-interest/1999-09/thread00282-0.html
>
&gt; I am not able to decipher german comments, but hoping this can be good
> starting point.
>;
> > - is there some serious use to the "mixed" and "lines" cases ? we really don't want
>; >   to turn Jamfiles into parsing programs, don't we.
>
&gt; For "lines" (thought): for example we know that program outputs our
> interested data on second or third line (gcc -v for example). But this
>; is probably better to be handled via external script, keeping jam source
>; simple.
&gt;
> > - which default behaviour would you prefer ? (I'm for "words", but YMMV)
>
> I am for "words" too (and only "words" ).
>
> --
> Sanel
> _______________________________________________
> jamming mailing list  -&nbsp;  jammingperforce.com">jammingperforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming
>
_______________________________________________
jamming mailing list  -&nbsp;  jammingperforce.com">jammingperforce.com
http://maillist.perforce.com/mailman/listinfo/jamming

Re: Command built-in questions (was Re: Executing shell command, save results to variable)
country flaguser name
United States
2007-03-21 15:46:52
John Waugh wrote:
> Too bad Jam doesn't have multidimensional arrays, then
you could have
> an array of lines, each being an array of words...

You can define funky variables to pretend you have 2d
arrays.  I do it
all the time.  I need psychological counseling.


foo_1 = whatever dude! ;
foo_2 = some stuff! ;

row = 2 ;
col = 2 ;
echo Hey! $(foo_$(row)[$(col)]) ;

rule function
{
  echo Hey again $($(1)_$(2)[$(3)]) ;
}

function foo : 1 : 2 ; # watch out, you can't say $(foo)

foo = foo ; #unless you do this hack

function $(foo) : 1 : 2 ;


Needless to say, your row ids don't have to be numbers, but
they can be.

 -Chuck
_______________________________________________
jamming mailing list  -  jammingperforce.com
http://maillist.perforce.com/mailman/listinfo/jamming

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )