File: foreman-runner

package info (click to toggle)
ruby-foreman 0.90.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 584 kB
  • sloc: ruby: 2,020; sh: 88; makefile: 8
file content (41 lines) | stat: -rwxr-xr-x 625 bytes parent folder | download | duplicates (6)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
#
#/ Usage: foreman-runner [-d <dir>] [-p] <command> [<args>...]
#/
#/ Run a command with exec, optionally changing directory first

set -e

error() {
  echo $@ >&2
  exit 1
}

usage() {
  cat $0 | grep '^#/' | cut -c4-
  exit
}

read_profile=""

while getopts ":hd:p" OPT; do
  case $OPT in
     d) cd "$OPTARG" ;;
     p) read_profile="1" ;;
     h) usage ;;
    \?) error "invalid option: -$OPTARG" ;;
     :) error "option -$OPTARG requires an argument" ;;
  esac
done

shift $((OPTIND-1))

[ -z "$1" ] && usage

if [ "$read_profile" = "1" ]; then
  if [ -f .profile ]; then
    . ./.profile
  fi
fi

exec "$@"