[__git] Simplify exporters.
Instead of using stat, we can rely on ls. Thanks to @ssrq for pointing that out.
This commit is contained in:
parent
e23e5ffa3c
commit
a837797ee3
2 changed files with 8 additions and 26 deletions
|
@ -1 +0,0 @@
|
|||
owner
|
6
cdist/conf/type/__git/explorer/group
Executable file
6
cdist/conf/type/__git/explorer/group
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
destination="/$__object_id/.git"
|
||||
|
||||
# See: cdist/conf/type/__file/explorer/stat
|
||||
ls -ld "$destination" | awk '{ print $4 }'
|
|
@ -2,28 +2,5 @@
|
|||
|
||||
destination="/$__object_id/.git"
|
||||
|
||||
action="$(basename "${0}")"
|
||||
|
||||
case $action in
|
||||
owner)
|
||||
bsd_fmt="%Su"
|
||||
linux_fmt="%U"
|
||||
;;
|
||||
group)
|
||||
bsd_fmt="%Sg"
|
||||
linux_fmt="%G"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
os="$(uname | tr '[:upper:]' '[:lower:]')"
|
||||
|
||||
case $os in
|
||||
*bsd)
|
||||
# Checked on OpenBSD, FreeBSD and NetBSD
|
||||
stat -f "${bsd_fmt}" "${destination}" 2>/dev/null || exit 0
|
||||
;;
|
||||
*)
|
||||
stat --print "${linux_fmt}" "${destination}" 2>/dev/null || exit 0
|
||||
;;
|
||||
esac
|
||||
# See: cdist/conf/type/__file/explorer/stat
|
||||
ls -ld "$destination" | awk '{ print $3 }'
|
||||
|
|
Loading…
Reference in a new issue