diff --git a/SC2145.md b/SC2145.md index 2481fcc..88b234e 100644 --- a/SC2145.md +++ b/SC2145.md @@ -26,7 +26,7 @@ If the intention is to provide each array element as a separate argument, put th Concatenating a string with an array can be used to make a command line interface with subcommands. -To implement the subcommand interface, first pick a prefix like `subcommand_` below for the function names that implement the subcommands. Then protect the parsing of the subcommands by listing them in the patterns of a case statement. In the body of the case statement, a concatenation of the prefix with `"$@"` will invoke the subcommand function and pass the rest of the parameters to the function. +To implement the subcommand interface, first pick a prefix like `subcommand_` below for the function names that implement the subcommands. Then protect the parsing of the subcommands by listing them as patterns of a case statement. In the body of the case statement, a concatenation of the prefix with `"$@"` will invoke the subcommand function and pass the rest of the parameters to the function. For example: ```sh @@ -58,4 +58,4 @@ main() { main foo aaa bbb ``` -In the above example, inside the `main` function, the value of `"$@"` is `( foo aaa bbb ccc )`. The value of `subcommand_"$@"` after expanding is `( subcommand_foo aaa bbb ccc )`, which the shell interprets as a call to the `subcommand_foo` function. \ No newline at end of file +In the above example, inside the `main` function, the value of `"$@"` is `( foo aaa bbb ccc )`. The value of `subcommand_"$@"` after expansion is `( subcommand_foo aaa bbb ccc )`, which the shell interprets as a call to the `subcommand_foo` function with parameters `aaa`, `bbb`, and `ccc`. \ No newline at end of file