[Toybox] long options support and yesno()

Rob Landley rob at landley.net
Fri Dec 7 09:26:01 PST 2012


On 12/04/2012 11:34:16 PM, Ashwini Sharma wrote:
> Hi Rob,
> 
>  As for the command options FLAG_xxx macros are auto generated. Is  
> the long
> options support in there and working?

It generates FLAG_ macros for the short options, but not yet for the  
long options.

This comes up if you have long options with no corresponding short  
options (which you can do by putting them at the start of the list).  
Right now, no macros get generated for that.

> Another usage issue I came across is in yesno() function.

I recently fiddled with yesno() for rm, and may wind up having to  
rewrite it entirely. The current one is... not right.

I blogged about this on the 4th (sorry I took so long to catch up on my  
email, still getting back in the habit of checking it regularly. :)

> In that you check for the tty fd. As '0' is also tty, you print the  
> prompt
> data onto 'stdin' which doesn't show up on screen.

Yup, I noticed that.

I think the new override behavior I added should probably become the  
default (read from stdin, write to stderr), and when I want to find the  
controlling tty even if some or all of stdin/stderr/stdout have been  
redirected I should just open /dev/tty.

> Putting "stdout' instead of fps[i] in fprintf shows the prompt. And  
> reading
> from fps[i] is fine.
> 
> what is your opinion on the same.

I added a flag to the "default" argument, which I'd make a proper macro  
for if I was sure about the design, but I'm not sure who all the users  
are yet. (For some things "yes | command" has to work, but others may  
need to prompt in the middle of a pipeline. Then again, the prompting  
_examples_ I can think of are asking for passwords, not y/n.) Right now  
I'm trying to finish up "rm" so I can get back to "cp" (which is  
currently the other yesno user) and work out what the right behavior is.

I should have this worked out by monday. Sorry for the delay. I'm  
trying to cut a new release so I can drop it into Aboriginal along with  
the 3.7 kernel, and then regression test everything.

Rob
 1354901161.0


More information about the Toybox mailing list