mirror of https://github.com/xfarrow/dircomp.git
Fixed unintended behaviour
This commit is contained in:
parent
4188059e4e
commit
183982a8cc
|
@ -1,2 +1 @@
|
|||
#! /bin/bash
|
||||
gcc -o3 dircomp.c -lssl -lcrypto -o dircomp
|
17
dircomp.c
17
dircomp.c
|
@ -13,11 +13,6 @@
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct arguments arguments = get_arguments(argc, argv);
|
||||
if (arguments.h == true)
|
||||
{
|
||||
print_help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* directory_to_analyze1 = malloc(strlen(arguments.directory1) * sizeof(char) + 1);
|
||||
char* directory_to_analyze2 = malloc(strlen(arguments.directory2) * sizeof(char) + 1);
|
||||
|
@ -25,8 +20,6 @@ int main(int argc, char *argv[])
|
|||
strcpy(directory_to_analyze2, arguments.directory2);
|
||||
free(arguments.directory1);
|
||||
free(arguments.directory2);
|
||||
arguments.directory1 = NULL;
|
||||
arguments.directory2 = NULL;
|
||||
|
||||
if (analyze_directories(directory_to_analyze1, directory_to_analyze2, &arguments))
|
||||
{
|
||||
|
@ -44,10 +37,7 @@ int main(int argc, char *argv[])
|
|||
struct arguments get_arguments(int argc, char **argv)
|
||||
{
|
||||
struct arguments provided_arguments = {"", "", false, false, false, false, false};
|
||||
if(argc == 1){
|
||||
provided_arguments.h = true;
|
||||
return provided_arguments;
|
||||
}
|
||||
|
||||
char option;
|
||||
while ((option = getopt(argc, argv, "rvhfd")) != -1)
|
||||
{
|
||||
|
@ -71,6 +61,11 @@ struct arguments get_arguments(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if(provided_arguments.h || argc == 1){
|
||||
print_help();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Get directories
|
||||
if ((argc - optind) < 2)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue