On 12/06/2026 09:37, Daniel Hofstetter wrote:
Hi,I noticed that pr interprets +0 as a file name and not as +FIRST_PAGE. And so a "no such file" error is shown whereas --pages=0 shows an "invalid page range" error. $ echo "foo" > foo $ pr +0 foo pr: +0: No such file or directory [snipped pr output of the "foo" file] $ pr --pages=0 foo pr: invalid page range ‘0’ I'm using coreutils 9.11.
+... could be a file name, so we treat +<invalid page> as a file since: https://github.com/coreutils/coreutils/commit/48eaa7382 --pages=0 is diagnosed directly as an invalid range as there can be no ambiguity there. So the inconsistency is due to a feature, allowing users to `pr +foo --option` for example. Adjusting this now could introduce some breakage, and I don't see much benefit to changing this. Oh this is probably coming from uutils partially supporting the fallback. It would be good to give that context when reporting bugs. I've pushed the attached test to the GNU test suite, to verify this handling. Marking this as done. thanks, Padraig
From a52fcef90382c51d97666ae9890cce1a4989ea6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]> Date: Fri, 12 Jun 2026 13:07:25 +0100 Subject: [PATCH] tests: pr: add checks for +... parameter handling * tests/pr/options.sh: Ad a new test. * tests/local.mk: Reference new test. Addresses https://bugs.gnu.org/81225 --- tests/local.mk | 1 + tests/pr/options.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 tests/pr/options.sh diff --git a/tests/local.mk b/tests/local.mk index 63a437318..6d572e679 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -290,6 +290,7 @@ all_tests = \ tests/mktemp/write-error.sh \ tests/misc/arch.sh \ tests/pr/bounded-memory.sh \ + tests/pr/options.sh \ tests/pr/pr-tests.pl \ tests/pwd/argument.sh \ tests/pwd/pwd-option.sh \ diff --git a/tests/pr/options.sh b/tests/pr/options.sh new file mode 100755 index 000000000..bbd1e8d72 --- /dev/null +++ b/tests/pr/options.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Test 'pr' option handling + +# Copyright (C) 2026 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ pr +getlimits_ + +# Ensure pr treats all invalid +page ranges as a file +for p in +0 +0foo; do + returns_ 1 pr "$p" 2>err </dev/null + printf '%s\n' "pr: $p: $ENOENT" >exp || framework_failure_ + compare exp err || fail=1 +done + +# number parsing issue +returns_ 1 pr --pages=-0 2>err </dev/null +printf '%s\n' "pr: invalid --pages argument '-0'" >exp +compare exp err || fail=1 + +# number validation issue +returns_ 1 pr --pages=0 2>err </dev/null +printf '%s\n' "pr: invalid page range '0'" >exp +compare exp err || fail=1 + +Exit $fail -- 2.54.0
