summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-02-08 08:47:44 -0800
committerKaz Kylheku <kaz@kylheku.com>2020-02-08 08:47:44 -0800
commitaa96c75936b5421ad3a814d0fe45a1b4674deb7c (patch)
tree1fbef878311b1c1a8355563d9cea4461a6e1f150
parent14a611a0328f966122083a5a862c2ad4884dd252 (diff)
downloadtxr-aa96c75936b5421ad3a814d0fe45a1b4674deb7c.tar.gz
txr-aa96c75936b5421ad3a814d0fe45a1b4674deb7c.tar.bz2
txr-aa96c75936b5421ad3a814d0fe45a1b4674deb7c.zip
chmod: ugo perms sees effects from same clause.
This is Coreutils chmod behavior. * sysif.c (chmod_wrap): Sample cmode into oldm at the start of every assigment before punching the masked hole into cmode. * tests/018/chmod.tl: Breaking test case added.
-rw-r--r--sysif.c1
-rw-r--r--tests/018/chmod.tl1
2 files changed, 2 insertions, 0 deletions
diff --git a/sysif.c b/sysif.c
index 444f8326..638f9642 100644
--- a/sysif.c
+++ b/sysif.c
@@ -673,6 +673,7 @@ static val chmod_wrap(val target, val mode)
case chm_sub: cmode &= ~bits; break;
case chm_set:
if (cs == chm_perm) {
+ oldm = cmode;
cmode &= ~mask;
if (implicit_all || (who & CHM_O) != 0)
cmode &= ~S_ISVTX; /* GNU Coreutils 8.28 chmod behavior */
diff --git a/tests/018/chmod.tl b/tests/018/chmod.tl
index 93739c48..8cde28eb 100644
--- a/tests/018/chmod.tl
+++ b/tests/018/chmod.tl
@@ -46,3 +46,4 @@
(cht "-----x------" "=,a+X" "------------")
(cht "-----x------" "a-x+X" "------------")
(cht "------------" "u+x-X" "------------")
+(cht "------------" "o+x=o" "-----------x")