#!/bin/sh
set -e || exit "$?"
test -d command/. || exit 0
echo 'Making command links in /command and /usr/local/bin'
home=
tmp=
command=
unset home tmp command
tmp=conf-compile/package_home
home=`sed q < "$tmp"`
case $home in
/*);;
*) echo "package/install_commands: $tmp must specify an absolute path."
exit 100;;
esac
dirname_() {
sed 's,^\(.*/\)[^/]*$,\1,' <<EOT
$1
EOT
}
basename_() {
sed 's,^.*/\([^/]*\)$,\1,' <<EOT
$1
EOT
}
sedarg_() {
sed "$1" <<EOT
$2
EOT
}
home=`sedarg_ 's,/*$,,' "$home"`
tmp=` dirname_ "$home"`
home=`basename_ "$home"`
home=$tmp`sedarg_ 's,-[0123456789].*$,,' "$home"`
cd command
for tmp in /command /usr/local/bin; do
test -d "$tmp"/. || mkdir "$tmp"
for command in *; do
test -f "$command" || continue
rm -f "$tmp/$command{new}"
ln -s "$home/command/$command" "$tmp/$command{new}"
mv -f "$tmp/$command{new}" "$tmp/$command"
done
done