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

Shellcheck wrap variables #376

Closed
wants to merge 4 commits into from
Closed
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
Prev Previous commit
Next Next commit
feat(invocation): wrap vvariable
  • Loading branch information
Mte90 committed Jul 30, 2024
commit 6e9b66b6513e0b7ce70eb1a10a8cc32b9c5efe6c
10 changes: 7 additions & 3 deletions src/modules/function/invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 148,13 @@ impl TranslateModule for FunctionInvocation {
} else {
let translation = arg.translate_eval(meta, false);
// If the argument is an array, we have to get just the "name[@]" part
(translation.starts_with("\"${") && translation.ends_with("[@]}\""))
.then(|| translation.get(3..translation.len() - 2).unwrap().to_string())
.unwrap_or(translation)
if translation.starts_with("\"${") && translation.ends_with("[@]}\"") {
translation.get(3..translation.len() - 2).unwrap().to_string()
} else if translation.starts_with("${") && translation.ends_with("}") {
format!("\"{}\"", translation)
} else {
translation
}
}
}).collect::<Vec<String>>().join(" ");

Expand Down