bash-20130308 remove leftover and stray files

This commit is contained in:
Chet Ramey
2013-03-26 20:52:27 -04:00
parent c677e9e0a2
commit e632a17a4f
52 changed files with 0 additions and 43378 deletions
-24
View File
@@ -1,24 +0,0 @@
#! /bin/bash
#
# center - center a group of lines
#
# tabs in the lines might cause this to look a little bit off
#
#
width=${COLUMNS:-80}
if [[ $# == 0 ]]
then
set -- /dev/stdin
fi
for file
do
while read -r
do
printf "%*s\n" $(( (width+${#REPLY})/2 )) "$REPLY"
done < $file
done
exit 0
-137
View File
@@ -1,137 +0,0 @@
#
# shprompt -- give a prompt and get an answer satisfying certain criteria
#
# shprompt [-dDfFsy] prompt
# s = prompt for string
# f = prompt for filename
# F = prompt for full pathname to a file or directory
# d = prompt for a directory name
# D = prompt for a full pathname to a directory
# y = prompt for y or n answer
#
# Chet Ramey
# chet@ins.CWRU.Edu
type=file
OPTS=dDfFsy
succeed()
{
echo "$1"
exit 0
}
while getopts "$OPTS" c
do
case "$c" in
s) type=string
;;
f) type=file
;;
F) type=path
;;
d) type=dir
;;
D) type=dirpath
;;
y) type=yesno
;;
?) echo "usage: $0 [-$OPTS] prompt" 1>&2
exit 2
;;
esac
done
if [ "$OPTIND" -gt 1 ] ; then
shift $(( $OPTIND - 1 ))
fi
while :
do
case "$type" in
string)
echo -n "$1" 1>&2
read ans || exit 1
if [ -n "$ans" ] ; then
succeed "$ans"
fi
;;
file|path)
echo -n "$1" 1>&2
read ans || exit 1
#
# use `fn' and eval so that bash will do tilde expansion for
# me
#
eval fn="$ans"
case "$fn" in
/*) if test -e "$fn" ; then
succeed "$fn"
else
echo "$0: '$fn' does not exist" 1>&2
fi
;;
*) if [ "$type" = "path" ] ; then
echo "$0: must give full pathname to file" 1>&2
else
if test -e "$fn" ; then
succeed "$fn"
else
echo "$0: '$fn' does not exist" 1>&2
fi
fi
;;
esac
;;
dir|dirpath)
echo -n "$1" 1>&2
read ans || exit 1
#
# use `fn' and eval so that bash will do tilde expansion for
# me
#
eval fn="$ans"
case "$fn" in
/*) if test -d "$fn" ; then
succeed "$fn"
elif test -e "$fn" ; then
echo "$0 '$fn' is not a directory" 1>&2
else
echo "$0: '$fn' does not exist" 1>&2
fi
;;
*) if [ "$type" = "dirpath" ] ; then
echo "$0: must give full pathname to directory" 1>&2
else
if test -d "$fn" ; then
succeed "$fn"
elif test -e "$fn" ; then
echo "$0 '$fn' is not a directory" 1>&2
else
echo "$0: '$fn' does not exist" 1>&2
fi
fi
;;
esac
;;
yesno)
echo -n "$1" 1>&2
read ans || exit 1
case "$ans" in
y|Y|[yY][eE][sS])
succeed "yes"
;;
n|N|[nN][oO])
succeed "no"
exit 0
;;
*)
echo "$0: yes or no required" 1>&2
;;
esac
;;
esac
done
exit 1
-21
View File
@@ -1,21 +0,0 @@
#!/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
-27
View File
@@ -1,27 +0,0 @@
#! /bin/bash
#
# xterm_title - print the contents of the xterm title bar
#
# Derived from http://www.clark.net/pub/dickey/xterm/xterm.faq.html#how2_title
#
P=${0##*/}
[ -z "$DISPLAY" ] && {
echo "${P}: not running X" >&2
exit 1
}
if [ -z "$TERM" ] || [ "$TERM" != "xterm" ]; then
echo "${P}: not running in an xterm" >&2
exit 1
fi
exec </dev/tty
old=$(stty -g)
stty raw -echo min 0 time ${1-10}
echo -e "\033[21t\c" > /dev/tty
IFS='' read -r a
stty $old
b=${a#???}
echo "${b%??}"
exit 0
-26
View File
@@ -1,26 +0,0 @@
#! /bin/bash
#
# zprintf - function that calls gawk to do printf for those systems that
# don't have a printf executable
#
# The format and arguments can have trailing commas, just like gawk
#
# example:
# zprintf 'Eat %x %x and suck %x!\n' 57005 48879 64206
#
# Chet Ramey
# chet@po.cwru.edu
[ $# -lt 1 ] && {
echo "zprintf: usage: zprintf format [args ...]" >&2
exit 2
}
fmt="${1%,}"
shift
for a in "$@"; do
args="$args,\"${a%,}\""
done
gawk "BEGIN { printf \"$fmt\" $args }"