From e1d78bbe080539a70bb1aa99c118c9d875b1aa79 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sun, 10 Dec 2023 04:18:37 +0300 Subject: [PATCH] own : Fix support for multiple files. --- .config/bash/module/own.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.config/bash/module/own.sh b/.config/bash/module/own.sh index 903e27b..6029a11 100644 --- a/.config/bash/module/own.sh +++ b/.config/bash/module/own.sh @@ -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 }