fix missing bold for your account item
[brisk.git] / bin / restarter.sh
1 #!/bin/bash
2 # set -x
3 cd "$PWD" 2>/dev/null
4 dirnm="$PWD"
5 cwd_old="$(ls -i -d "$dirnm" | cut -d ' ' -f 1)"
6 pid_exe=""
7 while true; do
8     if [ "$pid_exe" = "" ]; then
9         sleep 2
10         cd "$dirnm" 2>/dev/null
11         "$@" &
12         pid_exe="$!"
13     fi
14     sleep 1
15     kill -0 $pid_exe >/dev/null 2>&1
16     if [ $? -ne 0 ]; then
17         echo "Process not present"
18         exit 0
19     fi
20     for tloop in 1 2 3 4 5; do
21         cwd_cur="$(ls -i -d "$dirnm"  2>/dev/null | cut -d ' ' -f 1)"
22         if [ "$cwd_cur" ]; then
23             break
24         fi
25         sleep 1
26     done
27     if [ $tloop -eq 5 ]; then
28         echo "Unavailable current working directory"
29         exit 1
30     fi  
31     if [ "$cwd_cur" != "$cwd_old" ]; then
32         kill $pid_exe
33         wait $pid_exe
34         echo "WAIT EXIT: $?"
35         pid_exe=""
36     fi
37     cwd_old="$cwd_cur"
38 done
39