#!/usr/bin/env bash
#rK`B6\~pyu6yDK\6חY.M6gd/ݛ3>{d6tME
# this is to source, use ' source xf ' or ' . xf ' from withhin your shell prompt
#  optional it can also be executed, with a command and args as args
#
# owners :
#
#   {xmb}
# by <   @skilled.ch> - awk/bash code from http://xmb.ath.cx/ [/software] [/code/] [/code2/sh|awk]
#  <    ster@gmail.com> + //xmb.offenders.org/
#  < maiceuv@gmail.com>   //codebong.net/
#  <     @root.pe>        //localhack.ch/
#                         //szills.org/
#                       # //codebong.com/
#                         //xmb.bg/
#   r nlo ng nlo
# xikcz<xmbster@gmail.com> + //xmb.home.cosmic-cow.net/index.html
# ixikczi<xmbster@gmail.com> + //i.offenders.org/index.html
# ikxczii
# maiceuv<@gmail.com>
# nlo+zalexkhcszandrucsz <maiceuv@gmail.com>
# 
#
# changes, newest first :
# format : date name (<>) \n data \n things \n data \n\n
#( data:) D 777 and 77
#
# zalexkhcszandrucsz +nlo +puk '8*1'*2'1'
#
# d@qnz^:sKoTÞH|7eO;NFԖho񘲉@<K(}{u_퓨R%`t+sv\ߢAն>{߸,Yn۬ZFPn/ף1y⇌&p.T)BB-.*qW𒒊ȘփuRzF%$G`YV4)%:U#"ar&Bwաfb)>)hxZ?_wMj(Z}#:Y\BKʃ&v5F,.tЇW#Њ~79,Orᷘ`2S,\߈bmw!ͪ<HAJbԃN{LN5"-ˬ_mu$&oAЈ=|4C=bʢv;B4}`ROqZз'9!:DդUp֊9wt{|fa'o2TqPAd&މbʢDe6q3Gylo4r+K"#5agGn|ډ=p%8$sޟNqg's43|047$&$pEiK?tO˯\c_&Uwq"QTs8@Fbƺ/!<lfoʪEM~aFB.":uADF"!=e85MEAոX>-'zDU=?;f<yͅMQj(Y~$p/qQv2c*)fflJ)V|I*48?uGo2@vpJoڹ-.fzqbQB?ܔiTf֫\@
#
# fixing recent(), args were ... whatsoownt eh , yeah i ownt all .. normal ..
#  fixt, fault'' was the ' local arg' in earlier bash be true
#
#
# 13*'9*2'1' maiceuv
#
# 7mo9NC<I@l=,B2HpUC8m}2:<=Xi-&>α,b_ׅR5|ԨQ
# I*p͚/${)p5.z߽DaT"qlH&H=C6T0h8ȁO3<Ĝ15rӃCHUJ}bȊ;+FD.9}:ѓoyVîF;v&GqJڠMBp87ӚE7G@Rt$yFh2k@}pOnѓR#3.j襫MXk·8&abTl{csh8؋LUm"u\IT˩AhN_f7$i*Ur2}HUg^ԗ9dDiL"6eTεĿ!drN'Obfa%݂?xk!iX0̪"FhڶSPyv<ix}$M"IZ|DZ/(/O_`.cXomvA,o>-A9a%2TzwOACzT݂N/Ό8!D{Jjk6"$5,DVtߓ=m?s^?%Gc}!\y"T>gk>U׵s#_կ$(cY^Apx}>XNW.Cx_$J=b7Xm9*a;B@7u'ޖ_銸O+CQgu4TAd{IxrǶߐUF"4OzXCeM틑s-D"."BOfrI;iKD!
#
# adding a s=sleep shortcut ( alias) %done
# exchanging alias [ es] for ' a' %done
#
# rįgZJ.dy8W柤,Y:-IV.+V&X03*ɁJyAֵ\eӗW1RӲqŴ
#
# 
# 
# 
# maiceuv now 2'1'
# #VJ7pŗJA'Feq{^*4ʲF`"W`U%ۼ\qeKqx^ŽK'BdryZ;*)Hw3LKpkSIV\xq-FUvdHEᳰՅ^-U_$L5_͸˻&@>Q8JSq6*aO'g1p~z׏`_Q?R>eGbYh'dKiUڱM%@PjXL7;7iii9,9,^3"v$_ǐس:~Tl;_;L,\C~GX1,\"+.0=qFDO$U2Zڱ#쪉QA#4$xG71+/Y.Gs/E<a(OĊXO8⽉B@#ј2,=q≳U+7c>t>hIE-7fG$vMYi/-@O(g"uj,K$lk&)pTwt_㔰dhjK;B#OzaQ͠׹lŷS}J~0@Xy"):~ܴX6݂H;{҂BȯZa4ypeEϾ!,IKW~ZY|E"tg#ȊXAC!{7_ꊠxxW6)0R5#O8֔ә\K2tYڢ0Bxrj<s}Kcl5v盪S2?.<|H(՟`Fc)$wP>\ь1)Ò%cEQ
#
#
#
# adding more valid contacts section
#
#
#
#
#
# info :
#
# some useful functions and aliases, xmbfunctions
# to source, 'source xmbfunctions.sh' or '. xmbfunctions.sh', and use
# from /etc/profile /etc/bash.bashrc  or individual bashrc bash_profile sourceable
#
# or execute commands thought it:
# [doeval=1] [out=output_file] bash xmbfunctions.sh [eval] <command> '; command ..'
# ; as separator when doeval is set, in which case eval runs the arguments
# doeval=1 as also <eval cmds.. | other cmds> is possible
#
# time to source:
#  400er G3 bash3 - .040s
#  450er P2 bash3 - .044s/.034s
#           bash2 - .028s
#  500er P3 bash3 - .021s
# ++++
# with new on 04.08.2010:
#2x1.8amd64 bash4 + .035s
#
# - 09/2005 new/- bash:source/exec bash-static:source/exec - best times
#
#  1GHz     P3    bash3 - .030s/.025s 	.028s/.020s
# 2.66GHz HT Xeon bash3 - .011s/.012s 	.010s/.009s
#
# 01.04.2005 /* rest in peace paps poepel pope, you stand */
# rare update entry 13.03.2005, added advanced awkinc() awk multiporpose code mixing thing
# 11/09/2005 - long dep shit time has been, HD lost of scripts and partly xmbfunctions
#            - update entry: added functions in awkinc(), if (( term )) markups
#
# off entries: -14/05/2005 to 11/09/2005+
#
# 21/09/2005 @07h - update reprocessing
#            - term aliases, change prompt, hist expanding options by default +1
#            - rcp time
#            - modernizations/fixes: recent() , awkinc() , xMP()
#            - slowly modifying for zsh/ksh compatibility
# 27/09/2005 - sinst() / wrfile() / dltar(dlocate_tar) / netipmatch()
# 01/10/2005 - $do_term inherit addition to $term, alias pp=prettypaste
#            - old PS1 prompt is saved to $PS1_OLD and $old_PS1
#            - proper eval'ing arguments
#     28777C - removed sh incompatible name function /.() { .. }
#     29887C - added: mvlink(), utf2ascii->utf3ascii
# 02/10/2005 - 31280C / 31777C
#            - added: awkdiffsep() / termactivity()
#            - fixed: mvlink()
# 15/10/2005 - 
#            - added minimalistic awkxargs() - fut. needs dynamic code generation
#     33667C - added: showmissing() -> add_PATH()
# 30.05.2006 - 41417C / 42178C
#            - added array_work()
#            - extended awkinc() by 11 functions and new style / vars
#
# 23.07.2006 -
#            - two new functions
#
# 25.07.2010 - added default term_ext ( extglob)= 1
#            - added term_modern_aliases[ = 1]
#            - moved [vf]find defs up to have find=ffind alias working, added 'command' kw[ keyword]
#            -                                                           infront of find in there
#            -        added coloring of file names [ bg], nothing to do about ending the color at end of file, not line
#            - added a few new ng= var defs, mainly to change the world [ for great ] and information
#            - added one or a few ng comment additions ( format= [ng+<cont>])
#            - will update the prompt format soon to newest standards, check /prpt
#
# ysiJ"V"31>$(V>#*#DJ9l_%R"t$Ata .F[b<OM6\w#+1l(sJVJZRB]YW=8n>Y+Q5t
# SR6++&:".1W3IXqW+8 JO5NYL'.{e_Vp[2Jl+2VQ@%vI$i+5UeRP.onzaQ&]D1%,_
# IEJ#2#iyC0)4:,{7,P>D)kT*f&[$cK)3N!9?Bm -u.(,JuClZs+"15{.J"J+|]!b5
# ,;&3@ViY#ew]%zdLbM1WZ+sJNV,$M<7="<@T K+}+]VpPdQ|%1#+5+E+q<8GA+uM1
# $65u3+#Z0gx'Kyg9cj)#h+c^U>kJznNnGszvmP\P18O+N&*Ao%.d#m})QFl$Lo,?8
# {;2>@'t!kjo[aNq?%"pN^(JUXWR%dL+aBwegG*J+wir !++X7gQ!Z+.+7*Acm&$&U_BW#cLri%FjB
# }+Xj!]+Ti$+f\[|NL5?EC_7HOH'+3+U*4.= LW|fV65N+A!E3MA&|iO3<L=+2QFK+A]='T7K=GM_[
# rAGa:\U@Z9w@LIn.)K+l${|+Zvv4^m7KT'++d*+Cy,M[+"=n#+3r!Qdld>&Y3+T!%yR1>^!$'Lb='
#
# 28.07.2010 - added some more exported general useful defs\|vars, fixed and adding new aliases
# Axo'`K.#8{ԿJM,HLiKqZlc2H{=,!`Q}S;/SO.7fu1
#        fyi - vars, exported, are part of yer env[ironment], where u live at, umgabiigg, kadeto jiweeesch
# |M-^DM-ghrM-$M-"M-XYM-uM-DM-5M-^KM-)XthaM-KM-]@/M-gM-3M-^?\9M-^FM-uM-(mogM-`8M-z|AmM-f60M- M-f7M-lM-^@M-pPdM-+M-"M-nxlM-LliM-N$M-.|M-=JM-[M-E9M-^UM-|M-tM-.M-6tM-'M-dM-pp
#            - fixed aliases to not contain quotes, added more vars and aliases
#
# 29.07.2010 - a[dd[ing]] more ng defs, all the defs u see exported on top of this codes runtime tointerpret are !ng!
#            - a[dd[ed]] d[iff[erent]] n[am[ed]] h[i[st]]f[i[le]]
#            - more global ng style
#            - many more short named aliases, !very! useful
#            - fixed have_xmb=1 to exported +100
#
# ++++++++++ + fixed some schtuff in the meantime and extended
#
# 02.08.2010 + added s=sed\ -r #-i alias
#            + added r=recent=l
#            + added and adding more alises
#
# 03.08.2010 + adding more aliases
#
# 04.08.2010 + adding and fixing alises and ng env defs
#            + adding DEBUG trap to add every command to the histfile [ default not prefixed] after enter,:vgg!
#            + todo: add h command for history, a full featured set of commands, displaying multiline per line via prettyprint
#            + adding few comments and doing other format fixes, such as more than one empty newline in da row
#            + todo: d for data, flexible data+everythingy
# 58882C     + realigning aliases defs
# 58891C
#
#iM0<bh0a:74P)4ǔ~}`{j}+Lus2Яaѿ@Pnu'lx)
#
# 15.08.2010 7 xmb
#               ng names for a few major keywords
# 53881C
#
#n.<\8{1FV8&4nym#fPV9c޻KAx!4FZLwHU=$N,jXХ
# 02.09.2'1' 7 alekcsz 2 world
#              got rid of F+argparse , F+gen replaces it
#              changed a E=eval and did a editor=- + F+-=editor
#      C
#
# /* last updated: 13.09.2'1' */~

