summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2016-10-31 21:07:43 +0100
committerPeter Palfrader <peter@palfrader.org>2016-10-31 21:07:43 +0100
commitc1424f11fab7a4c54f554403469b269de53f196b (patch)
tree8a96e28e9591aaa51b3efc0053f99846b301fcd3
parent5e3b9eaf1f64b285d3d67a2ca18302d898ae41cf (diff)
rvi: try to restore group ownership even as non-root
-rwxr-xr-xrvi5
1 files changed, 4 insertions, 1 deletions
diff --git a/rvi b/rvi
index 53ab1da..4b4e72d 100755
--- a/rvi
+++ b/rvi
@@ -56,6 +56,7 @@ if ! [ -e "$1,v" ] && ! [ -e "$DN/RCS/$BN,v" ] ; then
fi
owner="`stat -c "%u:%g" "$1"`"
+group=$(stat -c '%g' "$1")
rcsdiff -u "$1"
if [ $? -ne 0 ] ; then
echo
@@ -74,7 +75,9 @@ if [ $? -ne 0 ] ; then
exit 1
fi
if [ "$(id -u)" = "0" ]; then
- chown "$owner" "$1"
+ chown "$owner" "$1"
+elif ! chgrp "$group" "$1"; then
+ echo >&2 "Warning: group ownership was $group, but this could not be restored."
fi
$editor "$1"
ci -u "$1"