Skip to content

Keep empty tilde expansion from empty field removal#164

Merged
magicant merged 1 commit into
trunkfrom
empty-home-tilde-expansion
May 1, 2025
Merged

Keep empty tilde expansion from empty field removal#164
magicant merged 1 commit into
trunkfrom
empty-home-tilde-expansion

Conversation

@magicant

Copy link
Copy Markdown
Owner

POSIX.1-2024 requires:

If the word being expanded consists of only the character and HOME is set to the null string, this produces an empty field (as opposed to zero fields) as the expanded word.

This commit implements this behavior by inserting a dummy quote that is removed later in the expansion process when the tilde expansion returns an empty string.

Summary by Copilot

This pull request introduces a change to how tilde expansions that result in empty strings are handled, ensuring they are no longer removed from command line words. Additionally, corresponding updates have been made to documentation and tests to reflect this behavior.

Handling of tilde expansions:

  • expand.c: Modified the expand_four function to add a dummy quote when a tilde expansion results in an empty string. This prevents the field from being removed during command line parsing.

Documentation updates:

  • NEWS: Updated the changelog to document the new behavior for tilde expansions resulting in empty strings.
  • NEWS.ja: Added the same documentation update in Japanese.

Test coverage:

  • tests/tilde-p.tst: Added a new test case to verify the behavior when HOME is empty and tilde expansion results in an empty string.

POSIX.1-2024 requires:

> If the word being expanded consists of only the <tilde> character and
> HOME is set to the null string, this produces an empty field (as
> opposed to zero fields) as the expanded word.

This commit implements this behavior by inserting a dummy quote that is
removed later in the expansion process when the tilde expansion returns
an empty string.
@magicant magicant added the enhancement New feature or request label Apr 30, 2025
@magicant magicant added this to the 2.59 milestone Apr 30, 2025
@magicant magicant self-assigned this Apr 30, 2025
@magicant magicant mentioned this pull request Apr 23, 2025
56 tasks
@magicant
magicant merged commit 6ef41e4 into trunk May 1, 2025
@magicant
magicant deleted the empty-home-tilde-expansion branch May 1, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant