Commit 2deb3c37 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add confirm, assure_root, regexp_subst functions

parent 6aa42f5f
......@@ -38,7 +38,7 @@ epm_checksystem_ALTLinux()
epm_checksystem()
{
[ -n "$SUDO" ] || fatal "Do not use checksystem under root"
[ $EFFUID = "0" ] && fatal "Do not use checksystem under root"
case $DISTRNAME in
ALTLinux)
......
......@@ -304,6 +304,33 @@ __get_package_for_command()
esac
}
# TODO:
confirm() {
local response
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
assure_root()
{
[ "$EFFUID" = 0 ] || fatal "run me only under root"
}
regexp_subst()
{
local expression="$1"
shift
sed -i -r -e "$expression" "$@"
}
# TODO: we we can't use epm directly?
assure_exists()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment