使用中间变量(此处为substr)构建功能消息(日期消息)和第二个构建的技术消息(错误消息): #! /bin/bashdeclare -r script_name="tmp.bash"function print_error { local substr= printf -v substr "$1" "${@:2}" printf "%s: ERROR: %s\n" "$script_name" "$substr"}print_error "Today is %s; tomorrow is %s" "$(date)" "$(date -d "+1 day")" 然后,您可以将功能构建和技术构建分开: #! /bin/bashdeclare -r script_name="tmp.bash"function print_tech_error () { printf "%s: ERROR: %s\n" "$script_name" "$1"}function print_fct_error { local substr= printf -v substr "$1" "${@:2}" print_tech_error "${substr}"}print_fct_error "Today is %s; tomorrow is %s" "$(date)" "$(date -d "+1 da