mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Show an example of when concatenating a string and an array is intended
29
SC2145.md
29
SC2145.md
@@ -24,4 +24,31 @@ If the intention is to provide each array element as a separate argument, put th
|
||||
|
||||
### Exceptions
|
||||
|
||||
None.
|
||||
```sh
|
||||
command_foo() {
|
||||
echo "In foo"
|
||||
echo "\$1 == $1 == aaa"
|
||||
echo "\$2 == $2 == bbb"
|
||||
}
|
||||
|
||||
command_bar() {
|
||||
echo "In bar"
|
||||
}
|
||||
|
||||
command_baz() {
|
||||
echo "In baz"
|
||||
}
|
||||
|
||||
main() {
|
||||
case "$1" in
|
||||
foo | bar | baz )
|
||||
command_"$@"
|
||||
;;
|
||||
* )
|
||||
printf "Error: %s\n" "Unrecognized command"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main foo aaa bbb
|
||||
```
|
||||
|
Reference in New Issue
Block a user