commit: afe6c1a38ba79de509f9db060818dc3a561b13c2
parent a332cf0349ff942600f34fcef9775fd09b2bb67a
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 1 May 2024 03:07:49 +0200
test-cmd/chown.t: More robust cases based on file ownership rather than id(1) output
Diffstat:
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/test-cmd/chown.t b/test-cmd/chown.t
@@ -12,49 +12,50 @@
[1]
$ touch id_unchanged
- $ chown -v $(id -u):$(id -g) id_unchanged
+ $ chown -v $(ls -ld id_unchanged | awk '{print $3}') id_unchanged
chown: Ownership already set to \d+:\d+ for 'id_unchanged' (re)
$ rm id_unchanged
$ touch uid_unchanged
- $ chown -v $(id -u) uid_unchanged
+ $ chown -v $(ls -lnd uid_unchanged | awk '{print $3}') uid_unchanged
chown: Ownership already set to \d+:\d+ for 'uid_unchanged' (re)
$ rm uid_unchanged
$ touch name_unchanged
- $ chown -v $(id -un):$(id -gn) name_unchanged
+ $ chown -v $(ls -ld name_unchanged | awk '{print $3":"$4}') name_unchanged
chown: Ownership already set to \d+:\d+ for 'name_unchanged' (re)
$ rm name_unchanged
$ touch uname_unchanged
- $ chown -v $(id -un) uname_unchanged
+ $ chown -v $(ls -ld uname_unchanged | awk '{print $3}') uname_unchanged
chown: Ownership already set to \d+:\d+ for 'uname_unchanged' (re)
$ rm uname_unchanged
$ mkdir loop.d
$ ln -s ../loop.d/ loop.d/loop
- $ chown -v $(id -u) loop.d
+ $ chown -v $(ls -lnd loop.d | awk '{print $3}') loop.d
chown: Ownership already set to \d+:\d+ for 'loop.d' (re)
- $ chown -v $(id -u) loop.d/loop
+ $ chown -v $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
- $ chown -v -h $(id -u) loop.d/loop
+ $ chown -v -h $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
- $ chown -v -R $(id -u) loop.d
+ $ chown -v -R $(ls -lnd loop.d/ | awk '{print $3}') loop.d
chown: Ownership already set to \d+:\d+ for 'loop.d' (re)
chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
- $ chown -v -R $(id -u) loop.d/loop
+ $ chown -v -R $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
- $ chown -v -R -P $(id -u) loop.d/loop
+ $ chown -v -R -P $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
- $ chown -v -R -H $(id -u) loop.d/loop
+ $ chown -v -R -H $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
chown: Ownership already set to \d+:\d+ for 'loop.d/loop/loop' (re)
- $ chown -v -R -L $(id -u) loop.d/loop >/dev/null 2>/dev/null
- [1]
+ Non-portable, meanwhile adding a depth limit on chown itself could be rather limiting…
+ $ chown -v -R -L $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop >/dev/null 2>/dev/null
+ [1]
$ rm -r loop.d
$ touch grp_unchanged
- $ chown -v :$(id -gn) grp_unchanged
+ $ chown -v $(ls -ld grp_unchanged | awk '{print ":"$4}') grp_unchanged
chown: Ownership already set to \d+:\d+ for 'grp_unchanged' (re)
$ rm grp_unchanged