Skip to content

Commit

Permalink
Merge pull request #1003 from Cyan4973/noInput_msg
Browse files Browse the repository at this point in the history
more clearly identify error when there is no input
  • Loading branch information
Cyan4973 authored Jan 22, 2025
2 parents f5a0b6f + b1f76e5 commit 647951a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cli/xxhsum.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ static LineStatus XSUM_hashFile(const char* fileName,
}
inFile = XSUM_fopen( fileName, "rb" );
if (inFile==NULL) {
XSUM_log("Error: unable to open input\n");
return LineStatus_failedToOpen;
} }

Expand Down Expand Up @@ -1404,6 +1405,7 @@ static int XSUM_usage(const char* exename)
XSUM_log( " -c, --check read xxHash checksum from [files] and check them \n");
XSUM_log( " --files-from generate hashes for files listed in [files] \n");
XSUM_log( " --filelist generate hashes for files listed in [files] \n");
XSUM_log( " - forces stdin as input, even if it's the console \n");
XSUM_log( " -h, --help display a long help page about advanced options \n");
return 0;
}
Expand Down Expand Up @@ -1658,8 +1660,10 @@ XSUM_API int XSUM_main(int argc, const char* argv[])
}

/* Check if input is defined as console; trigger an error in this case */
if ( (filenamesStart==0) && XSUM_isConsole(stdin) && !explicitStdin)
return XSUM_badusage(exename);
if ( (filenamesStart==0) && XSUM_isConsole(stdin) && !explicitStdin) {
XSUM_log("No input provided \n");
return 1;
}

if (filenamesStart==0) filenamesStart = argc;

Expand Down

0 comments on commit 647951a

Please sign in to comment.