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

cut: fix substring for -b flag #595

Merged
merged 1 commit into from
May 3, 2024
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented May 3, 2024

  • The substring length calculation in handle_b() wasn't correct in all cases
  • If start==end, then length==1
  • Pass parameters to handle_b() and handle_f()
  • Use defined() to test for presence of command options; 0 should not be ignored
  • test1: "perl cut -b 2-3 a.c" -> chars 2-3
  • test2: "perl cut -b -3 a.c" -> chars 1-3
  • test3: "perl cut -b 10 a.c" -> char 10
  • test4: "perl cut -f 1,2 -s -d ' ' a.c" -> fields 1&2, delimited by space, ignoring lines without a space

* The substring length calculation in handle_b() wasn't correct in all cases
* If start==end, then length==1
* Pass parameters to handle_b() and handle_f()
* Use defined() to test for presence of command options; 0 should not be ignored
* test1: "perl cut -b 2-3 a.c" -> chars 2-3
* test2: "perl cut -b -3 a.c" -> chars 1-3
* test3: "perl cut -b 10 a.c" -> char 10
* test4: "perl cut -f 1,2 -s  -d ' ' a.c" -> fields 1&2, delimited by space, ignoring lines without a space
@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 labels May 3, 2024
@briandfoy briandfoy self-assigned this May 3, 2024
@briandfoy briandfoy merged commit cdaeb1d into briandfoy:master May 3, 2024
2 checks passed
@briandfoy
Copy link
Owner

changes: ensure -b returns the right range of characters

@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels May 3, 2024
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.

None yet

2 participants