#!/bin/bash
#---------------------------------------------------------------------
##
## @Synopsis Functions for OS compatibility.
##
##
## This file contains functions that improve system compatibility.
##
##
## @Copyright Copyright 2019 by the Source Mage Team
##
#---------------------------------------------------------------------

# basic install replacement
if ! type install >/dev/null 2>/dev/null; then
  install() {
    local o=0 g=0 m=644 d
    while case "$1" in
	    -o|-g|-m) eval ${1#-}'="$2"'; shift;;
	    -p|-D) ;; # always
	    -d|-v) eval ${1#-}=1 ;;
	    *) false ;;
	    esac
    do shift; done
    if [ -n "$d" ]; then
      mkdir -p "$1"
    else
      mkdir -p "${2%/*}"
      rm -f "$2"
      cp "$1" "$2"
      chmod "$m" "$2"
      chown "$o:$g" "$2"
      touch -r "$1" "$2"
    fi
  }
fi
