own : Fix support for multiple files.
This commit is contained in:
parent
6faa880231
commit
e1d78bbe08
|
@ -2,12 +2,13 @@
|
||||||
# Root user by default. This directory recursively by default.
|
# Root user by default. This directory recursively by default.
|
||||||
# Usage: own [USER] [FILES]
|
# Usage: own [USER] [FILES]
|
||||||
function own() {
|
function own() {
|
||||||
local file="${2}"
|
local IFS=$'\n'
|
||||||
|
local files=("${@:2}")
|
||||||
local user="${1}"
|
local user="${1}"
|
||||||
|
|
||||||
# default to current dir.
|
# default to current dir.
|
||||||
if [ "${file}" = "" ]; then
|
if [ "${files[*]}" = "" ]; then
|
||||||
file='.'
|
files=(".")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# default to current user.
|
# default to current user.
|
||||||
|
@ -15,9 +16,11 @@ function own() {
|
||||||
user="${UID}"
|
user="${UID}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for file in "${files[@]}"; do
|
||||||
# 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}"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue