Usually a multi-line command gets added to the history list with semicolons added in the requisite places, i.e:
$ f() { > : > } $ fc -ln -1 f() { :; } However, if the final line is a comment, the semicolon is not added, making the history item an invalid command: $ f() { > : > # > } $ fc -ln -1 f() { : } Similarly, if the final line is a command which ends in a comment, the comment character is preserved as part of the command, again making the resulting history item invalid: $ f() { > : # > } $ fc -ln -1 f() { : #; } Same is true for `for' and `while' loops, `if` and `select' statements, etc.