bash : own : wrap variables.

This commit is contained in:
Dmitry Voronin 2023-10-29 18:27:32 +03:00
parent 7e441512ef
commit 3e59bca232

View file

@ -1,24 +1,24 @@
# change file ownership to specified user id and restrict access to him.
own()
{
local file="$2"
local user="$1"
local file="${2}"
local user="${1}"
# default to current dir.
if [ "$file" = "" ]; then
if [ "${file}" = "" ]; then
file='.'
fi
# default to current user.
if [ "$user" = "" ]; then
user="$UID"
if [ "${user}" = "" ]; then
user="${UID}"
fi
# set ownership.
chown "$user":"$user" -R "$file" &> /dev/null
chown "${user}":"${user}" -R "${file}" &> /dev/null
# remove access from group and others.
chmod -077 -R "$file"
chmod -077 -R "${file}"
}
# autocomplete.