Skip to content

Reject multiple pathname expansion results in redirection operands#158

Merged
magicant merged 1 commit into
trunkfrom
redir-operand-expansion-error
Apr 18, 2025
Merged

Reject multiple pathname expansion results in redirection operands#158
magicant merged 1 commit into
trunkfrom
redir-operand-expansion-error

Conversation

@magicant

Copy link
Copy Markdown
Owner

POSIX.1-2024 allows the shell to treat it as an error when pathname expansion on a file redirection operand results in more than one pathname. Previously, yash only did so when the POSIXly-correct mode was disabled, but now it does so regardless of the mode.

POSIX does not seem to allow the shell to treat it as an error when pathname expansion on a file redirection operand results in no pathname, so this error is only reported when the POSIXly-correct mode is disabled as before. However, the previous error message was misleading as we were using the same message as the one for multiple matches. This commit changes the error message to indicate that no match was found.

Closes #95

Summary by Copilot

This pull request introduces changes to the behavior of pathname expansion in file redirection, updates related documentation and translations, and adjusts corresponding test cases. The most significant updates ensure consistent error handling when pathname expansion results in no matches or multiple matches, regardless of whether POSIXly-correct mode is enabled.

Changes to pathname expansion behavior:

  • Updated expand.c to treat pathname expansion resulting in no matches or multiple matches as errors in non-POSIX mode, while maintaining POSIX behavior when the mode is enabled. [1] [2]

Documentation updates:

  • Updated doc/posix.txt and doc/ja/posix.txt to reflect the new behavior for pathname expansion in file redirection. [1] [2]

Translation updates:

  • Added new error messages to po/ja.po for cases where pathname expansion fails due to no matches or multiple matches.

Test case updates:

  • Modified tests/redir-y.tst to include new test cases for pathname expansion errors in both POSIX and non-POSIX modes, and updated existing test descriptions for clarity. [1] [2]

Miscellaneous:

  • Updated creation and revision timestamps in po/ja.po.

POSIX.1-2024 allows the shell to treat it as an error when pathname
expansion on a file redirection operand results in more than one
pathname. Previously, yash only did so when the POSIXly-correct mode was
disabled, but now it does so regardless of the mode.

POSIX does not seem to allow the shell to treat it as an error when
pathname expansion on a file redirection operand results in no pathname,
so this error is only reported when the POSIXly-correct mode is disabled
as before. However, the previous error message was misleading as we were
using the same message as the one for multiple matches. This commit
changes the error message to indicate that no match was found.

Closes #95
@magicant magicant added this to the 2.59 milestone Apr 18, 2025
@magicant magicant self-assigned this Apr 18, 2025
@magicant
magicant merged commit 7da3f6a into trunk Apr 18, 2025
@magicant
magicant deleted the redir-operand-expansion-error branch April 18, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reject if a redirection operand expands to more than one field in an interactive shell

1 participant