alias a=alias

#s#?Vq\eX(N&7\2`9d^Y5߂`$VߝΫY#B<){NJ?g
#a-be_8xѵ${9^o'GҨ;L|Ůd|(ײ'O`y7V9HCw
a d=def def=definition definition=data data=export
#'uSxV2^9sqϟS*r-ei,S4cY^+E.fzhn)naYJ8u
#X9fV铪m"1aX)"s'WM|E:hזHά,&(G3!(־1A+2d/MԟƮ+6

d a=all s=say as=allsay

a F=function

d I=IIIIII i=iiiiii saysave=rnlong i=$i,ii,=i lang=i[i[s[h]]]
d sayintro=hai
d saytime=pumpage mainaction=rngnlo,=pumpownhavekeepshare\
onproblems=gateback@body4recovery\&upates7fullbeback7fullnewfunctionality
d d=d[ef[inition]]\|v[ar[s]],d[ata],everything,amust@ng\&bg
d i=intro\&ng\&holygod\&alias4initre,=instant,=inventation,=erfinndig
d v=iverboselyrapu
d lang=ng,=normal,=bg,=any,=all,=natural,=neutral,=native,=weird
d axikcz=axikcz,=oxikcza
d languagetospeak=nativenaturallanguage
d xmb=i,=a,=o,=axikcz,=god BOT=bot,=theclan bot=BOT
d ng=tehstandard:ranges:neutral:0\ -\ 100,negative:-100\ -\ -0,positive:+0\ -\ +100,\
=newgeneration,=veryimportant,=betterthanneutral
d done=k,orsimiliar dicwelldone=holyshit welldone=holygod
d lt=lealtime,similiartort rt=realtime r=redo,recover,includes:remember,regenerate,remap,rethink
d n=name[s]
d d=$d,d,./d,=xrand,=useforanykindofstamps[+cryptoandcode\!]
d whosgod=axikcz,=manymorenames77@comeheredef\'d
d whattodoonproblems=own,=befriendly,informative,etc[moretocome,..],=iftheystillcauseproblemstellem\'die\'etc,=[k]
d gangster=underground,=dowhatyouwannado,=nga

d errectionexitcode=7777777

#nrEM%Y)pRXK#T=RVZ^5)I\bܜx@sțhG}-

d faikdisduktschioen=tot.shit.man

d own=7aleksz

d fullsuccess=+100+ fullownage=\!+100+\!

d full=np,=k,=welcome,=thx,=sorry,=be,=have,=keep,=etc,=me,=/me

d gline=gangsterline oline=ownline

d gg=wininng,=shizzling,=hustling,=beeingunderground,=beeingactive,=slick,=sick,=leet,=udopain,=welldone

d PATH=.:/:/root:$PATH

d tech=xmb
d priority=nlo,=realtime,=lealtime,=rt,=fifo
d fastest=tialo,=tela,=body,=bodies,=xmb

## 15/10/2005
#
# add_PATH - add unexisting

add_PATH() { local newpath
        newpath=$( echo $PATH:SEP:"$@" | tr \  : | RS=[:\\n] ORS=: showmissing )
	PATH=$PATH:$newpath PATH=${PATH%:};}; #~F\add_path~
alias add_path=add_PATH

## 15/10/2005
#
# showmissing - show missing entries from data 2 to data 1
#
# EX: echo -e "foo\nbar\nSEP\nfoo\nzaza" | SEP=SEP showmissing
# ->  zaza

