summaryrefslogtreecommitdiff
path: root/t
blob: 73ad51d2a61c6758c852decf284d11e25c43bb45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

unset SPAWN

while getopts "t:r:a:" o; do case "${o}" in
  t)
    if pgrep -Uzachir -x "$OPTARG" >/dev/null 2>&1; then
      pkill -Uzachir -x "$OPTARG"
      exit
    else
      SPAWN="$OPTARG"
    fi
    ;;
  r)
    if pgrep -Uzachir -x "$OPTARG" >/dev/null 2>&1; then
      pkill -Uzachir -x "$OPTARG"
    fi
    SPAWN="$OPTARG"
    ;;
  a)
    ARGS="$ARGS$OPTARG "
    ;;
esac done

sleep 0.1
[ -n "$SPAWN" ] && exec "$SPAWN" $ARGS &