When you place [double quotes][1] around an [expansion][2], such as the [parameter expansion][3] `$*`, the expanded text is not subject to [word splitting][4]. (That's one of the reasons to use double quotes around `$` expansions; the other is to prevent [globbing][5].) Furthermore, inside double quotes, [single quotes][6] are not treated specially, so they do not perform quoting and they are not [removed][7].
So, as [Michael Homer says][8], you can just **omit the spurious `'` `'` marks** and your function should work. I suggest writing it like this:
<!-- language: lang-bash -->
gac() {
git add .
git commit -m "$*"
}
You can use the `function` keyword to define functions in Bash but the syntax shown above works just as well and is portable across Bourne-style shells.
[1]: https://www.gnu.org/software/bash/manual/bash.html#Double-Quotes
[2]: https://www.gnu.org/software/bash/manual/bash.html#Shell-Expansions
[3]: https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion
[4]: https://www.gnu.org/software/bash/manual/bash.html#Word-Splitting
[5]: https://www.gnu.org/software/bash/manual/bash.html#Filename-Expansion
[6]: https://www.gnu.org/software/bash/manual/bash.html#Single-Quotes
[7]: https://www.gnu.org/software/bash/manual/bash.html#Quote-Removal
[8]: https://unix.stackexchange.com/questions/399774/passing-string-containing-spaces-as-command-line-argument-from-within-script#comment713953_399774