- Never check agains username, that's bad practice. Always use effective UID (#4894)
- Never write error messages and tracing info to stdout, that's bad practice too.
This commit is contained in:
parent
5195aad7d1
commit
957ff3981f
2 changed files with 15 additions and 15 deletions
|
@ -6,8 +6,8 @@
|
|||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
current_user=$(whoami)
|
||||
if [ $current_user != "root" ]; then
|
||||
current_userid=$(id -u)
|
||||
if [ $current_userid -ne 0 ]; then
|
||||
echo "$(basename "$0") uninstallation script requires superuser privileges to run"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -24,16 +24,16 @@ is_dotnet_host_installed(){
|
|||
}
|
||||
|
||||
is_dotnet_host_installed
|
||||
[ "$?" -eq 0 ] && echo "Unable to find dotnet installation to remove." \
|
||||
[ "$?" -eq 0 ] && echo "Unable to find dotnet installation to remove." >&2 \
|
||||
&& exit 0
|
||||
|
||||
remove_all
|
||||
[ "$?" -ne 0 ] && echo "Failed to remove dotnet packages." && exit 1
|
||||
[ "$?" -ne 0 ] && echo "Failed to remove dotnet packages." >&2 && exit 1
|
||||
|
||||
is_dotnet_host_installed
|
||||
[ "$?" -ne 0 ] && \
|
||||
echo "dotnet package removal succeeded but appear to still be installed. Please file an issue at https://github.com/dotnet/cli" && \
|
||||
echo "dotnet package removal succeeded but appear to still be installed. Please file an issue at https://github.com/dotnet/cli" >&2 && \
|
||||
exit 1
|
||||
|
||||
echo "dotnet package removal succeeded."
|
||||
echo "dotnet package removal succeeded." >&2
|
||||
exit 0
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
current_user=$(whoami)
|
||||
if [ $current_user != "root" ]; then
|
||||
echo "$(basename "$0") uninstallation script requires superuser privileges to run"
|
||||
current_userid=$(id -u)
|
||||
if [ $current_userid -ne 0 ]; then
|
||||
echo "$(basename "$0") uninstallation script requires superuser privileges to run" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -22,17 +22,17 @@ remove_dotnet_pkgs(){
|
|||
|
||||
for i in "${installed_pkgs[@]}"
|
||||
do
|
||||
echo "Removing dotnet component - \"$i\""
|
||||
echo "Removing dotnet component - \"$i\"" >&2
|
||||
pkgutil --force --forget "$i"
|
||||
done
|
||||
}
|
||||
|
||||
remove_dotnet_pkgs
|
||||
[ "$?" -ne 0 ] && echo "Failed to remove dotnet packages." && exit 1
|
||||
[ "$?" -ne 0 ] && echo "Failed to remove dotnet packages." >&2 && exit 1
|
||||
|
||||
echo "Deleting install root - $dotnet_install_root"
|
||||
rm -r "$dotnet_install_root"
|
||||
rm "$dotnet_path_file"
|
||||
echo "Deleting install root - $dotnet_install_root" >&2
|
||||
rm -rf "$dotnet_install_root"
|
||||
rm -f "$dotnet_path_file"
|
||||
|
||||
echo "dotnet packages removal succeeded."
|
||||
echo "dotnet packages removal succeeded." >&2
|
||||
exit 0
|
||||
|
|
Loading…
Reference in a new issue