Created
September 13, 2016 09:11
-
-
Save ceving/bad44b3489bbbac66d17448713679e65 to your computer and use it in GitHub Desktop.
Annex one or more files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
set -eu | |
annex () | |
{ | |
local option | |
local OPTARG | |
local OPTIND | |
local recursive= | |
local user=${SUDO_UID:-$(id -ru)} | |
local group=${SUDO_GID:-$(id -rg)} | |
while getopts ':R' option; do | |
case $option in | |
R) recursive=-R;; | |
\?) echo "Invalid option -$OPTARG" >&2; return 1;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
for file; do | |
chown $recursive "$user:$group" "$file" | |
done | |
} | |
annex "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment