So, let's try to sort this out:
The case switch in lines 44 - 60 of DownloadUpdates.sh, version 9.5:
- Code: Select all
case "$OpSys" in
Linux)
#set working directory
cd $( dirname $(readlink -f "$0") )
;;
*BSD|Darwin)
echo "Operating System $OpSys not yet supported"
echo "Maybe something doesn't work as expected"
sleep 10
#set working directory
cd $( dirname $(readlink "$0") )
;;
*)
echo "unknown Operating System"
exit 1
;;
esac
can be replaced with all of this:
- Code: Select all
# Setting up the working directory:
#
# $0 is the script name, as it was typed on the command line;
# this may be an absolute or relative path name,
# and it may include symbolic links.
#
# $canonical_name is the real path name of the script.
#
# $prog_name is the file name of the script.
#
# $dir_name is the name of the enclosing directory.
#
# Explicitly evaluating these variables step-by-step
# will also help, should the path ever contain spaces.
case "$OpSys" in
Linux)
#set working directory
canonical_name=$(readlink -f "$0")
prog_name=$(basename "$canonical_name")
dir_name=$(dirname "$canonical_name")
cd "$dir_name"
;;
*BSD|Darwin)
echo "Operating System $OpSys not yet supported"
echo "Maybe something doesn't work as expected"
sleep 10
#set working directory
canonical_name=$(readlink "$0")
prog_name=$(basename "$canonical_name")
dir_name=$(dirname "$canonical_name")
cd "$dir_name"
;;
*)
echo "unknown Operating System"
exit 1
;;
esac
# Printing all variables for debugging:
if [ $debug -eq 1 ]; then
echo "script name: " "$0"
echo "canonical name: " "$canonical_name"
echo "file name: " "$prog_name"
echo "directory name: " "$dir_name"
echo "working directory: " "$(pwd)"
fi
The shell function
printheader() in lines 315 - 318 of DownloadUpdates.sh:
- Code: Select all
printheader() {
echo " "
head -20 "$0" | grep '^###'
}
can be replaced with this definition:
- Code: Select all
printheader() {
echo " "
head -20 "$canonical_name" | grep '^###'
}
I hope this helps,
Hartmut