bash : own : wrap variables.
This commit is contained in:
parent
7e441512ef
commit
3e59bca232
|
@ -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.
|
||||
|
|
Reference in a new issue