Imported from ../bash-2.0.tar.gz.

This commit is contained in:
Jari Aalto
1996-12-23 17:02:34 +00:00
parent 726f63884d
commit ccc6cda312
502 changed files with 91988 additions and 69123 deletions

0
examples/scripts/bcsh.sh Normal file → Executable file
View File

19
examples/scripts/inpath Executable file
View File

@@ -0,0 +1,19 @@
#! /bin/sh
#
# Search $PATH for a file the same name as $1; return TRUE if found.
#
command=$1
[ -n "$command" ] || exit 1
set `echo $PATH | sed 's/^:/.:/
s/::/:.:/g
s/:$/:./
s/:/ /g'`
while [ $# -ne 0 ] ; do
[ -f $1/$command ] && exit 0 # test -x not universal
shift
done
exit 1

View File

@@ -0,0 +1,51 @@
#
# BASH VERSION OF nohup COMMAND
#
ctype()
{
path=$(builtin type -p $cmd | sed 1q)
if [ -n "$path" ]; then
echo "$path"
return 0
else
case "$cmd" in
*/*) [ -x "$cmd ] && { echo "$cmd" ; return 0; } ;;
*) case "$(builtin type -t $cmd)" in
"") return 1;;
*) echo "$cmd" ; return 0;;
esac ;;
esac
fi
return 1
}
trap '' HUP # ignore hangup
command=$(ctype "$1")
oldmask=$(umask)
umask u=rw,og= # default mode for nohup.out
exec 0< /dev/null # disconnect input
if [ -t 1 ]; then # redirect output if necessary
if [ -w . ]; then
echo 'Sending output to nohup.out'
exec >> nohup.out
else echo "Sending output to $HOME/nohup.out"
exec >> $HOME/nohup.out
fi
fi
umask "$oldmask"
# direct unit 2 to a file
if [ -t 2 ]; then
exec 2>&1
fi
# run the command
case $command in
*/*) exec "$@"
;;
time) eval "$@"
;;
*) "$@"
;;
esac

0
examples/scripts/precedence Normal file → Executable file
View File

25
examples/scripts/scrollbar Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
#
# scrollbar - display scrolling text
#
# usage: scrollbar args
#
# A cute hack originally from Heiner Steven <hs@bintec.de>
#
# converted from ksh syntax to bash v2 syntax by Chet Ramey
WIDTH=${COLUMNS:-80}
[ $# -lt 1 ] && set -- TESTING
# Posix.2 compatible printf command or bash loadable builtin
# in examples/loadables/printf
Text=$(printf "%-${WIDTH}s" "$*")
Text=$(echo "$Text" | tr ' ' '_')
while :
do
printf "%-.${WIDTH}s\r" "$Text"
LastC=$(expr "$Text" : '.*\(.\)$')
Text=$(printf "%-.${WIDTH}s" "$LastC$Text")
done

42
examples/scripts/vtree2 Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
#
# vtree - make a tree printout of the specified directory, with disk usage
# in 1k blocks
#
# usage: vtree [-a] [dir]
#
# Original posted to Usenet sometime in February, 1996
#
usage()
{
echo "vtree: usage: vtree [-a] [dir]" >&2
}
while getopts a opt
do
case "$opt" in
a) andfiles=-a ;;
*) usage ; exit 2 ;;
esac
done
shift $((OPTIND - 1))
export BLOCKSIZE=1k # 4.4 BSD systems need this
[ $# -eq 0 ] && set .
while [ $# -gt 0 ]
do
cd "$1" || { shift; [ $# -ge 1 ] && echo >&2; continue; }
echo -n "$PWD"
du $andfiles | sort +1f | sed \
's/\([^ ]*\) \(.*\)/\2 (\1)/
'"s#^$1##"'
s#[^/]*/\([^/]*\)$#|____\1#
s#[^/]*/#| #g'
[ $# -gt 1 ] && echo
shift
done

26
examples/scripts/zprintf Executable file
View File

@@ -0,0 +1,26 @@
#! /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 }"