On 05/10/2012 08:14 AM, Ashwini Sharma wrote: > Hi Rob, > > Is there any mechanism or framework in place to have multiple commands > implemented in same source file.
Unfortunately, no. I need to do redesign some of the common infrastructure to be more flexible about command names: http://lists.landley.net/pipermail/toybox-landley.net/2012-April/000410.html The OLDTOY() macro lets you have multiple names for the same command (ala nc and netcat, or sh and toysh), but they feed into the same main() function and if you wanted to determine which name you were called under you'd have to check toys.which->name. There's no infrastructure to have multiple command_main() functions in the same file, because the infrastructure that finds a toys/*.c file and hooks it up to menuconfig and the help command and the big array of available commands and the gcc command line and so on expects only one entry in each, and the same name for all of it. Making this more flexible is a todo item, but getting the automation right is somewhat non-obvious. I also want to autogenerate the FLAG_x macros for the optino parsing (which it's actually doing right now, but getting them available to each command under the right names involves macro magic I haven't figured out yet). > For example: > > we can have the implementation for *grep, egrep, fgrep* in one file > itself, as grep -E is equivalent to egrep and grep -F is fgrep. > Currently I do not see any such mechanism, where in I can make all the > binaries point to same place and then decide on what to run. OLDTOY() can do that. Look at netcat. But auto-adding the -F flag is awkward right now. It would be best if it could dispatch to different main() functions, and right now it can't. > Same will be applicable for *env* and *printenv* as printenv is similar > to the env default behaviour. > > Doing this will help reduce the effort and code size. > > Whats your opinion on this.? It's on the todo list already. I've just been swamped by real life recently and fallen a bit behind. (Between getting sick and moving to a new house I lost over a month.) > regards, > Ashwini Rob -- GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code. Either it's "mere aggregation", or a license violation. Pick one. _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
