Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cat: exit(1) for bad arguments #223

Merged
merged 1 commit into from
Aug 26, 2023
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Aug 24, 2023

  • Previously on my system directory arguments would silently be ignored instead of flagging an error
  • Make $options more pretty
  • Declare $Program and exit code constants as done in other scripts
  • Explicitly check for directory before open() as done in other scripts
  • Error exit if one or more files cannot be opened, or is a directory
  • Lone '-' argument is still handled for stdin
  • The <> loop over all input files becomes explicit do_file() call per argument
  • case1: perl cat F1 . will print F1, warn about directory '.' then exit(1)
  • case2: perl cat F1 F2 will warn about F1 not existing, proceed to print F2 then exit(1)

* make $options more pretty
* declare $Program and exit code constants as done in other scripts
* explicitly check for directory before open() as done in other scripts
* error exit if one or more files cannot be opened (and for directory arguments)
* lone '-' argument is still handled for stdin
* restructure single <> loop over all arguments; now explicit do_file() per argument
* case1: `perl cat F1 .` will print F1, warn about directory '.' then exit(1)
* case2: `perl cat F1 F2` will warn about F1 not existing, proceed to print F2 then exit(1)
@briandfoy briandfoy self-assigned this Aug 26, 2023
@briandfoy briandfoy added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: cat The cat program labels Aug 26, 2023
@briandfoy
Copy link
Owner

Very nice. Thanks,

@briandfoy briandfoy merged commit 691d82e into briandfoy:master Aug 26, 2023
1 check passed
@briandfoy briandfoy added Status: accepted The fix is accepted Status: released there is a new release with this fix and removed Priority: low get to this whenever Status: accepted The fix is accepted labels Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: cat The cat program Status: released there is a new release with this fix Type: enhancement improve a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants