mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-08-07 09:50:23 +00:00
tests+samples: Check for --help support to determine stat/sed tools flavor
Using the kernel name was not a good choice for determining which flavor (BSD vs. GNU) of stat, sed, and install was being used since one could install either one of them at least on MacOS. Instead, check whether --help is supported by these tools. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
c43003b954
commit
895df2c36e
@ -26,7 +26,7 @@ logerr()
|
||||
# @1: filename
|
||||
function get_filesize()
|
||||
{
|
||||
if [[ "$(uname -s)" =~ (Linux|CYGWIN_NT-) ]]; then
|
||||
if stat --help &>/dev/null; then
|
||||
stat -c%s "$1"
|
||||
else
|
||||
# OpenBSD
|
||||
|
||||
@ -735,7 +735,7 @@ function run_swtpm_bios()
|
||||
# @1: filename
|
||||
function get_filesize()
|
||||
{
|
||||
if [[ "$(uname -s)" =~ (Linux|CYGWIN_NT-|GNU) ]]; then
|
||||
if stat --help &>/dev/null; then
|
||||
stat -c%s "$1"
|
||||
else
|
||||
# OpenBSD
|
||||
@ -748,7 +748,7 @@ function get_filesize()
|
||||
# @1: filename
|
||||
function get_filemode()
|
||||
{
|
||||
if [[ "$(uname -s)" =~ (Linux|CYGWIN_NT-) ]]; then
|
||||
if stat --help &>/dev/null; then
|
||||
stat -c%a "$1"
|
||||
else
|
||||
# BSDs
|
||||
@ -761,7 +761,7 @@ function get_filemode()
|
||||
# @1: filename
|
||||
function get_fileowner()
|
||||
{
|
||||
if [[ "$(uname -s)" =~ (Linux|CYGWIN_NT-|GNU) ]]; then
|
||||
if stat --help &>/dev/null; then
|
||||
stat -c"%u %g" "$1"
|
||||
else
|
||||
# BSDs
|
||||
@ -774,7 +774,7 @@ function get_fileowner()
|
||||
# @1: filename
|
||||
function get_fileowner_names()
|
||||
{
|
||||
if [[ "$(uname -s)" =~ (Linux|CYGWIN_NT-|GNU) ]]; then
|
||||
if stat --help &>/dev/null; then
|
||||
stat -c"%U %G" "$1"
|
||||
else
|
||||
# BSDs
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ "$(uname -s)" =~ (Linux|CYGWIN_NT-) ]]; then
|
||||
if install --help &>/dev/null; then
|
||||
install -D "$1" "$2"
|
||||
else
|
||||
mkdir -p "$(dirname "$2")"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ "$(uname -s)" =~ (Linux|CYGWIN_NT-|GNU) ]]; then
|
||||
if sed --help &>/dev/null; then
|
||||
sed -i "$1" "$2"
|
||||
else
|
||||
sed -i '' "$1" "$2"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user