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

diff: validation for -U and -C #308

Merged
merged 1 commit into from
Nov 2, 2023
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Nov 2, 2023

  • The -U option accepts the number -1 but perl dies

perl diff -U -1 A B
--- A Sat Oct 28 11:49:12 2023
+++ B Sat Oct 28 11:49:24 2023
@@ -3104,-1 +3104,-1 @@
Modification of non-creatable array value attempted, subscript -1 at diff line 383.

  • For -U 0, output matches GNU diff on my Linux system (OpenBSD diff also accepts -U 0)
  • "-U hello" is interpreted as -U 0 but this should be an error
  • Looking at the option parser, -C and -U have the same problem
  • Standards document doesn't mention -U, but has wording about -C value being a positive integer[1]
  • Follow OpenBSD diff and allow -U 0, but raise error for negative values (same treatment for -C)
  1. https://pubs.opengroup.org/onlinepubs/009604499/utilities/diff.html

* The -U option accepts the number -1 but perl dies

perl diff -U -1  A B 
--- A	Sat Oct 28 11:49:12 2023
+++ B	Sat Oct 28 11:49:24 2023
@@ -3104,-1 +3104,-1 @@
Modification of non-creatable array value attempted, subscript -1 at diff line 383.

* For -U 0, output matches GNU diff on my Linux system
* OpenBSD diff command also accepts -U 0
* "-U hello" is interpreted as -U 0 but this should be an error
* Looking at the option parser, -C and -U have the same problem
* Standards document doesn't mention -U, but has wording about -C value being a positive integer[1]
* Follow OpenBSD diff and allow -U 0, but raise error for negative values (same treatment for -C)

1. https://pubs.opengroup.org/onlinepubs/009604499/utilities/diff.html
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: diff The diff program labels Nov 2, 2023
@briandfoy briandfoy self-assigned this Nov 2, 2023
@briandfoy briandfoy merged commit 17f109a into briandfoy:master Nov 2, 2023
2 checks passed
@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Nov 9, 2023
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: diff The diff 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.

2 participants