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

Use shellwords for .stowrc parsing #111

Merged
merged 2 commits into from
Jun 18, 2024
Merged

Conversation

jeremy-code
Copy link
Contributor

@jeremy-code jeremy-code commented Jun 14, 2024

  • Use shellwords to parse .stowrc files from Text::ParseWords
  • Add test for .stowrc parsing with quotes
    • Add stow directory to tmp-testing-trees for testing

This change allows .stowrc arguments to be parsed similar to shell arguments, where quotes can be used to group an argument with spaces.

However, this change affects the behavior in --ignore, --defer, --override.

--ignore=$HOME => (?^:$HOME\z)
--defer=$HOME => (?^:\A$HOME)
--override=$HOME => (?^:\A$HOME)

Hi, this PR is in regards to #15. Other than the tests mentioned (rc_options.t, Test that environment variable expansion is applied. for ignore, defer, and override), everything passes.

I am using shell_words but I also did it with `parse_line(" ", 0, $line) and it had the same effect of breaking that test.

My two concerns are:

  1. The RegEx for the options for that aforementioned test appears to have different behavior than before. I am not certain how to fix this, or whether this is the intended behavior. The current change is just a hack for now.
  2. I added a test but I imagine it is not ideal to have a new folder in tmp-testing-trees for just one test.

Fixes #15.

jeremy-code and others added 2 commits June 15, 2024 13:01
- Use `shellwords` to parse `.stowrc` files from `Text::ParseWords`
- Add test for `.stowrc` parsing with quotes
  - Add `stow directory` to `tmp-testing-trees` for testing

This change allows `.stowrc` arguments to be parsed similar to shell arguments,
where quotes can be used to group an argument with spaces.

However, this change affects the behavior in --ignore, --defer, --override.

(?^:$HOME\z)
(?^:\A$HOME)
(?^:\A$HOME)
Previously the \A and \z anchoring for --ignore / --override / --defer
was being applied without wrapping the user-specified regexp in
parentheses, so if it was something like bin|man then the anchor would
only apply to one half of those two paths.  So add parentheses, and
also change from qr() to qr{} syntax to visually differentiate between
regexp boundaries and parentheses inside the regexp.
@aspiers
Copy link
Owner

aspiers commented Jun 15, 2024

Awesome, thanks a lot! I think I've fixed the concerns you highlighted now - take a look and let me know what you think?

@jeremy-code
Copy link
Contributor Author

Looks great, thank you so much!

@aspiers aspiers merged commit 9e7bd86 into aspiers:master Jun 18, 2024
5 checks passed
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.

Option with spaces breaks in stowrc
2 participants