aboutsummaryrefslogtreecommitdiff
path: root/build/mssql/mssql
blob: 863aa1ab9b609d55328ac877300c6498562b78d6 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/env bash

# file      : build/mssql/mssql
# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC
# license   : GNU GPL v2; see accompanying LICENSE file

#
# SQL Server driver wrapper.
#

opt=
driver=

while [ $# -gt 0 ]; do
  case $1 in
    --driver)
      driver=$2
      shift 2
      ;;
    --user)
      opt="$opt -U $2"
      shift 2
      ;;
    --password)
      opt="$opt -P $2"
      shift 2
      ;;
    --database)
      opt="$opt -d $2"
      shift 2
      ;;
    --server)
      opt="$opt -S $2"
      shift 2
      ;;
    *)
      break
      ;;
  esac
done

if [ -z "$driver" ]; then
  driver=sqlcmd
fi

opt="-x -r -b $opt"

if [ -n "$1" ]; then
  exec $driver $opt -i $1
else
  exec $driver $opt
fi