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.
|
||||
# Usage: own [USER] [FILES]
|
||||
function own() {
|
||||
local file="${2}"
|
||||
local IFS=$'\n'
|
||||
local files=("${@:2}")
|
||||
local user="${1}"
|
||||
|
||||
# default to current dir.
|
||||
if [ "${file}" = "" ]; then
|
||||
file='.'
|
||||
if [ "${files[*]}" = "" ]; then
|
||||
files=(".")
|
||||
fi
|
||||
|
||||
# default to current user.
|
||||
|
@ -15,9 +16,11 @@ function own() {
|
|||
user="${UID}"
|
||||
fi
|
||||
|
||||
# set ownership.
|
||||
chown "${user}":"${user}" -R "${file}" &> /dev/null
|
||||
for file in "${files[@]}"; do
|
||||
# set ownership.
|
||||
chown "${user}":"${user}" -R "${file}" &> /dev/null
|
||||
|
||||
# remove access from group and others.
|
||||
chmod -077 -R "${file}"
|
||||
# remove access from group and others.
|
||||
chmod -077 -R "${file}"
|
||||
done
|
||||
}
|
||||
|
|
Reference in a new issue