Skip to content

Commit

Permalink
Fixed error handling with bad commandline parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Shepperd committed Aug 15, 2023
1 parent 592e906 commit 5f64db4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ int main(int argc, char *argv[])
opts.head = strtol(optarg, &endp, 0);
if ( !endp || *endp || opts.head <= 0 )
{
fprintf(opts.ourStdErr, "Invalid --head option: %s" EOLSTR, optarg);
return helpEm(opts.ourStdErr);
fprintf(stderr, "Invalid --head option: %s" EOLSTR, optarg);
return helpEm(stderr);
}
break;
case OPT_TAIL:
Expand All @@ -439,8 +439,8 @@ int main(int argc, char *argv[])
opts.tail = strtol(optarg, &endp, 0);
if ( !endp || *endp || opts.tail <= 0 )
{
fprintf(opts.ourStdErr, "Invalid --tail option: %s" EOLSTR, optarg);
return helpEm(opts.ourStdErr);
fprintf(stderr, "Invalid --tail option: %s" EOLSTR, optarg);
return helpEm(stderr);
}
break;
case OPT_SKIP:
Expand All @@ -449,8 +449,8 @@ int main(int argc, char *argv[])
opts.skip = strtoll(optarg, &endp, 0);
if ( !endp || *endp || opts.skip < 0 )
{
fprintf(opts.ourStdErr, "Invalid --skip option: %s" EOLSTR, optarg);
return helpEm(opts.ourStdErr);
fprintf(stderr, "Invalid --skip option: %s" EOLSTR, optarg);
return helpEm(stderr);
}
break;
case OPT_WIDE:
Expand All @@ -465,7 +465,7 @@ int main(int argc, char *argv[])
break;
case '?':
default:
return helpEm(opts.ourStdErr);
return helpEm(stderr);
}
}
if ( stdOutName )
Expand Down

0 comments on commit 5f64db4

Please sign in to comment.