showmissing() { local SEP=MISSEP way=cat skipline=1 mfield=${mfield:-0} mdata=${mdata:-0} FS RS ORS
	${awk:-awk} ${FS:+-v FS="$FS"} ${RS:+-v RS="$RS"} ${ORS:+-v ORS="$ORS"} \
	-v SEP="$SEP" -v mfield=$mfield -v mdata=$mdata '
#!/usr/bin/awk -f
{
  if ($0 ~ SEP) { NR++; next }
  if (NR == FNR) Seen[ $mfield ]
  else if (! ($mfield)) print $mdata}';} #~F+showmissing~

#add_path . /root #wontworkatm~stillnotdoing~

set -b

#F ap( )
# {
F ami( )
 {

 # apt-get mass install and removes the dependencie problematic packages from the lists
 #  does
 #  # a sw install *{data}*
 #   if fail, save up the list of dep prob pkgs and remove em from the list and do again
 # gg ware

 #a install $(  .. todo )

 #A install $( for d; do aaa $d; done| awk ' )
 :
 
}

### *** settings to enable| disable !\

###
# default settings here, all just term modification related: prompt, aliases, history
# to disable, simply set do_term=0

: ${term=${xT:-${do_term:-1}}} ${term_aliases=1} ${term_functions=1} ${term_prompt=${xP-${Tp:-1}}} ${term_hist=1}
: ${term_ext=${extglob:-1}}
: ${term_unset=} ${term_unalias=}
: ${_unset=} ${_unalias=}
: ${term_modern_aliases=${modern_aliases=${ma=1}}}

: ${ulimits=1}

: ${personal_spawn_shizzle=.....1...needcheckingofalreadyworkingornotahwell}


if (( term )); then   # include the following to have in an interactive shell, ie HISTORY control and prompt

shopt -s checkwinsize
if (( term_ext )); then
	shopt -s extglob
	shopt -s dotglob
        #shopt -s nocaseglob # thatnocaseglob:--:breaks:completition
fi

(( ulimits))&&
 ulimit -c 7777 -i 777777 -l 777 -n 7777 -q 7777777 -s 77777 -r 7777777 # -p 77

##
# 'verbose' find
# ffind showing kinda better output [ng+than plain find]
#
# $ vfind <find args>
# $ ffind <find args>
##

vfind() { command find "$@" -printf "%-9s %-6i %F %u:%g\t (%AD-%AX/%CD-%CX/%TD-%TX) <%-2d> %30f \33[42m%h\33[m\n"; }
ffind() { command find "$@" -printf "%-9s %-6i %F %u:%g\t (%AD-%AX/%CD-%CX/%TD-%TX) <%-2d> \33[42m%p\33[m\n"; }

(( ng_functionality|| term_aliases|| term_modern_aliases))&&{

 a s=sleep

 a E=eval
 a e=echo\ -e

 a K=kill
 a k=killall\ -7

 a L=ls ls=ls\ -Ac\ --color=always
 a less=l l=command\ less\ -RU\ +F

 a ln=ln\ -vn
 a rm=sleep\ .7777\ \;rm\ -vrf
 a mv=mv\ -v
 a cp=cp\ -i\ -vx\ -rap\ -u
 a df=df\ -Th
 a du=du\ -ch
 # .. more to come

 a r=recent #l| ..
 a tp=rpid
 #      tracepid

 a mkdir=mkdir\ -p

#a find=f f=ffind
 a f=superfind superfind=ffind
 a grep=g g=command\ grep\ -rE

 a ps=P P=command\ ps\ auxwwf

 a cat=command\ cat\ -vTt

 a ts=trap #trapsignal
 a hook=trap

 a gimmedata=needtodef+cat+something

 a A=apt-get\ -fy\ --force-yes\ -t\ experimental,unstable,testing,stable
 a aa=apt-cache\ show
 a aaa=apt-cache\ search

 a t=touch
 a nt=ntouch
 a rt=realtouch

 a n=nestat\ -46an

 a cip=checkip ivip=cip ifvalidip=cip
#alias ipn=netipcheck
#alias nip=netipcheck%already:have

 a h=adnshost\ -a\ -u\ -Qq\ -Qa\ -Cl\ -Vq\ -Fi\ +e\ -Tt\ $adns_args # good adns alias
 a xargs=xargs\ --verbose\ --no-run-if-empty

 a multipleoneline=prettypaste

 a editor=-
 F -( ) { command vim -b ${1+"$@"};}

 a pico=nano\ -w

 a urlgrep=u u=urlgrep grepurl=urlgrep

 a dl=curl C=dl
 a curl=command\ curl\ -A\ i+intelligentware\ -e\ i

 a sed=S S=command\ sed\ -r #-i

 a s=sudo

 a sE=s\ E
 a c=clear #keepingthiscrapduetoimportancy,notthatiuseditanymanyornuff=pp
#alias cl=clear\;\ l

 a search=shernix shernix=awk\ -f\ shernix_cli.awk\ -f\ shernix.awk #=search\ ${S-google${s--long}} #S=s

 a albums=albums.awk
 a indexfiles=albums
 a fc=f\|\ albums # f[i[nd]] c[o[ll[ec[t[ed]]]]]

 a debdlocatetar=dltar ddt=dltar

 a xx=x_hex_print

}

if (( term_prompt )); then

[[ -n $PS1_OLD ]] && eval PS1_OLD_$RANDOM=\$PS1_OLD
PS1_OLD=$PS1 old_PS1=$PS1 OLD_PS1=$PS1
# PS1='\u (\[\e[1m\]\h\[\e[0m\]:\l:\j)\[\e[1m\]\w\[\e[0m\] \$ '
#def:promptline
PS1_XMB='\u (\[\e[1;31m\]\h\[\e[m\]:\[\e[33m\]\l\[\e[m\]:\[\e[32m\]\j\[\e[m\])\[\e[1m\]\w\[\e[m\] \$ '
PS1=$PS1_XMB

# new code for multiline prompt, get it from //xmb.offenders.org/prpt

. prpt .

fi

if (( term_hist )); then

 HISTCONTROL=ignoredups
 hsize=77777777777 histsize=$hsize HISTSIZE=$hsize HISTFILESIZE=$hsize
 hfile=echoes histfile=$hfile HISTFILE=$histfile # electronic hoes # ahahwhhwwhhwkwkwkekekehwhwwwhhwhhwhwvgg!pwntownt@!!

fi

#[[ -n $term_unset ]] && eval {unset,unalias} $term_unset\;

fi # if (( term_functions )) missing cause _() = easy and needed by some functions, but still in if =p

# kind of a `which`
_()  	{ if (( one )); then type ${ttype--p} ${1+"$@"} | head -1; else type ${ttype--p} ${1+"$@"}; fi; }
__()	{ eval echo {{${PATH//:/,}{$(for arg; do echo -n ",$arg"; done)}}; } # args nowork,`do$argoneveryinpathpreandschtu
#ss()	{ strace -fF "$@" 2>&1; }
#so()	{ strace -fF "$@" 2>&1 | grep ^open; }
#lss()	{ ltrace -Sf "$@" 2>&1 | grep open; }

kbg()	{ bg; $H1 kill -7 $H2 $!; :; } # background and kill -9 the last job
alias 	bgk=kbg

F bmv( )
 {

 for d
  do

  mv "$d"{,"$( D 77 s)"};done;}; alias mvb=bmv

sls()	{ ls ${1+"$@"} | rlist | ${less:+less -RU - --} ${less:-cat}; }

sinst() { chmod +x $1; mv ${1} ${spath:+$spath/}${1%.[a-z0-9]}; }

wrfile(){ local file; while read file; do [[ -f $file ]] && echo "$file"; done; }
# dlocate tar
dltar() { local arch=$1; shift
	[[ ! $arch || ! $@ ]] && { echo "dltar <out archive> <dlocate search>"; return 1; }
	dlocate "$@" | awk '{ print $2 }' | wrfile | tr \\n \\0 | xargs -0 tar cfz $arch;
}

# match current netstat -an with text files containing ips
# needs: xmb.ath.cx/code/ipgrep
netipmatch() { local ips ip
	ips=$( ipgrep ${1+"$@"} )

	#echo --- ips "$ips"

	netstat -an --inet |
		${S+sudo} ipgrep |
		awk '{ print $2, $0 }' |
		while read ip rest; do
			#  grep -q $ip <<<"$ips" &&
			[[ $ips == *$ip* ]] &&
			echo ip matching: $ip &&
			echo "$rest"
		done
} ; alias netipgrep=netipmatch nip=netipmatch

# advanced general purpose strace wrapper / ltrace wrapper
# new generation transformation - 02.05.2005 - maybe local instead unset - shell var unfriendly, but pwn it
# 31.05.2006 - fixed local vars and n=$0
# it was once 5 lines long

st()	{ local n arg r reset # n = $FUNCNAME
	  local St{base,socket,select,thread,mem} grepbase
	  ${r+unset ${!St*}} ; ${reset+unset ${!St*}}

	  : ${Stbase=open|access|fstat} ${Stsocket=socket|fcntl} ${Stselect=select|fcntl}
	  : ${Stthread=mutex|p?thread|set_p?thread|rt_|getp?(pid|grp)} ${Stmem=m(un?)map}

	  Stthread=$Sthread\|\(set\|mit\)_in_pages\|clone\|child\|.?.?fork Stbase=$Stbase\|ioctl
	  
	
	[[ $n == lt* ]] && ltrace= || unset ltrace ; [[ $n == *f  ]] && f= F= || unset f F
	[[ $n == *p* ]] && pid=    || unset pid    ; [[ $n == *o* ]] && o= x= || unset o
	[[ $n == *e* ]] && ext= x= || unset ext    ; [[ $n == sl* ]] && s=    || unset s
	
	grepbase="-- SIG|^${pid+(\[pid [^ ]+ )?}(old_${ltrace+|SYS_})?($Stbase${T+|$Stthread}"
	
	# ${ltrace+ltrace} ${ltrace-strace ${F+-F}} ${f+-f} ${pid+-p} ${1+"$@"} 2>&1  |
	${ltrace+ltrace} ${ltrace-strace ${F+-F}} ${f+-f} ${pid+$(for arg; do echo -p$arg; done)} ${pid-${1+"$@"}} 2>&1  |
		
	#	${o+ grep ^open} ${e+ grep -E "^(open|recv|send|connect|bind)"} ${x-cat}
	#	${o+ grep -E   "^${ltrace+(SYS_)?}($base)" } \
	#	${ext+ grep -E "^${ltrace+(SYS_)?}($base|recv|send|connect|bind${R+|read}${S+|$socket})" } \
	#   ${x+ cat }
	
	#	${o+   grep -E "^(old_${f+|\[pid [^ ]+ }${ltrace+|SYS_})?($base)" } \
	#	${ext+ grep -E "^(old_${f+|\[pid [^ ]+ }${ltrace+|SYS_})?($base|recv|send|connect|bind${R+|read}${S+|$socket})" } \
	#	${x-   cat }

		${o+   grep -E -- "$grepbase)" } \
		${ext+ grep -E -- "$grepbase${R+|read}${S+|$Stsocket}|recv|send|connect|bind)" } \
		${x-   cat }
	
	unset x
}

# alias building for all the possible strace / ltrace commands

#alias	{st{p,f,fp},lt,. 
#alias	{{st,lt}{,o,e}{,p,f,fp}}=st
#alias	$( for _tm in {{st,lt}{,o,e}{,p,f,pf}}; do echo "\"$_tm='n=$_tm' st\""; done; unset _tm ) # impossible?
#for _tm in {{st,{,s}lt}{,o,e}{,p,f,pf}}; do false && Tm[++tm]=$_tm=n=$_tm\ st || alias "$_tm=n=$_tm st"; done
#                    {,a}
#unset   _tm tm Tm
#unalias st

# ng

#for _d in {o,e}{s,l}
# ng: comment: god damn wheres the functionality list lolz # there up lolz

##
# st   -> strace
# lt   -> ltrace
# slt  -> ltrace with -S syscall
## additional chars in the cmd
# o  -> filter file requests
# e  -> extended filtering
# p  -> hook pid
# *f -> follow forks
##

## eg
# sto          - strace and show open files
# F= stof      - strace, follow all forks, and show open files
# R= S= sltef  - ltrace, show syscalls, follow works, enable extended filtering and show open operations, read operations and socket operations
# ..
##

## /*
#     actual functions and code follow
## */

## 01.05.2005, -18/09/2005 ( access/modify/change difference and coloring )
# recent - show most recent file, with stat(1) timestampt and a touch -t compatible timestampt
#
# P: [oldest=1|last=1] recent [files/dirs]
#
# $ recent file
# $ recent *
# $ IFS=$'\n' ; recent $( ls -c | tac ) -> recentdir() -> list from oldest to newest
# $  [lsa=-d] [finda=-maxdepth 2]  [rev=0] recentdir */
##

# ksh compatibility probs, IFS, $'..'
#function recentdir() { local OIFS=$IFS IFS=$'\n' ref=0
#	recent -- $( find ${1+"$@" } | ${ls:-ls} $lsa $ls_args ${1+"$@"} | tac )
#	IFS=$OIFS
#} ; alias rrecent=recentdir

recent(){ local have_args; [[ $1 ]] && have_args= || unset have_args
	stat ${1+"$@"} ${have_args- -- *} |
		awk -F'[\x27\x60 \t]+' -v way=$oldest$last$latest '/File:/ { file = $3 ; next }
		$3 ~ /[0-9][0-9]:/ {
			#printf "1 %s 2 %s 3 %s\n", $1, $2, $3
			# if (file ~ /(HEADER|FOOTER).html/) next
			# if (max < $2 " " $3) { print file, $2, $3; max = $2 " " $3; f = file } }
			if ($1 == "Access:") gsub(/^|$/, "\33[32m", $1 )
			else if ($1 == "Modify:") gsub(/^|$/, "\33[35m", $1 )
			else if ($1 == "Change:") gsub(/^|$/, "\33[37m", $1 )
			if ( ((way) ? New[ $1 ] > $2 " " $3 : Max[ $1 ] < $2 " " $3) ) {
				printf "\33[mnewer %s  %s [ %s ]   %s\n", $1, $2 " " $3, mktouch( $2 $3 ), file
				Max[ $1 ] = $2 " " $3 ; Max[ $1 , "file" ] = file
			}
		}
			
			END {   # touch_t = max; gsub(/[ :-]|\..*/, "", touch_t)
				# print "most recent:", f, max, substr(touch_t, 1, 12) "." substr(touch_t, 13)
				
				for (i in Max) {
					if (i ~ SUBSEP) continue
					##touch_t = Max[i] ; gsub(/[ :-]|\..*/, "", touch_t)
					printf "most recent %s-   %-24s  %s  %s\n\33[m",
						i , Max[ i , "file" ] , Max[ i ] , #touch_t
						mktouch( Max[i] )
						##substr( touch_t, 1, 12 ) "." substr(touch_t, 13)
				}
			}
			
		function mktouch( time ) {
			gsub( /[ :-]|\..*/, "", time )
			return substr( time, 1, 12 ) "." substr( time, 13 )
		}'
}

## 03.05.2005, 18/09/2005( modernization )
# xMP newgeneration prelimitary mplayer wrapper
#
# P: [t=] [grepv=match] [ga=-grep-args]  xMP  [dirs/files] [-- ext1 ext2 .. avi mpe?g] [-- mplayer_args .. -ao null]
##

alias xp=xMP xmp=xMP
xMP() {
	local t f m arg args  Args Files files ext exts h_mplayer IFS argmode Margs margs grepv=$grepv grep_args=$grep_args ; unset Args Files #_
	#-[[ $1 ]] && ${t-false} && t= || unset t
	#-[[ $@ ]] && h_A
	
	shopt -s | grep -q extglob   || shopt -s extglob dotglob #nullglob
	#shopt -s nullglob
	type -p mplayer.awk >&- && h_mplayer=
	[[ -n $grepv ]] && h_grepv=
	
	for arg; do
		[[ ! -n $arg ]] && continue
		[[ $arg == -- ]] && { (( argmode++ )) ; continue; }
		if   (( argmode == 1 )); then (( args++ )) ; Args=( ${Args:+"${Args[@]}"} "$arg" )
		elif (( argmode == 2 )); then Margs=( ${Margs:+"${Margs[@]}"} "$arg" ) ; echo marg: $arg
		elif (( ! argmode )); then 	Files=( ${Files:+"${Files[@]}"} "$arg" )
		fi
	done
	[[ $Args ]]  && for ext in "${Args[@]}" ; do exts=$exts$ext\| ; done ; exts=${exts%}
	[[ $Margs ]] && for m   in "${Margs[@]}"; do margs=$margs$m,\ ; done ; margs=${margs%, *} mm=${margs//,}
	[[ $Files ]] && for f   in "${Files[@]}"; do files=$files$f,  ; done ; files=${files%,}
	unset IFS
	#ls -At ${h_A+"$@"} ${h_A- *@(mpg|mpeg|avi|wm[av]|mp3|ogg|asf|mov|[aw][vi])} |
  eval	" ls -At ${Files+{$files\}}\*@(mpg|mpeg|avi|wm[av]|mp3|ogg|asf|mov|[aw][vi]) | "
  #\$\{Args+$\{exts\}\$\{Args:-'mpg\|mpeg\|avi\|wm[av]\|mp3\|ogg\|asf\|mov\|[aw][vi]'\}\}) |
  		eval ${h_grepv+grep -v $grep_args "\"$grepv\""} ${h_grepv-cat} |
		tr \\n \\0 |
	eval	xargs "--no-run-if-empty --verbose --null -n ${N:-66} -P ${P:-1} ${player:-mplayer}" $mm |
			${h_mplayer+mplayer.awk} ${h_mplayer- ${awk:-awk} -- "$(curl -s http://xmb.ath.cx/code/mplayer.awk)"}
}

### export related functions

# minimal self export function

exportme() {
	# local longnow=$( date +%F )
	
    export >"${TMPDIR-/var/tmp}"/exported  ;  .  "${TMPDIR-/var/tmp}"/exported
    
	${rmexport+rm -f}  mv  ${TMPDIR-/var/tmp}/exported{,.$longnow.$RANDOM}
	exported=1
}            

#exportgrep() { export | grep -Eo " ([a-zA-Z0-9]+)?(${gargs=$@})([^\"\x27]+)?=?.*"; }
exportgrep()  { export | grep -Eo " ([a-zA-Z0-9]+)?(${gargs=$@})([^=]+)?=.*"; }
exportawk()   { awk '/SHLVL=/,/ohnosTopme/ { print (/SHLVL=/) ? "" : $0 }' ${1+"$@"}; }

#lgrep() { zgrep -E "$@" /var/log/apache/access.log{,*} ~xmb/tethereal.out* &
#		  zgrep -A1 -B1 -E "$@" ~xmb/p0f.out*; wait $!; }

##
# code grep, strip comments out of (shell) code
# P: [empty=[01]] [Ccode=[01]] [;] cgrep [files]
#
# $ cgrep thing.awk thing.pl thing.sh -
##

#alias cgrep="awk '! /^[ \t]+#|^[ \t]+\$/ { if (/#/) sub(/#.*/, \"\"); if (\$1) print }'"
alias cgrep="awk -v p=$empty -v C=${Ccode-${C-$c}} '! /^[ \t]*([^\\\]|^)#/ { if (/#/) sub(/#.*/, \"\")
	if ((C||CM) && /([^\\\]|^)(\/\*|\*\/|\/\/)/) { print \"fuck\"; CM += sub(\"/\*/\", \"\")
			if (( tmp = sub(\"\*/\", \"\xFF\") )) { CM -= tmp; sub(/.*\xFF/, \"\") }
		sub(/\/\/.*/, \"\")
	}
	if (p || \$1)    print }'"

##
# touch arguments as file with a prepending 003 number prefix
#
# $ ntouch Welcome
# $ ntouch "This is some foolish test"
# $ ntouch "...and bye"
##

ntouch() { local n=$( printf "%03d" $((++ntouch)) ); ((ntouch++)); touch "$n $*" || ((ntouch--)); }

##
# indent html from scratch, w/o line count modifications
# needs http://xmb.ath.cx/code/htmlformat.awk and right adjusted path
#
# $ xx_html_indent www.apple.com
##

xx_html_indent() {
	[[ $1 == -D ]] && local debug=$2 && shift 2
	if [[ $1 == -n || $1 == -s ]]; then
		shift
		wget -qO- "$@" | less
		return
	fi
	
	[[ ! $@ ]] && echo need url as arg && return 1
	
	wget -qO- "$@" | ${awk-awk} -f ~xmb/code/htmlformat.awk -v DEBUG=$debug
}

##
# kill grepped procs, with normal signal or $SIG (has to include the dash)
#
# $ killproc cat
# $ SIG=-9 killproc perl
##

killproc() {
	[[ ! $@ ]] && echo need match args && return 1
	local x=$@

	pids=$( ps aux | grep -v grep | grep "$x" | awk '{ print $2 }' )
	[[ ! $pids ]] && echo nothing to kill && return
	kill $SIG $pids
	#kill -9 $pids
}

##
# resolve all tlds for one string/host using h, the adns alias
# and print error codes and seen resolved ips
#
# $ hh apple bogusporn
##

hh() { local host; export host
	[[ ! $tlds ]] && tlds=$(curl -s http://xmb.ath.cx/tlds) tlds=${tlds//[ $'\n']/,} tlds=${tlds//,,/,}
	#echo $tlds
	#echo "${tlds// /_}"
	#return
	for host; do echo NAME: $host; eval h $host.{$tlds}; done | awk '
		BEGIN { r = "/dev/stderr" }
		/^NAME: / { if (! old) old = $2; else old = NAME; NAME = $2 }
		/^;/ { err[$3, $4]++; next } $1 == c { nouse_Seen[$1]++; c = 0 }
		Seen[$1]++ { dup++; if (Seen[$1] == 2) diff++; Dup[$1] } $3 == "CNAME" { cname++; c = $NF }
		#{ if(/^;/) { olderr[$3]++; err[$3, $4]++ } else print }
		! /^NAME: / { print; seen++ }

		old != NAME { report() }
		END { report() }
		
		function report() { if (! NR) exit; fflush()
			printf "For \x27%s\x27, Total %d, printed %d",
				old, NR, seen >r # ENVIRON["host"], name
			if (cname) printf ", %d cnames", cname >r
			if (dup) printf ", %d duplicates (%d unique)", dup, diff >r
			printf "\n" >r
		for (i in err) { if (! x) { x = 1; printf "Errors: " >r }
			if (i ~ SUBSEP) { split(i, I, SUBSEP); printf "%s-%s:%s ", I[1], I[2], err[i] >r }
			else printf "%s:%s ", i, err[i] >r }
		if (x) printf "\n" >r; old = NAME }
		#function pn(s) { printf "%s'
}

##
# pseudo print the arguments as hex vars + echo command to expand them
#
# $ x_hex_print something here
#
# > i="73 6F 6D 65 74 68 69 6E 67 20 68 65 72 65"
# > eval echo -e \\\\x${i// /\\\\x}
##

function x_hex_print() {
        tmp=$(ascii -s "$*" | awk '{ sub(/0x/, "", $3); print $3 }')
        echo i=\"$tmp\"
        echo 'eval echo -e \\\\x${i// /\\\\x}'
}

##
# slashdot short, 'search' being gawk -f shernix.awk -f shernix_cli.awk "$@"
# xmb.ath.cx/code2/awk/shernix/
##

#function /.() { search slashdot | less -RU; }
function slashdot() { search slasdot | less -RU; }
#fix_X() { cp ~xmb/.Xauthority /root; }


##
# print pids related in any way to one pid
# not by me
#
# $ rpid $$
##

rpid() {
command ps -fe x | awk -v pid=$1 '
BEGIN{if(!pid){
 t="/dev/tty";printf "PID ? ">t;getline<t;pid+=$1
}}
function child(id  ,i){
 print line[id];if(id==pid)printf "\n"
 for(i in ppid) if(ppid[i]==id) child(i)
}
function parent(id  ,i){
 i=ppid[id]
 if(line[i]>"" && i!=id) buf=parent(i)"\n"line[i]
 return buf
}
$2==pid{++found}
{ppid[$2]=$3;line[$2]=$0}
END{if(found){
  print line["PID"]"\n"parent(pid)"\n";child(pid)
  	# xmb comment, parent(pid) and child(pid) can be removed at will
	# for the desired effect of not including parent or child procs
}}
'
}

#leo() {
#	[[ ! $@ ]] && return 1
#	
#	wget -O- -o /dev/null http://dict.leo.org/?search="$@" > $(mktemp) #|
	#awk -f ~xmb/awk/dict.leo.org.awk
	#http://dict.leo.org/?search=canoe
#}

##
# short for dict.leo.org dictionary lookups
#
# $ leo penetration
##

leo() {
	local search=$@ search=${search// /+}
	$(type -p elinks links{,2} w3m lynx | head -1) \
		dict.leo.org/?search="$search"
}

##
# debian /usr/share/doc changelog viewer
##

debdoc() {
	local docs=/usr/share/doc/
	local file=changelog.Debian.gz
	for i in "$@"; do
		if [[ -f $docs/$i/$file ]]; then
			zless $docs/$i/$file
		elif [[ -f $docs/${i//-*}/$file ]]; then
			zless $docs/${i//-*}/$file
		else
			local p=$docs/$i*
			[[ $p ]] && echo not matching: $i.. possibilities: $p
		fi
	done
}

##
# compare files of one archive with another
# yet no other help text here
##

cmp_archive() {
	tmp=$(mktemp)
	local src=$1

	shift

	if [[ $@ ]]; then
		tar cfz $tmp $src "$@"
	else
		tar cfz $tmp $src
	fi

	tar xfz $tmp -O | diff - <(tar xfz $src.tgz -O) &>/dev/null || local moo=$?

	rm -f $tmp
	return $moo
}

## .. 14/09/2005
# 
# general purpose simple backup
# copy tree's of files from one place to another
#
# P: [do_cp=[01]] [cp=prog] x_backup <from (with find args)> [to] [[same]cut regex]
# $ x_backup <from(find argument)> [<to>] [cut away text/regex from original path, or 'same' as $1]
#
# $ x_backup /lib /tmp/test same # copy over /lib to /tmp/test cutting away '/lib' (copy file structure over)
# $ do_cp=1 x_backup dira dirb dira # copy content of dira to dirb
##

x_backup_copy() {
  local from=$1 to=$2; shift 2 #cut=$3
  local IFS=$'\x02' # should not appear in filenames
  [[ $1 == same ]] && cut=$from

  while read src dst; do
    echo $src --\>\> "$to/$dst"
    
    [[ $do_cp ]] && {
      [[ ! -d $to/$dst ]] && mkdir -p $to/$dst
      ${cp=cp} -a "$src" "$to/$dst/" || { echo failed; (( do_fail )) && return 1; }
    }
  done < <( find $from -type f |
    awk -v SEP="$IFS" -v cut="$@" '{ printf "%s%s", $0, SEP
      sub(cut, ""); sub(/\/[^\/]+$/, "/"); print }' )
}

# backup /tmp
# do_cp=1 backup /lib /tmp/test same

###
## new 13/03/2005
## three new things
###

##
# make 'release' out of a project dir containing a 'release' dir
# with symlinks back to the original docs
##

#x_rel() ...

##
# sh/awk/similiar function grepper
# $ funcgrep <files or - for stdin or nothing>
# $ funcgrep awkinc functions.sh
##

funcgrep() {
	local search=$1; shift
	
	awk -v search=$search '($0 ~ "[ \t]*^(function)?[ \t*]*[A-z0-9_-]*" search "[A-z0-9_-]* *(.*)"), /^\}$/' $@
}

##
# simple make temp files wrapper
# name=myprog _mktemp <mktemp | tempfile arguments>
##

_mktemp() {
	mktemp $@ || tempfile $@ || echo ${TMP-/tmp/}${name-temp}.$$
}

## 13.03.2005 .. 09.04.2005, 1[67].04.2005, 25.04.2005, 10/09/2005 ( modernization of args )
## 30.05.2006 ( added new flexibility variables, extended functions by 11)
##
#
## like awklib, an
##
#
# advanced awk files/code/functions mix and include function
# wraps all defined elements in its pre and stu arrays, all argumented files and $_awk_inc
# wraps all in a var: defined elements in its pre and stu arrays, $_awk_inc and
#  $_awk_code passover vars, and valid files as argumens.. and executes awk without -f
# removed shinc for easier usage
#
# P: [awk=mawk] [_awk_inc=<code>] [_awk_code=<code>] [_awk_args=<args>]
#    [shinc=file] awkinc [awkfiles]
# printed in-awk code by the _bash(txt) function
# also a place to store universally useful awk functions
# will collect functions here!
#
# $ _awk_inc='BEGIN { print "success"; exit }' awkinc
# $ awk=gawk awkinc /usr/share/*awk*/{,*/{,*/{,*/}}*.awk
# $ awkinc your_file.awk
# $ shinc=/tmp/a _awk_inc='BEGIN { _bash("a=b"); exit }' awkinc
# \ source /tmp/a OR shinc=/tmp/a _source_inc
# $ _awk_inc='{ subawkinc ...
##

checknum() { [[ ! -n $1 || $1 == [0-9] || $1 == [0-9][0-9] || $1 == [0-9][0-9][0-9] ]] && return || return 1 ; }

gimme_local() { local n arr=$1; action='echo ${Work[entry//[$,-]/ }' array_work $1 $2; }

awkinc() {
	local tmp2 code pre fd=3 i dP dX es whole argmode Awk_Args # shinc=$1 ; shift
	unset dP dX es

	local awk_args awk_code
	awk_args=(
		FS  -F      0 1 0 0 
		RS  -vRS    = 1 0 0
		ORS -vORS   = 1 0 0
		OFS -vOFS   = 1 0 0
	)
	awk_code=( 
		BEGIN ''    0 0 'BEGIN { %s }' '$BEGIN'     
		END ''      0 0 'END { %s }' '$END' 
		code ''     0 0 '%s { %s }' '$code_match,$code'     
		sub  ''     0 0 'sub( %s, %s, %s )' '$sub,$sub_re,$sub_to'  
		gsub  ''    0 0 'gsub( %s, %s, %s )' '$gsub,$gsub_re,$gsub_to'      
		match ''    0 0 'match( %s, %s )' '$match_to,$match'        
		substr ''   0 0 'substr( %s, %s, %s )' '$substr_to,$substr_r,$substr_l'
    	)

	local $( gimme_local awk_args 0 ) $( gimme_local awk_code 5 )
	
	#[[ ! $shinc ]] && return 1
	
	tmp2=$( name=awkinc _mktemp )
	pre=(
'BEGIN { err = "/dev/stderr"; fd = "/dev/fd/" ENVIRON["fd"]; cmds = ENVIRON["tmp2"] }'
'function _bash(txt) { print txt >>cmds }' # >fd
'function warn(txt)  { print "[++] awkinc warning: ", txt >err }'
'BEGIN { formFS = "[ \t<>=]"; }' # split(" \" \' ", SEPS)
'function fsep(txt) { if (! txt) txt = $0 # findsep[arator]
	if (/^\"/) return "\""; else if (/^\x27/) return "\x27"
	if (/\"/) return "\""; else if (/^\x27/) return "\x27"
	return 0 }'
'function getv(sep, txt, Arr  ,rstart,rlength  ,re_match,exc  ,n1,n2  ,RSTART,RLENGTH) { if (! txt) txt = $0
	if (re_match) { match(txt, re_match); if (exc) { rstart = RSTART + n1
		rlength = RLENGTH + n2 } }
	if (rstart) txt = substr($0, rstart, (rlength) ? rlength : 666)
	return split(txt, Arr, sep) }'
'function getm( re,src  ,p1,m2  ,p2,m1 ) { if (! re) { re = ">[^<]+"; p1 = m2 = 1 }
	if (! src) src = $0 # ...
	return substr( $0, match( $0, re ) +p1-m1, +p2-m2 ) }'
'function getnum( pos,src  ,m,n,num) { if (! pos) pos =1; if (! src) src = $0; if (! m) m = "[0-9]+"

while (++n <= pos) { num = getm( m, src); sub(num, "", src) } return num }'
		
		#####
		#function fieldrev( num, do_it ) { return
		#
		#
		###### bash bug with quotes above, between the function
'function proctime(    tmp ) { getline tmp <"/proc/uptime"; tmp = substr( tmp, 1, match( tmp, / / ) )
	close( "/proc/uptime" ); return tmp }'
######
'function getcmd( cmd   ,lines,l,f    ,tmp,all ) { # , lines # l,f lines/field to return in while loop
	while ( (cmd | getline tmp ) >0 ) all = all tmp FS #"\n"
	close( cmd )
	return all }'
######
'function get_href( src   ,Arr,SEP   ,t,tt ) {
	if (! sep) sep = " " ; if (! src) src = $0
	t  = substr( src, match( src, /(href|s[rc][rc])=['\''"]?[^'\''">]+/ ) + 5, RLENGTH - 5 )
	sub(/^['\''"]/, "", t)
	src = "\xFF" substr( src, RSTART + RLENGTH )
	gsub( /\xFF[^>]+>|<\/a>.*/, "", src )
	#tt = substr( src, match( src, /\xFF[^>]+
	if (! ("valid" in Arr) ) return t SEP src
	else { Arr["url"] = t ; Arr["desc"] = src }
}'

'function newfile( file   ,ret ) { if (! file) file = FILENAME
	if (  _newfile_ == file ) return 0
	#if (  _new! _newfile_) 
	return _newfile_ = file
}'

###
# new
###

'function test_file( file   ,do_print,do_rm, str ) {
        #if (do_print && (print "test" >file) <0 ) return _err(0, "noprint: ", file)
        if (do_print) print "test" >>file
        if ( (getline t <file) <0 ) return _err(0, "nofile: " file)
        close(file)
        #if (! t) return _err(0, "novar: t from: " file)
        if (do_rm) system("rm '" file "'") # err:..
        return 1
}'

'function _err(code, str  ,std,noexit) {
  if(std) print str >std ; else print str
  if (! noexit) return code; else exit code
}'

'function date(    fmtime, cmd, out) {
        if (fmtime) cmd = "date '+" fmtime "'"
        else cmd = "date"
        cmd | getline out; close(cmd)
        return out
}'

'function sleep( time     ,noprint) {
        if (! noprint) printf "<sleeping> at %s - %d seconds\n", date(), time
        system("sleep " time)
}'


'function print_files_find( dir   ,f,ff,tf ) {
        f = format_t ; ff = format

        if (files_cut && dir ~ "/") sub(".*/", "", dir)
        sub("%dir", dir, f)
        # print f ..

        for (cat in Cat) {

                tf = f ; sub( "%matches", cat format_F gimme_last_entry( To, cat SUBSEP ) )
                printf "%s\n", tf

                if (pfiles) sweep_files_find( To, cat SUBSEP )
        }
}'

'function fill( src, dest, pre , stu    ,n,e) {
  #while (++n in src) if( fill_t) dest[ pre src[n] stu ] ; else dest[ pre n stu ] = src[n]
  #while (++n in src) { if(! Seen[r,src[n]]++) { if(src[n] == "`") src[n] = "" ; if( fill_t) dest[ pre src[n] stu ] ; else dest[ pre n stu ] = src[n] ; e++ } }                                                             while (++n in src) { if( src[n] ~ /^``/ ) { sub(/../, "", src[n] ) ; dest[pre n stu, 1] }  else if(src[n] == "`") src[n] = "" ; if( fill_t) dest[ pre src[n] stu ] ; else dest[ pre n stu ] = src[n] ; e++ }                                              return e
}'

'function mconv(num      ,n) {
        while (Size[++n]) {
                if (num / rsize(Size[n]) >= 1) # change to .1 to break to higher
                        return sprintf(format "%s", # <things>
                        num / rsize(Size[n]), Size[n + 1])
                n++
        }
}'

# if ** would work with non gawk, there wouldnt be that function
'function rsize(times    ,res) {
        res = 1
        do res *= base; while (--times)
        return res
}'

# see dig.awk for a complete script
'function lookup_dig(name    ,x, t_ips, t_ip, cmd, tt) {
        if (name ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]$/)
                return name

        cmd = ("dig " name)
        while (cmd | getline x) {
                if (x ~ /;; ANSWER SECTION:/)
                        while (x) {
                                cmd | getline x
                                split(x, X)
                                if (X[4] ~ /^A$|^AAAA$/ && X[5])
                                        t_ip[++tt] = X[5]
                        }
        } tt = 0; close(cmd)

        while (t_ip[++tt])
                if (! t_ip[tt + 1])
                        if (t_ips)
                                return t_ips ", " t_ip[tt]
                        else
                                return t_ip[tt]
                else
                        if (t_ips)
                                t_ips = t_ips ", " t_ip[tt]
                        else
                                t_ips = t_ip[tt]
}'

'function gimme_last_entry( Arr, preElement   ,num ) {
        while ( Arr[ preElement ++num ] ) { }
        return num-1
}'

'function mktab(times    ,i, ii, tmp) {
        while ( ++i <= times ) {
                tmp = tmp tab 
        }               
                
        return tmp
}'               

##
# /new
##
			
		######
		## x_db_prepare()
		##     _makeup()
		##     _fill(*)
		
			

		### damnit!!unfinished
	#	#'function mktxt1( fields, range1, range2    ,sep   ,f,F,i,n,res,r1,r2 ) {
	###	#	if (! sep) if (nosep || sep == 00) sep = ""; else sep = "\n"
	####	#	n = split(fields, F); while (++i <= n) res = res F[i] sep
	###	#	'
	##	
			#while (++n <= pos) { num = substr( src, match( src, m), RLENGTH); sub(num, "", src) } return num }'
		
		#'function vget(txt, which  ,sep,T) { split(txt, T, /=/); sub(/.*[ \t]/, "", T[which])
		#	#if (T[which+1] !~ /^[\"\x27]/) warn()
		#	if (! sep) fsep()
		#	if (! sub(/^[\"\x27]+/, "")) warn("vget field " which " (" T[which+1] ") not beginning with a quote"
		#	sub(
		#gsub(/
		#}'
		'function cut(field   ,stu1, stu2) { # stu as do stuffix, latter part/rest, in two steps
			if (! field) field = NF # hmm
			if (stu1) sub(/$/, "\xff", $field); else sub(/^/, "\xff", $field)
			if (stu2) sub(/\xff.*/, ""); else sub(/.*\xff/, "")
		}'
		# ANOTHER bash bug: }' on its own line
		#'function cut2(field  ,pre,src) { if (! src) src = $0
		#	return substr(src, (pre) ? 1 : length($field), (pre) ? 
		#		length( substr( src, .. nowork
		#
		'! noprint { print }' # by default, print all output
		#"$_awk_inc"
	)

	stu=(
		'BEGIN { if (exitonbegin) exit }'
	)
	
	export tmp2 fd
	
	for file; do    # arg modernization
		[[ $file == -- ]]  && (( ++argmode )) && continue
		(( argmode == 1 )) && Awk_Args=( ${Awk_Args:+"${Awk_Args[@]}"} "$file" ) && continue
		(( argmode >= 2 )) && echo "unknown arg: $arg" && continue
		
		file=${file%\}} # hmm
		#echo file -- $file --
		[[ -f $file ]] && code[i++]=$( <$file)
	done

	# code mixing
	func=$'\n'function
	wholecode="${pre[@]} ${code[@]//function/$func} $_awk_inc $awk_code $_ac ${stu[@]}"
	#awk "${pre[@]} ${code[@]}"
	
	# ah well
	(( noprint || np || _np || n )) && dP=
	(( space || perspace || s )) && es=
	(( exit || EX || ex )) && dX=
	
	#A && S
	#eval exec $fd\<\>$tmp2 # set/open fd
	#${awk=awk} ${FS+${es--F "$FS"}} -v noprint=${dP+1} -v exitonbegin=${dX+1} \
	${awk=awk} $( makeargvar "${awk_args[@]}" ) -v noprint=${dP+1} -v exitonbegin=${dX+1} \
		${_aa+"$_aa"} $_awk_args "$wholecode" ${Awk_Args:+"${Awk_Args[@]}"}
		#"${wholecode//function /$'\n'function /}" #"$wholecode"
	#A && T
	
	#awk -f $@ 3>$tmp
	#. $tmp
	[[ -f $shinc && -s $tmp2 ]] && _inline_inc $tmp2 >>$shinc
	#rm $tmp2
}

