diff options
author | Chet Ramey <chet.ramey@case.edu> | 2014-02-25 20:36:50 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2014-02-25 20:36:50 -0500 |
commit | 4539d736f1aff232857a854fd2a68df0c98d9f34 (patch) | |
tree | 841c9a36d28c9a4d61c1b2d79524ccbe5f5c5029 /examples/scripts.v2/shprof | |
parent | f281b8f4f8936b2713966274d9f8508a9f0910e4 (diff) | |
download | android_external_bash-4539d736f1aff232857a854fd2a68df0c98d9f34.tar.gz android_external_bash-4539d736f1aff232857a854fd2a68df0c98d9f34.tar.bz2 android_external_bash-4539d736f1aff232857a854fd2a68df0c98d9f34.zip |
prep for bash-4.3 release
Diffstat (limited to 'examples/scripts.v2/shprof')
-rw-r--r-- | examples/scripts.v2/shprof | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/examples/scripts.v2/shprof b/examples/scripts.v2/shprof deleted file mode 100644 index 73a1bb9..0000000 --- a/examples/scripts.v2/shprof +++ /dev/null @@ -1,66 +0,0 @@ -#! /bin/bash -# -# shprof - a line profiler for shell scripts -# -# adapted from a similar program included in `The New KornShell' by -# Bolsky and Korn and posted to usenet by bsh20858@challenger.fhda.edu -# -# converted to bash v2 syntax by Chet Ramey -# -TMPFILE=${TMP:-/tmp}/shprof$$ - -trap 'rm -f $TMPFILE' EXIT - -errexit() -{ - echo $0: "$@" >&2 - exit 1 -} - -# create script with profiling enabled -cat > $TMPFILE <<- \_EOF_ - declare -a _line - _profend() - { - case "$1" in - /*|./*) file="$1" ;; - *) file=$(type -path "$1") ;; - esac - - echo "*** line profile for $file ***" - i=1; - while read -r && [ $i -le $NLINE ]; do - count=${_line[$i]} - if [ "$count" -gt 0 ]; then - echo "[$count] $i: $REPLY" - fi - i=$((i + 1)) - done <$file -_EOF_ -# make the profiling script remove itself after printing line stats -echo "rm -f $TMPFILE" >> $TMPFILE -cat >> $TMPFILE <<- \_EOF_ - } - _command=$1 - shift - i=1 - NLINE=$(wc -l < "$_command") - while [ $i -le $NLINE ]; do - _line[$i]=0 - i=$((i + 1)) - done - unset i - trap "_profend ${_command}" EXIT - trap '_line[$LINENO]=$((${_line[$LINENO]} + 1))' DEBUG - LINENO=0 -_EOF_ - -case "$1" in -/*|./*) file=$1 ;; -*) file=$((type -path "$1")) ;; -esac - -cat "${file-$1}" >> $TMPFILE || errexit "${1}: cannot open" -chmod +x $TMPFILE - -exec -a "$file" $TMPFILE "$@" |