Bash set +x without it being printed

后端 未结 5 1305
轻奢々
轻奢々 2020-12-07 11:56

Does anyone know if we can say set +x in bash without it being printed:

set -x
command
set +x

traces

+ command         


        
5条回答
  •  感情败类
    2020-12-07 12:37

    How about a solution based on a simplified version of @user108471:

    shopt -s expand_aliases
    alias trace_on='set -x'
    alias trace_off='{ set +x; } 2>/dev/null'
    
    trace_on
    ...stuff...
    trace_off
    

提交回复
热议问题