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