bash: unable to set and use alias in the same line
问题 I would expect the second line to say foo instead of command not found : $ alias foo="echo bac" ; foo; -bash: foo: command not found $ foo bac $ Why won't the second line say foo ? Tested with the following shells, same behavior: bash 3.2.5 zsh 5.0.8 dash 0.5.9 busybox 1.25.0 回答1: The behaviour you're seeing is described in the Bash Reference Manual (emphasis mine): The rules concerning the definition and use of aliases are somewhat confusing. Bash always reads at least one complete line of