So the execution trace looks very odd if your alias is defined on multiple lines, and looks plausibly normal if it's defined on only one? That seems slightly strange, but it sounds to me like a peculiarity of the execution trace mechanism rather than of the alias system.
I notice also that if you just set PS1 to ">>> " then this doesn't happen; there's some weird interaction between PS1 executing an actual command, and aliases, and set -x. Strange.
Indeed. set -x doesn't apparantly make any difference, if you try a command that produces error output then it will produce error output three times with that value of PS1 (and twice more for every other command you execute in PS1).
I've set: here for simplicity and done 'set +x'
>>> alias xxx=' func() { $@; } func ' + alias 'xxx= func() { $@; } func ' ++ echo '>>> ' >>> xxx false ++ func false ++ false ++ echo '>>> ' ++ func false ++ false ++ echo '>>> ' + func false + false ++ echo '>>> ' >>> alias xxx='func() { $@; }; func ' + alias 'xxx=func() { $@; }; func ' ++ echo '>>> ' >>> xxx false + func false + false ++ echo '>>> 'I notice also that if you just set
PS1to">>> "then this doesn't happen; there's some weird interaction betweenPS1executing an actual command, and aliases, andset -x. Strange.set -x doesn't apparantly make any difference, if you try a command that produces error output then it will produce error output three times with that value of PS1 (and twice more for every other command you execute in PS1).