# autoinclude and source functions
_source_inc() { [[ -s $shinc ]] && { (( DEBUG )) && cat $shinc; . $shinc ; > $shinc; }; }
_inline_inc() { local file; for file; do echo ". $file ; rm $file"; done; }

### 22.03.2005
# treesplit - split files (ls -l) into dirs with a max per-dir-size limit
# P: [max=maxbyte] [to=destination] treesplit [data files]
# data files to be optional, ls -l output they have to be
#
# $ ls -l /tmp | treesplit
# $ ls -ARl ~  | treesplit
#
# -> /tmp/out/1/ tld_list
# -> /tmp/out/1/ tld_list.old
# -> /tmp/out/2/ xmbfunctions.sh
###

treesplit() {
	awk -v max=${max=$((1024**2 *20))} -v to=${to=/tmp/out} '
	/^\..*:$/ { Dir[++dir] = substr($0, 1, length - 1) "/" }
	$5 { if (i + $5 >= max) p(0); i += $5; cut(9); List[++n] = $0; List[n, DIR] = dir }
	
	function cut(field) { sub(/^/, "\xff", $field); sub(/.*\xff/, "") }
	function p(docut    ,x) { prun++; n = i = 0
		while (++x in List)  print to "/" prun "/", Dir[ List[x, DIR] ] List[x]
		if (docut) { cut(9); print to "/" prun "/", Dir[ dir ] $0 }
	} END { p() }' $@
}

