#!/command/execline

# This is my svstopsync script, written in execline syntax.
# Pretty cute, in a way.

import PATH
export PATH /package/host/skarnet.org/skaembutils/command:${PATH}

forbacktick -pd "" i ~dollarat ~-d ~ ;
  ~backtick ~-n ~name ~~basename ~~$i ~;
  ~if ~~test ~~\\\\${name} ~~!= ~~svlog ~;
  ~cd ~/service/${name}
  ~foreground ~~minrmrf ~~/service/${name} ~;
  ~foreground ~~if ~~~svok ~~~. ~~; ~~svc ~~-xd ~~. ~;
  ~ifthenelse ~~if ~~~test ~~~-d ~~~log ~~; ~~svok ~~log ~;
    ~~foreground
      ~~~if ~~~-n ~~~~npt-svwaitexit ~~~~30 ~~~~. ~~~;
      ~~~foreground ~~~~svc ~~~~-k ~~~~. ~~~;          # Ain't tildas cool ?
      ~~~npt-svwaitexit ~~~5 ~~~.
    ~~;
    ~~foreground ~~~svc ~~~-xd ~~~log ~~;
    ~~if ~~-n ~~~npt-svwaitexit ~~~30 ~~~log ~~;
    ~~foreground ~~~svc ~~~-k ~~~log ~~;
    ~~npt-svwaitexit ~~5 ~~log
  ~;
    ~~if ~~-n ~~~npt-svwaitexit ~~~30 ~~~. ~~;
    ~~foreground ~~~svc ~~~-k ~~~. ~~;
    ~~npt-svwaitexit ~~5 ~~.
  ~;
;
wait ;

# Disgusted ? Just stick to the execlineb syntax.
