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

fix: add documentation on substitution and shell variable expansion #38

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
ismaelgv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,13 @@ rnr -f '(\w+)-(\d+).(\w+)' '${2}-${1}.${3}' ./*
├── 02-file.txt
└── 03-file.txt
```
__SHELL NOTE:__ In shells like Bash and zsh, make sure to wrap the `REPLACEMENT` pattern in single quotes. Otherwise, capture group indices will be replaced by expanded shell variables which will most likely be empty:
```
# Command typed in the shell
rnr -f '(\w+)-(\d+).(\w+)' "${2}-${1}.${3}" ./*
# After parameter expansion, the command that is actually ran:
rnr -f '(\w+)-(\d+).(\w+)' "-." ./*
```
ismaelgv marked this conversation as resolved.
Show resolved Hide resolved
#### Capture several named groups and swap them
1. Capture two digits as `number`.
2. Capture extension as `ext`.
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn create_app<'a>() -> App<'a, 'a> {
)
.arg(
Arg::with_name("REPLACEMENT")
.help("Expression replacement")
.help("Expression replacement. Enclose in single quotes to prevent variable expansion")
ismaelgv marked this conversation as resolved.
Show resolved Hide resolved
.required(true)
.validator_os(is_valid_string)
.index(2),
Expand Down