### 23.03.2005
# ipcheck - check arguments to be valid ips
#           speed of around 600/s on 450MHz P2
#           with wrong octet count straight 1400/s+
#
# $  checkip 80.218.12.32 -1.23.43 apple.com 80.666.33.222
# $  checkip invalid.ip 2>&-
#
# -> 80.218.12.32
#    totally invalid: -1.23.43
#    totally invalid: apple.com
#    bad, 80.666.33.222 -> 2 666
#
###

checkip() { local ip Ip i run invalid
	for ip; do
		#(( run++ ))
		IFS=.; Ip=( $ip ); unset IFS
		(( ${#Ip[@]} != 4 )) && echo totally invalid: $ip >&2 && continue
		for (( i=0; i <= 3; i++ )); do
			#[[ ${Ip[i]} < 0 || ${Ip[i]} > 255 ]] && return $run
			(( ${Ip[i]} < 0 || ${Ip[i]} > 255 )) 2>&- &&
				echo bad${run:+ $run}, ${ip:0:15} -\> $((i+1)) ${Ip[i]} >&2 &&
				invalid=1 && break
			# (( .. )) && invalid=1 && break
		done
		(( invalid )) && invalid=0 || echo $ip
	done
}

### 24.03.2005
# prettypaste - pretty paste(1) files one line next to each other with
#               fold(1) width limiting
# P: [width=width] [sep=column sep] [psep=paste sep]
#    [doansi0=1] prettypaste [files]
#
# $ prettypaste fileA fileB
#
# -> <file1 | <file2
# -> <file1 | <file2 | <file3 ...
###

gen_fold() { local file args; [[ $width ]] && args=-w$width
	for file; do
		[[ $file == \<* ]] && continue # skip beginning with < args
		echo "<(fold $args \"$file\")"
	done
}

prettypaste() {
	local file sep psep #width
	[[ ! $sep ]]   && sep='|'
	[[ ! $psep ]]  && psep=$'\v'
	[[ ! $width ]] && width=40
	
	eval paste -d $psep $( width=$width gen_fold "$@" ) |
		awk -F $psep -v "w=$width" -v "sep=$sep" -v "ansi=$doansi0" '{
			for (i=1; i <= NF; i++) {
				fix(i)
				if (i == NF) printf "%s%s\n", $i, (ansi) ? "\33[m" : ""
				else printf "%-" w "s %s%s ", $i, sep, (ansi) ? "\33[m" : ""
			}
			#printf "%-" w "s %s %s\n", $1, sep, $2
		} function fix(field) {
			gsub(/^[ \t]*|\t*$/, "", $field)
		}'
}

alias ppaste=prettypaste pp=prettypaste

### 24.03.2005
# prettydiff - use prettyprint to list diff(1)s of a pair (two) of files
# P: [width=width] [sep=column sep] [diff=diff program] [diffargs=args]
#    [sf1=1] [sf2=1] [doansi0=1] prettydiff files
#
# $sf == $showfile; to control displaying of which of them
# best viewed in a BIG term
#
# $ prettydiff a b c d
#
###

prettydiff() {
	local Files count f1 f2 run #width
	[[ ! $width ]] && width=50
	[[ ! $diff && $(type colordiff) ]] && diff=colordiff

	Files=( "$@" ) count=${#Files[@]}
	while (( run +1 <= count )); do
		f1=${Files[run]} f2=${Files[run+1]}
		#prettypaste <( diff $diffargs "$f1" "$f2" ) $( gen_fold $( ((sf1)) && echo $f1 ) $( ((sf2)) && echo $f2 ) )
		prettypaste <( ${diff=diff} $diffargs "$f1" "$f2" ) "$( ((sf1))&&echo -n $f1 )" "$( ((sf2))&&echo -n $f2 )"

		(( run+= 2 ))
	done
}

alias pdiff=prettydiff

### 01/10/2005
### 02/10/2005 fixes
# mvlink - move symlinks (or other kind of find(1) -type <type> with pre/appended text - not "-in-filename safe
#
# P: [pre=txt] [stu=txt] [type=ftype(l)] [paths=paths]
#    [mv=prog] [mva=mv_args] [sh=shell_to_pipe_mv_commands]
#      mvlink [find args]
#
# common linux GNUfind(1) -type types
#
# b      block (buffered) special
# c      character (unbuffered) special
# d      directory
# p      named pipe (FIFO)
# f      regular file
# l      symbolic  link;  this  is never true if the -L option or the -follow option is in effect, unless the symbolic
#      link is broken.  If you want to search for symbolic links when -L is in effect, use -xtype.
# s      socket
# D      door (Solaris)

mvlink() { local pre stu t n
	local type=${type:-l} mv=${mv:-mv} mva=${mva-${mv_args--v}} sh=${SHELL:-sh} norun=${norun:-${no:-0}}
	local cut=${cut:-${CUT:-}} rep=${rep:-${REP:-}}
	
	unset t n
	[[ -n $pre || -n $stu ]] && t=
	(( norun )) && n=
	
	find ${paths} ${1+"$@"} -type $type |
	${t-false} \
	awk -F/ -v OFS=/ -v pre="$pre" -v stu="$stu" -v mv=$mv -v mv_args="$mva" -v cut="$cut" -v rep="$rep" '{
		file = $0 ; sub(/^/, pre, $NF) ; sub(/$/, stu, $NF) #; print "new", $0 >"/dev/stderr"
		if (cut) gsub( cut , rep )
		printf "%s %s \"%s\" \"%s\" \n", mv, mv_args, file, $0
	}' | ${n+cat} ${n-$sh}
		
		#tr \\n \\0 |
		#xargs $mv $mva
}

# convert utf8 to ascii

utf3ascii() {
	${awk:-awk} '{ gsub(/\010 /, " "); gsub(/\040/, " "); gsub(/\x08.|\137/, "") ; if ($1)print }' ${1+"$@"}
}

## 02/10/2005
#
# awkdiffsep - add missing data by the first dataset
# 
# P: [SEP=separator(SEP)] [field=field(0)]
#    [FS=field_sep_regex] [RS=record_sep_regex] [ORS=output_sep]
#      awkdiffsep
#
# $ echo foo:bar:bleh:ah:SEP:foo:bummmm
# -> bummmm
#
# echo $PATH SEP /usr/{,nonexist/,local/}{s,}bin: |
#   tr -d \ |
#   awk -v RS=[:\\n] -v ORS=: '{ if (/SEP/) { NR++; next } if (NR == FNR) S[ $1 ] ; else if (! ($1 in S)) print }' -

awkdiffsep() {
	local RS ORS FS SEP=${SEP:-${diffsep:-SEP}} field=${field:-${FIELD:-${match_field:-0}}}
	local h_ors ; [[ ! -n $ORS ]] && unset h_ors
	
	awk ${FS:+-F"$FS"} ${RS:+-v RS="$RS"} ${ORS:+-v ORS="$ORS"} -v SEP="$SEP" -v field=$field '{
		if( $0 ~ SEP ) { NR++; next }
		if (NR == FNR) S[ $field ] ; else if (! ($field in S)) print
	}' -
}

## 02/10/2005
#
# termactivity - show recent term activity
#
# P: [sleep=time(2)] [nostamp=do_it(0)] termactivity

termactivity() {
	local sleep=${sleep:-${SLEEP:-${wait:-2}}} nostamp=${nostamp:-${nodate:-0}}
	
	echo "recent term activity"
	while sleep $sleep ; do
		(( ! nostamp )) && date >&2
		w
	done | awk '{ m = $1 $2 $3; if( Set[ m] > $5 || ! Set[ m] ) { print ; Set[ m] = $5 } }'
}

## 15/10/2005
#
# awkxargs - fast multiple-arg flexible alternative to xargs
#
# P: [N=([01)(0)] [sh=shell(sh)] [sh_args=args] [max=max_args_at_once(200)] awkxargs <cmd> <base args> [-- <last args>]
#
# have_thread is =1 is threads.sh is found and sourced

awkxargs() { local cmd=$1 pre noact=${no:-${N:-0}} no_R sh=${sh:-${xargsshell:-${shell:-sh}}} sh_args; shift;
	(( noact )) && no_R= || unset no_R
	
        awk ${FS+-F "$FS"} ${null+-v RS="\\\0"} ${RS+-v RS="$RS"} \
        -v cmd="$cmd" -v base="$@" -v max=${max-200} \
        -v thread=$have_thread -v n=${noforkbg:-1} -v pre="$pre" '
#!/usr/bin/awk -f
BEGIN { if (pre) print pre }
NR % max == 1 {
	if (NR == 1) printf "%s %s ", (thread) ? ". threads.sh\nthread" : "", cmd
	else printf "%s %s\n%s %s ", base, (thread || n) ? "" : "&", (thread) ? "thread" : "", cmd
} END { printf "%s %s\n", base, (thread || n) ? "" : "&" }
{ printf "\"%s\" ", $0 }' |
	${no_R+cat} ${no_R-$sh $sh_args}

}

### awkxargs version 2 overloaded
### needs dynamical code

awkxargs2() { local cmd=$2 ; shift ; export out append pip grep
 ${awk:-..}
}

#noforkbg=1
#threads_max=3
#. threads.sh 2>&-

### ... - 30.05.2006
##
## array_work
##
## very nice function to work with variable array content
##
# P: [action=eval_action] [hook=hook_func] arr_work <arr> [field -1]
#
## %s%  -> field
## %s1% -> field +1
## %m1% -> field -1
## %all% -> all with $P prefix and $S stuffix printed

array_work() {
        local arr=${arr:-${1-Work}}
	local field=${field:-${2:-$(eval echo \${${arr}_field-0})}}} skip=${skip:-${3:-$(eval echo \${${arr}_skip-4})}} entry max Work
        local matchid match h_m pm sm action=${action:-echo %s%} ACT hook action #<! action
        local mfield pfield math_field=$(( pfield - mfield )) #minus/plus the main selected field
        local cur match_field=${match_field-${MF:-$field_}} #match_field_fuzzy
	local PF #printfield
        local MF=$match_field P S arr_work_local _ entrypos
        local DSPLIT toSPLIT SPLIT Split split
	local samechar=${samechar:-_same_} dosame=${dosame:-0} di

        eval "[[ -n \$${arr}_entries ]] && skip=\$${arr}_entries"
        eval Work=\( \"\${$arr[@]}\" \) # copy array, easier than evals everywhere
        max=${#Work[@]} # last +1 entry
        
        (( matchid )) && entry=$matchid
        (( entry += field )) # default: +0
        
        # this is quite slower with eval ${h_m+[[ code ]]}
        #[[ -n $match ]] || unset h_m #h_m=
        
        #while [[ $SPLIT && ${Split[split]} ||
        while [[ -n ${Work[ entry ]} ]]; do
                [[ -n $match && ${Work[ entry+MF]} != $pm${match}$sm ]] && {
                  (( entry += skip , (entry > max) )) && break
                  continue
                }
		
		(( dosame )) &&
		  di=-1 &&
		  while (( ++di <= skip )) ; do
		    [[ ${Work[di]} == $samechar ]] && Work[di]=${Work[di-1]}
		  done
		    

                #(( mentry && (entry -= mfield, entry += pfield) ))
                (( math_field && (entry += math_field) ))

                [[ $DSPLIT ]] && ! (( SPLIT )) && {
                        Split=( ${Work[ entry]//$DSPLIT/${toSPLIT:- }} )
                        Work[ entry]=${Split[0]}
                        SPLIT=1
                        #echo "splitted -- ${#Split[@]} -- ${Split[@]}"
                }
                
                cur=${Work[ entry]}

                #echo entry $entry / $cur

                #ACT=$action
                ACT=${action//\%s\%/${Work[ entry +PF]}} # s after \%
                
                [[ -n $hook ]] && $hook
                
                [[ ! -n $ACT ]] && ACT="echo \"${Work[ entry ]}\"" ||
                [[ $ACT != *%* ]] && : ||
                
                # run only when $action contains any %'es
                #[[ ${ACT//%s%} != *%* ]] && ACT=${ACT//%s%/${Work[ entry]}} || # %s% only speedup
                [[ $ACT == *%all%* ]] && ACT=${ACT//\%all\%/$( P=$P S=$S loop_arr $entry $skip )} #||
                
                # substitude it
                [[ $ACT == *%* ]] && {
                eval "ACT=\${ACT//\%"{\
s%/${Work[ entry]},\
m1%/${Work[ entry-1]},m2%/${Work[ entry-2]},\
s1%/${Work[ entry+1]},s2%/${Work[ entry+2]},s3%/${Work[ entry+3]},s4%/${Work[ entry+4]}}"}" #\;echo\ action=$action
                } 2>&-
                
                # work it
                eval "$ACT"

                (( SPLIT )) && [[ -n ${Split[++split]} ]] && {
			Work[ entry]=${Split[split]}
			continue
		} || SPLIT=0

		(( matchid )) || [[ -n $match ]] && break #return
		(( math_field && (entry += math_field) ))
                (( entry += skip , arr_work_local++ , arr_work++ ))
		#echo entry -- $entry/$skip
		(( entry >= max )) && break
		#echo entry \>= max check succeeed
	done
}

# for %all%
loop_arr() { local begin=$3 max=$(($1+$2)) sep=${sep:- } run loop_arr P S N #txt=${txt:-"\$run
        echo -n "arr($begin-$max) ->$sep"
        while (( begin <= max && ++run )) ; do
                #echo $begin \<= $max >&2
                #echo -n "$run:'${Work[begin]}'$sep" >&2
                echo ${N:+-n} $P${Work[begin]}$S
                (( begin++ ))
        done
} #// loop_arr()

### check_mac_foo
### very useful base var definition system''
#
### P: eval "$(check_vars 'var' '' '[def]' 'other' 'sub secondsub' '[def]')"

eval_vars() {
  local vars IFS=$'\n' i res n #split n res

  vars=( "$2" )

  while [[ ${vars[i]} ]] ; do
    #split=( ${vars[i]} ]]
    #split=${vars[i]}
    #while [[ ${split[n]} ]] ; do

    [[ -n ${vars[i+1]} ]] && n= || unset n

    res=$'\n'\${${vars[i]}=${n+\$\{${vars[i+1]//\}\$\{}\}}${vars[i+2]}}

    (( i += 3 ))

  done

  echo ": ${res//$'\n'/$'\n': }"
}

### P: in_arr text fields_to_echo "${array[@]}"

in_arr() { local n x match=$1 fields=$2 ; shift 2 
 for elem ; do
  [[ -n $x ]] && (( ++n <= fields )) && echo "$elem"
  [[ $elem == $match ]] && x=1
 done
}

###
# menu functions and array examples
###

Menu_actions=(
 #name #shell_action
)

RootMenu=( File Edit ) #RootMenu_skip=1
File=( new,New )
Edit=( copy paste )
New=( file dir )

#Menu_skip=1 #3
Menu=(
 #name #desc #type ## #action[dep.type,array] #optional_linkor_to_other_menu
 #name #desc[link] #type[thing]
 #name[,link]
)

showmenu() { local arr=$1 posX=$2 posY=$3 sub=${sub:->} pre=${pre:-|} stu space; shift 3
 echo -ne "\e[${posX}G${posY}H"
 eval _menu_pos_$arr=$posX,$posY
 
 skip=1 field=0 action='
  name=%1% link=${name#*,} name=${name%,*}
  echo -n "$pre$name"
  [[ -n $link ]] && echo -n "$sub"
  echo "$stu"
 ' array_work $arr
}

menustart() {
 showmenu $1

}

## /* end of most stuff */
#
# /* check argumented commands and execute now */
##

export have_xmb=100 xmb=\!+100+\!
export have_xmbfunctions=100 path_xmbfunctions=$0 path_xmbfunctions_pwd=$PWD

export LC_ALL=a

#alias hook=trap #/6\already\up\def[ine'd~~~

a gh=gimme_hooks gimme_hooks=gatherhooks gatherhooks=gettraps gettraps=get_traps
a rd=riddouble riddouble=rid_double rid_double=rmd
a  rmd=removedouble removedouble=rm_double rm_double=remove_doubles
a  remove_doubles=awk\\\\\ \\\\\!\\\\\ h\\\\\ \\\\\[\\\\\ $\\\\\ 0\\\\\]++
#  remove_doubles=awk\ \!\ h\ \[\ $\ 0\]++
#  remove_doubles=awk\ \'\ \!\ h\ [\ $\ 0]++\'

#.PRk=Ap~SW:.RTMΩAC%ǨkFOe~p<yCq˼Dx_ی

F get_traps( )
 {

 hook -p ${@-DEBUG}|
  rmd;} #/F\get_traps

#\original\debug\runway
#was:oneline%was:inputgathering;now:def+var+alias(func)
def odr=$( gh DEBUG)

#debugsignal for electronic hoes
#was:ds
#\electric\+hoes\runway
def er=\>\>\$PWD/\$histfile\ e\ \$BASH_COMMAND
#\;\ sleep\ 0.0000007s\&\&\ e\ \\e[m
#the\sleep\afterwards\doesnt\do\either
#zٛcyՆ>-܋Azpgq*1lQgy\aQUnhۢ.󙦾ŰHE2_Y
#4}\m\QjbN1_C+~k<=7"Jw0z:k/gCqa<Tlä׷C-^
#\e[m\instantly\after\doesnt\do\the\effects\for\'prpt'prompt!
#k5صB>ǃQCDe9!XbP/S.Ch;Qzk-c_Iɫ$alYA
#ts:DEBUG #ownt!ummwhydoesntitwritetothafileeh?itsknow#cnd;cmddoesntwork#worksperfetto#ts
#?&=4M,p-EÎ:_e"'AȲ>tdI+cQI@.WW֧7
###include#bash_builtin_check!

#A!61&Uz(1dqL4=egIu9@iѩWnDan:2;gNHrܺc

#\debug\runway
def dr=${er+$er;}$odr

if [[ $1 != . && $1 != source ]]; then ##source##

 hook "$dr" DEBUG

[[ $1  &&  ! $cmd ]] && {
	[[ $1 == eval ]] && { cmd=$1\ $2; shift 2; } || { cmd=$1; shift; }
}

[[ $cmd ]] && {
	if [[ $out ]]; then
		${doeval+eval} $cmd ${1+"$@"} >>$out
	else
		${doeval+eval} $cmd ${1+"$@"}
	fi
}

fi #//source##

hook "$dr" DEBUG

