snipplets:prargs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
snipplets:prargs [2013/03/23 15:43]
ormaaj
snipplets:prargs [2013/03/23 16:24]
ormaaj Totally hide debug output, even the initial test
Line 17: Line 17:
 It uses the [[commands:​builtin:​printf | printf command]] to generate a list of arguments, even with escape sequences interpreted. This list is shown formatted by the nl(1) utility. It uses the [[commands:​builtin:​printf | printf command]] to generate a list of arguments, even with escape sequences interpreted. This list is shown formatted by the nl(1) utility.
  
-Another alternative with colorized output.+Another alternative with colorized output. If run in Bash, it temporarily disables all debug output for itself, including the test that determines whether to hide debug output. In ksh, tracing would have to be enabled on the function to show debug output, so it works out to being equivalent.
  
 <code bash> <code bash>
 # Bash or ksh93 debugging function for colored display of argv. # Bash or ksh93 debugging function for colored display of argv.
 # Optionally set OFD to the desired output file descriptor. # Optionally set OFD to the desired output file descriptor.
 +# Debugging function for colored display of argv.
 function args { function args {
- if [[ ${BASH_VERSION+$-== *x* ]]; then + { BASH_XTRACEFD=3 command eval ${BASH_VERSION+"$(</​dev/​fd/​0)"​}; } <<​-'​EOF' ​3>/​dev/​null 
- { BASH_XTRACEFD=3 command set +x; } 3>/​dev/​null + case $- in *x*) 
- trap 'trap RETURN; set -x' RETURN + set +x 
- fi+ trap 'trap RETURN; set -x' RETURN 
 + esac 
 +EOF
   
  [[ ${OFD-1} == +([0-9]) ]] || return  [[ ${OFD-1} == +([0-9]) ]] || return
  • snipplets/prargs.txt
  • Last modified: 2013/03/23 16:25
  • by ormaaj