$ cat 2.sh
#!/bin/bash
 ####################################################################
 # author: hjjdebug
 # date: 2023年 08月 07日 星期一 17:44:09 CST
 # configure 文件中测试Makefile 是否支持嵌套变量的代码注释.
 # 下面代码是从configure 脚本中择出的一小段代码,供研究用,有详细注释
 ####################################################################
 as_echo="printf %s\n"        # shell 变量赋值
 as_echo_n="printf %s"
 as_me=$0
 am_make=${MAKE-make}        # 若$MAKE 没有定义,返回 make
 exec 5>config.log            # 重定向文件描述符 5 到 config.log
 exec 6>&1                    # 重定向文件描述符 6 到 标准输出
 #由于$as_lineno没有定义,所以返回$LINENO,这就是脚本行号
 #因5,6已被重定向,故输出到文件和控制台
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
 $as_echo_n "checking whether $am_make supports nested variables... " >&6; }
#这个变量替换是当${am_cv_make_support_nested_variables}有值时,返回":"
 # false 是 if 的条件强制改为false, 所以 then 语句不会走到,
 # then 后面的: 是返回true的意思,因if 条件强制为false, 不会走到了
 # 不知道它为什么要这样写?
 if ${am_cv_make_support_nested_variables+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 # 状若垃圾的bash 语法, 是为了效率!
 # 向控制台输出了一段 Makefile, 然后用 make 去执行,成功则设变量为yes
 # Makefile 的意思是执行$(TRUE), 其展开过程为V=1 则 $(V)=1 则内层为BAR1
 # 由于BAR1=true, 所以${BAR1}=true, 所以 TRUE=true; 所以 $(TRUE)为true, true 就是命令true
# Makefile 若能成功执行命令,总是返回true
if $as_echo 'TRUE=$(BAR$(V))
 BAR0=false
 BAR1=true
 V=1
 am__doit:
     @$(TRUE)
 .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
   am_cv_make_support_nested_variables=yes
 else
   am_cv_make_support_nested_variables=no
 fi
 fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
 $as_echo "$am_cv_make_support_nested_variables" >&6; }
执行结果:
$ ./2.sh
 checking whether make supports nested variables... yes
 hjj@hjj-u7090:~/test/test_bash$ cat config.log
 ./2.sh:16: checking whether make supports nested variables
 ./2.sh:43: result: yes