diff options
author | 2005-09-20 23:26:39 +1000 | |
---|---|---|
committer | 2005-09-20 23:26:39 +1000 | |
commit | 149594f974350bb364a76c73b91b1d5ffddaa1fa (patch) | |
tree | 95650e9982d5fabe4bd805d94c5d700cbbc1ca7f /count.c |
Initial revision
darcs-hash:20050920132639-ac50b-fa3b476891e1f5f67207cf4cc7bf623834cc5edc.gz
Diffstat (limited to 'count.c')
-rw-r--r-- | count.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/count.c b/count.c new file mode 100644 index 00000000..f57b8048 --- /dev/null +++ b/count.c @@ -0,0 +1,22 @@ +/** \file count.c + The length command, used for determining the number of items in an + environment variable array. +*/ +#include <stdlib.h> +#include <stdio.h> + +/** + The main function. Does nothing but return the number of arguments. + + This command, unlike all other fish commands, does not feature a -h + or --help option. This is because we want to avoid errors on arrays + that have -h or --help as entries, which is very common when + parsing options, etc. For this reason, the main fish binary does a + check and prints help usage if -h or --help is explicitly given to + the command, but not if it is the contents of a variable. +*/ +int main( int argc, char **argv ) +{ + printf( "%d\n", argc-1 ); + return argc==1; +} |