instead of using variants printf, use write to save 7-14kb
... but write is painful to use, so try these defines:
Code: Select all
#include <string.h>
//warn - write string to stderr
#define warn(s) write(2, s, strlen(s));
//tell - write string to stdout
#define tell(s) write(1, s, strlen(s));
painful, unsafe or incomplete, so try this:
Code: Select all
#include <unistd.h>
//spawn executable with arguments & continue - where "a" is an array of cmd and args
#define spawn(a) ({int s,p;if((p=fork())==0){execvp(a[0],a);}})
//run and wait for executable with args - where "a" is an array of cmd and args
#define eggseck(a) ({int s;pid_t p; \
if((p = fork())==0){execvp(a[0],a);}else{while(wait(&s)!= p);}})
Code: Select all
//remove the first "i" parameters from array "a"
#define shift(i,a) ({ int j=0;while(a[j] != NULL){a[j]=a[j+i];j++;}})
Code: Select all
//compare 2 strings: 1st parameter ($1 in bash) and RESTART
if (strcmp(argv[1], "RESTART")==0) tell("\nRestarting.\n");
Code: Select all
//output a string from an env variable
tell("User's home is: ");
tell(getenv("HOME"));