2
# Copyright (C) 2004 Aaron Bentley
4
# See the file "COPYING" for further information about
5
# the copyright and warranty status of this work.
10
*) readlink_f "$1/$2";;
16
readlink_qualify `dirname -- "$1"` `readlink "$1"`
22
# Get directory where this script resides -- allows systemwide installation.
23
test -z "$abadir" -a -f "$HOME/.aba/aba-lib" && abadir="$HOME/.aba"
24
test -z "$abadir" && abadir=$(dirname $(readlink_f "$0"))
25
test -f "$abadir/aba-lib" || {
26
echo "* Can't find aba-lib. Please set abadir to wherever it resides." >&2
30
abaname=$(basename $0)
34
[ -z "$cmd" ] || shift
35
if tmp=`tla tree-root 2>/dev/null`; then treeroot=$tmp; fi
37
if [ -n "$treeroot" -a -f "$treeroot/{arch}/++options/$cmd" ]; then
38
prefix=`cat "$treeroot/{arch}/++options/$cmd"`
39
elif [ -f ~/.aba/options/$cmd ]; then
40
prefix=`cat ~/.aba/options/$cmd`
41
elif [ -f "$abadir/options/$cmd" ]; then
42
prefix=`cat "$abadir/options/$cmd"`
45
if [ -f ~/.aba/aliases ]; then
46
aliaschar=$(grep '^[ ]*aliaschar=.*' <~/.aba/aliases)
47
eval "$aliaschar" # So we honor quoting
48
aliaschar=${aliaschar:-^} # With zsh's extended globbing, ^ is no good choice.
51
if [ -n "$aliaschar" ]; then
54
echo 'Aliaschar "*" '"won't work." >&2
58
sed "s:[\$]:\\\\\$:g;s:\\$aliaschar:\$:g" <<EOS
68
sed "s:[\$]:\\\\\$:g;s:$aliaschar:\$:g" <<EOS
74
# This runs in subshell due to round brackets.
76
if [ -n "$treeroot" ]; then
77
if [ -f $treeroot/++aliases ]; then
82
eval "printf '%s' \"$(prepare_alias "$1")\""
85
# Spacewise correct expand-aliases, inline
86
# Well, actualy it's not correct for arguments that are expanded, but
87
# I don't know how to do that (command-substitution is not correct).
91
$aliaschar$aliaschar*)
94
arg=$(expand_alias "$arg")
96
*) set -- "$@" "$arg";;
101
if [ ! -z "$cmd" ] && [ -x ~/.aba/commands/$cmd ] && [ ! -d ~/.aba/commands/$cmd ]; then
102
# echo ~/.aba/commands/$cmd exec $prefix "$@"
103
~/.aba/commands/$cmd exec $prefix "$@"
104
elif [ ! -z "$cmd" ] && [ -x "$abadir/commands/$cmd" ] && [ ! -d "$abadir/commands/$cmd" ]; then
105
# echo "$abadir/commands/$cmd" exec $prefix "$@"
106
"$abadir/commands/$cmd" exec $prefix "$@"
108
# echo tla $cmd $prefix "$@"
109
if [ -n "$ABAFILTER" ]; then
112
tla $cmd $prefix "$@" | $ABAFILTER
114
tla $cmd $prefix "$@"
117
# arch-tag: aba by Aaron Bentley (12:14 Jan 15, 2004)