Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
snipplets:prargs [2013/03/23 15:28]
ormaaj Another version
snipplets:prargs [2013/03/23 16:25] (current)
ormaaj
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>
-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.
 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 'set -x' RETURN + set +x 
- fi+ trap 'trap RETURN; ​set -x' RETURN 
 + esac 
 +EOF
   
- [[ $OFD == +([0-9]) ]] || return+ [[ ${OFD-1} == +([0-9]) ]] || return
  
  if [[ -t ${OFD:-2} ]]; then  if [[ -t ${OFD:-2} ]]; then
- typeset -A 'clr=( [green]="$(tput setaf 2)" ​[sgr0]="$(tput sgr0)" ​)'+ typeset -A clr=([green]=$(tput setaf 2) [sgr0]=$(tput sgr0))
  else  else
  typeset clr  typeset clr
  • snipplets/prargs.1364052488.txt
  • Last modified: 2013/03/23 15:28
  • by ormaaj