Skip to content

cut: use error exit-code if a file argument does not open - #1054

Merged
briandfoy merged 2 commits into
briandfoy:masterfrom
mknos:cut-open-exitcode
Sep 3, 2026
Merged

cut: use error exit-code if a file argument does not open#1054
briandfoy merged 2 commits into
briandfoy:masterfrom
mknos:cut-open-exitcode

Conversation

@mknos

@mknos mknos commented Sep 3, 2026

Copy link
Copy Markdown
Contributor
  • When testing cut today I discovered that it uses the idiomatic while(<>) loop for reading input in handle_b() and handle_f()
  • If file arguments are provided, all should process correctly in order for a success exit-code
  • Failure to open a file argument means process-next-file, not terminate-program
  • Hijack the WARN signal to set exit code; in future handle_b() and handle_f() could be restructured if necessary
  • If a directory is passed as an argument it is ignored; this is consistent with OpenIndiana & OpenBSD, but GNU cut raises a warning for it
  • For now, no attempt is made to suppress line numbers in the warning message

Test from "Git-Bash"...

$ perl -v | perl grep -F built
This is perl 5, version 42, subversion 2 (v5.42.2) built for x86_64-cygwin-thread-multi
$ echo 'y,a,y' > cheer
$ perl cut.pl -c1,2  nothing .. cheer
cut.pl: Can't open nothing: No such file or directory at cut.pl line 122.
y,
$ echo $?
1

* When testing cut today I discovered that it uses the idiomatic while(<>) loop for reading input in handle_b() and handle_f()
* If file arguments are provided, all should process correctly in order for a success exit-code
* Hijack the WARN signal to set exit code; in future handle_b() and handle_f() could be restructured if necessary
* If a directory is passed as an argument it is ignored; this is consistent with OpenIndiana & OpenBSD, but GNU cut raises a warning for it
@mknos
mknos deployed to housekeeping September 3, 2026 02:52 — with GitHub Actions Active
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 02:52 — with GitHub Actions Inactive
@github-actions github-actions Bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: cut The cut program Status: needs verification issue needs to be verified Type: bug an existing feature does not work labels Sep 3, 2026
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 3, 2026 10:01 — with GitHub Actions Inactive
@briandfoy briandfoy removed Type: bug an existing feature does not work Status: needs verification issue needs to be verified labels Sep 3, 2026
Comment thread bin/cut
@briandfoy
briandfoy merged commit 01c2bf9 into briandfoy:master Sep 3, 2026
21 of 22 checks passed
@briandfoy
briandfoy deployed to housekeeping September 3, 2026 17:12 — with GitHub Actions Active
@briandfoy

Copy link
Copy Markdown
Owner

changes: ensure the an error condition is set and reported in the exit code

@github-actions github-actions Bot added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Program: cut The cut program Status: accepted The fix is accepted Type: enhancement improve a feature that already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants