diff options
author | Jari Aalto <jari.aalto@cante.net> | 1997-06-05 14:59:13 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:50 +0000 |
commit | d166f048818e10cf3799aa24a174fb22835f1acc (patch) | |
tree | 1ca27f9243900f8b236d0cde6a3862002aea9e19 /examples/scripts | |
parent | ccc6cda312fea9f0468ee65b8f368e9653e1380b (diff) | |
download | android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.tar.gz android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.tar.bz2 android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.zip |
Imported from ../bash-2.01.tar.gz.
Diffstat (limited to 'examples/scripts')
-rw-r--r-- | examples/scripts/spin.bash | 21 | ||||
-rwxr-xr-x | examples/scripts/vtree2 | 9 | ||||
-rw-r--r-- | examples/scripts/vtree3 | 99 |
3 files changed, 125 insertions, 4 deletions
diff --git a/examples/scripts/spin.bash b/examples/scripts/spin.bash new file mode 100644 index 0000000..dc6a66a --- /dev/null +++ b/examples/scripts/spin.bash @@ -0,0 +1,21 @@ +#!/bin/bash +# +# spin.bash -- provide a `spinning wheel' to show progress +# +# Chet Ramey +# chet@po.cwru.edu +# +bs=$'\b' + +chars="|${bs} \\${bs} -${bs} /${bs}" + +# Infinite loop for demo. purposes +while : +do + for letter in $chars + do + echo -n ${letter} + done +done + +exit 0 diff --git a/examples/scripts/vtree2 b/examples/scripts/vtree2 index 27649a1..62aa948 100755 --- a/examples/scripts/vtree2 +++ b/examples/scripts/vtree2 @@ -6,6 +6,7 @@ # usage: vtree [-a] [dir] # # Original posted to Usenet sometime in February, 1996 +# I believe that the original author is Brian S. Hiles <bsh29256@atc.fhda.edu> # usage() { @@ -32,10 +33,10 @@ do echo -n "$PWD" du $andfiles | sort +1f | sed \ - 's/\([^ ]*\) \(.*\)/\2 (\1)/ - '"s#^$1##"' - s#[^/]*/\([^/]*\)$#|____\1# - s#[^/]*/#| #g' + -e 's/\([^ ]*\) \(.*\)/\2 (\1)/' \ + -e "s#^$1##" \ + -e 's#[^/]*/\([^/]*\)$#|____\1#' \ + -e 's#[^/]*/#| #g' [ $# -gt 1 ] && echo shift diff --git a/examples/scripts/vtree3 b/examples/scripts/vtree3 new file mode 100644 index 0000000..2059b9f --- /dev/null +++ b/examples/scripts/vtree3 @@ -0,0 +1,99 @@ +#!/bin/ksh +# +# Name: dirtree +# Programmer: +# Hemant T. Shah +# Life Insurance Data Processing +# July 12 1994 +# +# Description: +# Print directory tree structure as follows: +# |___Mail +# |___scheduler +# |___cics_scripts +# |___tar_msdos +# |___awk +# |___attributes +# |___tmp +# |___News +# |___dosscsi +# |___FAQ_xterminal +# |___shell_history.Z +# |___FAQ_AIX +# |___aix_ftp_site +# |___hp_software +# |___dnload +# |___telnet.h +# |___msdos +# |___tnetd.tar.Z +# |___aix +# |___hp +# |___xkey.c +# +# Conversion to bash v2 syntax done by Chet Ramey +# - removed command substitutions calling `basename' +# + +ProgramName=${0##*/} +Path="." +ShowAll=1 +ShowDir=0 + + +ExpandDirectory() +{ +local object # Local variable + +cd "$1" + +for object in $PWD/.??* $PWD/* +do + if [ -d $object ]; # It is a directory + then + echo "${indent}|___${object##*/}/" + indent="${indent}! " # Add to indentation + if [ -x $object ]; + then + ExpandDirectory $object + fi + indent=${indent%????} # Remove from indentation + elif [ -e $object ]; then + if (( ShowAll == 1 )); + then + echo "${indent}|___${object##*/}" + fi + fi +done + +} + +usage() +{ + echo -e "Usage: $ProgramName [-h] [-f] [-d] [path] " + echo -e "\t-h ... display this help message." + echo -e "\t-f path ... shows all files and directories below path (default)." + echo -e "\t-d path ... shows all directories only below path." +} + +while getopts "fd" opt +do + case $opt in + f) ShowAll=1 ;; + d) ShowDir=1 ;; + *) usage ; exit 2;; + esac +done + +shift $(( $OPTIND - 1 )) + +Path=${1:-.} + +if [ ! -d "$Path" ]; then + echo "$0: error: specified path is not a directory." >&2 + exit 1 +fi + + + +echo "!$Path/" +ExpandDirectory $Path |