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

This commit is contained in:
Jari Aalto 1997-06-05 14:59:13 +00:00
commit d166f04881
304 changed files with 14702 additions and 13012 deletions

View file

@ -25,5 +25,9 @@ _libdir=.
_dbgfile=$_tmpdir/bashdb$$ #temp file for script being debugged
cat $_libdir/bashdb.pre $_guineapig > $_dbgfile
exec bash $_dbgfile $_guineapig $_tmpdir $_libdir "$@"
if [ -f "$BASH" ]; then
exec $BASH $_dbgfile $_guineapig $_tmpdir $_libdir "$@"
else
exec bash $_dbgfile $_guineapig $_tmpdir $_libdir "$@"
fi
# end of bashdb

View file

@ -13,6 +13,7 @@ _steptrap() {
let " $_trace" &&
_msg "$PS4, line $_curline: ${_lines[$(($_curline-$_firstline+1))]}"
# if in step mode, decrement counter
let " $_steps >= 0" && let _steps="$_steps - 1"
@ -87,7 +88,7 @@ _at_linenumbp() {
if [ -z "${_linebp}" ]; then
return 1
fi
echo "${curline}" | egrep -s "(${linebp%\|})" >/dev/null 2>&1
echo "${_curline}" | egrep "(${_linebp%\|})" >/dev/null 2>&1
return $?
}
@ -95,11 +96,12 @@ _at_linenumbp() {
# search string brkpts to see if next line in script matches.
_at_stringbp() {
local l;
if [ -z "$_stringbp" ]; then
return 1;
fi
l=${_lines[$_curline-$_firstline+1]}
echo "${l} | egrep -s "*(${stringbp%\|})*" >/dev/null 2>&1
echo "${l}" | egrep "*(${_stringbp%\|})*" >/dev/null 2>&1
return $?
}
@ -132,9 +134,9 @@ _setbp() {
# list brkpts and break condition.
_listbp() {
_msg "Breakpoints at lines:"
_msg "$(echo $_linebp | tr '|' ' ')"
_msg "${_linebp//\|/ }"
_msg "Breakpoints at strings:"
_msg "$(echo $_stringbp | tr '|' ' ')"
_msg "${_stringbp//\|/ }"
_msg "Break on condition:"
_msg "$_brcond"
}

View file

@ -11,7 +11,7 @@ set -o history
set +H
# prompt for trace line
PS4=$1
PS4="${1}"
_dbgfile=$0
_guineapig=$1

View file

@ -0,0 +1,21 @@
# xalias - convert csh alias commands to bash functions
# from Mohit Aron <aron@cs.rice.edu>
# posted to usenet as <4i5p17$bnu@larry.rice.edu>
function xalias ()
{
if [ "x$2" = "x" ]
then
declare -f $1
else
echo $2 | egrep -q '(\!|#)'
if [ $? -eq 0 ]
then
comm=$(echo $2 | sed 's/\\!\*/\"$\@\"/g
s/\\!:\([1-9]\)/\"$\1\"/g
s/#/\\#/g')
else
comm="$2 \"\$@\""
fi
eval function $1 \(\) "{" command "$comm" "; }"
fi
}

View file

@ -166,6 +166,8 @@ pushd_builtin (list)
{
add_dirstack_element ((flags & NOCD) ? savestring (list->word->word) : current_directory);
dirs_builtin ((WORD_LIST *)NULL);
if (flags & NOCD)
free (current_directory);
return (EXECUTION_SUCCESS);
}
else
@ -186,7 +188,9 @@ popd_builtin (list)
long which;
int flags;
char direction;
char *which_word;
which_word = (char *)NULL;
for (flags = 0, which = 0L, direction = '+'; list; list = list->next)
{
if (ISOPTION (list->word->word, 'n'))
@ -206,6 +210,7 @@ popd_builtin (list)
builtin_usage ();
return (EXECUTION_FAILURE);
}
which_word = list->word->word;
}
else if (*list->word->word == '-')
{
@ -219,7 +224,7 @@ popd_builtin (list)
if (which > directory_list_offset || (directory_list_offset == 0 && which == 0))
{
pushd_error (directory_list_offset, list ? list->word->word : "");
pushd_error (directory_list_offset, which_word ? which_word : "");
return (EXECUTION_FAILURE);
}
@ -538,10 +543,12 @@ static char *pushd_doc[] = {
"directory. With no arguments, exchanges the top two directories.",
"",
"+N Rotates the stack so that the Nth directory (counting",
" from the left of the list shown by `dirs') is at the top.",
" from the left of the list shown by `dirs', starting with"
" zero) is at the top.",
"",
"-N Rotates the stack so that the Nth directory (counting",
" from the right) is at the top.",
" from the right of the list shown by `dirs', starting with"
" zero) is at the top.",
"",
"-n suppress the normal change of directory when adding directories",
" to the stack, so only the stack is manipulated.",

View file

@ -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

View file

@ -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

99
examples/scripts/vtree3 Normal file
View file

@ -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