#!/bin/sh # ybcon start script EXENAME=ybcon # Default location of the executable defaultBinLocation=/opt/bin/ybcon usage() { echo "$EXENAME [-h|--help] [-p|--printresult] file" echo " -h or --help What you're seeing right now" echo " -p or --printresult Prints the transpilation result to stdout" } args=""; run=false; newArgs() { if [ "$args" = "" ]; then args="$args$1" else args="$args $1" fi } if [ "$#" != 0 ]; then for it in "$@" do case "$it" in -h | --help ) echo "Usage:" usage exit 0 ;; -p | --printresult ) newArgs "$it" shift ;; *.ybcon ) newArgs "$it" run=true break ;; * ) usage ;; esac done else usage fi runIt() { eval "$1" " $args"; } if [ "$run" = true ]; then if [ -f $defaultBinLocation ]; then runIt "$defaultBinLocation" elif [ -f ybcon ]; then runIt "./ybcon" fi fi