Keep empty tilde expansion from empty field removal#164
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
POSIX.1-2024 requires:
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 theexpand_fourfunction 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 whenHOMEis empty and tilde expansion results in an empty string.