run.sh 280 B

123456789101112131415161718
  1. #!/usr/bin/env bash
  2. function _pgrep() {
  3. if ! [[ -x "$(command -v pgrep)" ]]; then
  4. # Set pgrep fallback
  5. ps axf | grep "$1" | grep -v grep | awk '{print $1}'
  6. else
  7. pgrep -f "$1"
  8. fi
  9. }
  10. function run {
  11. if ! _pgrep "$1" ;
  12. then
  13. $@&
  14. fi
  15. }