Help output more Linux-standard

This commit is contained in:
Alessandro Ferro 2023-04-14 22:51:43 +02:00
parent 7836572fac
commit 6e5ff7cfc5
2 changed files with 7 additions and 3 deletions

View File

@ -1,2 +1,2 @@
#! /bin/bash #! /bin/bash
gcc dircomp.c -lssl -lcrypto -o dircomp gcc -o3 dircomp.c -lssl -lcrypto -o dircomp

View File

@ -36,6 +36,10 @@ int main(int argc, char *argv[])
struct arguments get_arguments(int argc, char **argv) struct arguments get_arguments(int argc, char **argv)
{ {
struct arguments provided_arguments = {"", "", false, false, false}; struct arguments provided_arguments = {"", "", false, false, false};
if(argc == 1){
provided_arguments.h = true;
return provided_arguments;
}
char option; char option;
while ((option = getopt(argc, argv, "rnsvh")) != -1) while ((option = getopt(argc, argv, "rnsvh")) != -1)
{ {
@ -253,8 +257,8 @@ unsigned char *get_sha1_file(char *filename)
void print_help(void) void print_help(void)
{ {
printf("Usage: dircomp directory1 directory2 [-r] [-v] [-h]\n\n"); printf("usage: dircomp directory1 directory2 [-r] [-v] [-h]\n");
printf(" -r \t\t Recursive\n"); printf(" -r \t\t Recursive\n");
printf(" -v \t\t Verbose\n"); printf(" -v \t\t Verbose\n");
printf(" -h \t\t Print this help and quit\n\n"); printf(" -h \t\t Print this help and quit\n");
} }