poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature request: open file before running poke script


From: David Faust
Subject: Re: Feature request: open file before running poke script
Date: Sat, 6 Feb 2021 11:36:17 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

Hi Mohammad-Reza,

On 2/5/21 10:02 PM, Mohammad-Reza Nabipoor wrote:
> Hi, David.
> 
> On Fri, Feb 05, 2021 at 12:16:33PM -0800, David Faust wrote:
>>
>> As a motivating use case, I currently have a small poke script which
>> collects BTF information in a file, and displays portions of it. But
>> right now, I need to hardcode the filename (foo.o) into the script.
>> Otherwise, the following happens:
>>
>>   $ poke -s myscript foo.o
>>   unhandled no IOS exception
>>   $ poke foo.o --script=myscript
>>   unhandled no IOS exception
>>
>> With this improvement, it would be much easier to rapidly check multiple
>> test cases:
>>
>>   $ poke -s myscript foo.o
>>   (dump of relevant information in foo.o)
>>   $ poke -s myscript bar.o
>>   (dump of relevant information in bar.o)
>>   ...
>>
>> Or maybe there is an existing way to do this, in which case the
>> documentation around poke script usage could perhaps be improved?
>>
> 
> 
> You can use `-L` option (Section 1.4.5 of info documentation ("Scripts")).
> Poke will send the list of command line arguments as an array of strings
> called `argv`.
> 
> An example script (called `util-script.pk`):
> 
> ```poke
> #!/usr/bin/poke -L
> !#
> 
> for (arg in argv)
>   printf ("Argument: %s\n", arg);
> ```
> 
> You can run this script either by
> 
>     $ poke -L util-script.pk A B C
> 
> or,
> 
>     $ ./util-script.pk A B C
> 
> 
> An example of such utility script is `utils/pk-elfextractor.in` file in
> poke repo.

Aha, ok I see. You are right, -L is what I need.

I was not understanding properly the difference between poke commands or
command files, and Poke sources (and accordingly the -s and -l options).

Thanks a lot for your help :)

> 
> 
> And if you need option/argument handling you can use the `argp` pickle 
> (Section
> 9.1 of documentation ("argp")).
> 
> 
> BTW patches are welcome :)
> 
> 
> Regards,
> Mohammad-Reza
> 

Best,
David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]