rc

[fork] interactive rc shell
git clone https://hhvn.uk/rc
git clone git://hhvn.uk/rc
Log | Files | Refs | README | LICENSE

addon.c (397B)


      1 /*
      2    This file is NOT BUILT by default.  Together with addon.h, it
      3    provides an example of how to add new builtins to rc.
      4 */
      5 
      6 #include "rc.h"
      7 #include "addon.h"
      8 
      9 void b_sum(char **av) {
     10 	long sum = 0;
     11 
     12 	while (*++av)
     13 		sum += atol(*av);
     14 	fprint(1, "%ld\n", sum);
     15 	set(TRUE);
     16 }
     17 
     18 void b_prod(char **av) {
     19 	long sum = 1;
     20 
     21 	while (*++av)
     22 		sum *= atol(*av);
     23 	fprint(1, "%ld\n", sum);
     24 	set(TRUE);
     25 }