1
0
mirror of https://github.com/golang/go synced 2024-09-30 00:24:29 -06:00

Incorporated review comments

This commit is contained in:
Shawn Elliott 2019-04-22 10:14:34 -04:00
parent c2f026330c
commit 4b61931e66

View File

@ -374,17 +374,16 @@ Words:
// Substitute command if required.
if len(words) > 0 && g.commands[words[0]] != nil {
// Replace 0th word by command substitution.
// ... If no other words besides the command are on the invocation
// ... line, e.g.,
// ... //go:generate MY-COMMAND
// ... append() wouldn't force a copy as no increase in capacity was
// ... needed. Instead, it would instead return a reference to
// ... the actual g.commands value (the original word array). We
// ... don't want the original word list to be subjected to os.Expand()
// ... below, since the words in the command could contain changing
// ... environment variables, etc., so force a copy.
tmpCmdWords := append([]string(nil), (g.commands[words[0]])[0:]...)
// If no other words besides the command are on the invocation
// line, e.g.,
// //go:generate MY-COMMAND
// append wouldn't force a copy as no increase in capacity was
// needed. Instead, it would instead return a reference to
// the actual g.commands value (the original word array). We
// don't want the original word list to be subjected to os.Expand
// below, since the words in the command could contain changing
// environment variables, etc., so force a copy.
tmpCmdWords := append([]string(nil), (g.commands[words[0]])...)
words = append(tmpCmdWords, words[1:]...)
}
// Substitute environment variables.