Skip to content

Commit

Permalink
fs-own: add --me for current user to take ownership
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Lupton <b@lupton.cc>
  • Loading branch information
balupton committed Mar 17, 2024
1 parent 4a82a5f commit c726bd1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion commands/fs-own
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ function fs_own() (
--permissions=<permissions>
sets file and directory permissions
--me
if provided, will set yourself as the owner.
--admin
if provided, will use the platform specific admin values.
Expand Down Expand Up @@ -102,6 +105,7 @@ function fs_own() (
local option_owner=''
local option_user=''
local option_group=''
local option_me='no'
local option_admin='no'
local option_permissions=''
local option_directory_permissions='' # deprecated
Expand All @@ -121,6 +125,9 @@ function fs_own() (
'--no-changes'* | '--changes'*)
option_changes="$(get-flag-value --affirmative --fallback="$option_changes" -- "$item")"
;;
'--no-me'* | '--me'*)
option_me="$(get-flag-value --affirmative --fallback="$option_me" -- "$item")"
;;
'--no-admin'* | '--admin'*)
option_admin="$(get-flag-value --affirmative --fallback="$option_admin" -- "$item")"
;;
Expand Down Expand Up @@ -177,7 +184,11 @@ function fs_own() (
fi

# adjustments: admin
if test "$option_admin" = 'yes'; then
if test "$option_me" = 'yes' -a "$option_admin" = 'yes'; then
help "--me and --admin cannot both be provided"
elif test "$option_me" = 'yes'; then
option_user="$(whoami)"
elif test "$option_admin" = 'yes'; then
if is-mac; then
option_user="$(whoami)"
option_group='admin'
Expand Down

0 comments on commit c726bd1

Please sign in to comment.