xbps-src: abstract away non-portable stat(1)
This implements semi-portable abstractions for both GNU and BSD flavors of stat.
This commit is contained in:
parent
4349108b68
commit
937272e967
6 changed files with 43 additions and 7 deletions
|
@ -1,5 +1,41 @@
|
|||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
# A portable abstraction for stat(1)
|
||||
#
|
||||
# The stat(1) command has different syntaxes between GNU flavor
|
||||
# and BSD flavor; implementations generally follow one or the other
|
||||
#
|
||||
if ! stat -c "%s" / > /dev/null 2>&1; then
|
||||
# BSD stat
|
||||
|
||||
stat_size() {
|
||||
stat -f %z "$1"
|
||||
}
|
||||
|
||||
stat_inode() {
|
||||
stat -f %i "$1"
|
||||
}
|
||||
|
||||
stat_mtime() {
|
||||
stat -f %m "$1"
|
||||
}
|
||||
else
|
||||
# GNU stat
|
||||
|
||||
stat_size() {
|
||||
stat -c %s "$1"
|
||||
}
|
||||
|
||||
stat_inode() {
|
||||
stat -c %i "$1"
|
||||
}
|
||||
|
||||
stat_mtime() {
|
||||
stat -c %Y "$1"
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
run_func() {
|
||||
local func="$1" desc="$2" funcname="$3" restoretrap= logpipe= logfile= teepid=
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue