#!/bin/sh

# The contents of this file are subject to the MonetDB Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.monetdb.org/Legal/MonetDBLicense
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is the MonetDB Database System.
#
# The Initial Developer of the Original Code is CWI.
# Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
# Copyright August 2008-2015 MonetDB B.V.
# All Rights Reserved.

THIS=$0
THISDIR=${0%/*}
THISFILE=${0##*/}

#############################################################################
#	FUNCTIONS

function LOG1 () { prompt="# `date +%H:%M:%S` >  " ; { echo ; echo "$prompt" ; echo "$prompt$*" ; echo "$prompt" ; echo ; } >&2 ; }
function LOG2 () { LOG1 "$@" 2>&1 ; LOG1 "$@" ; }
 
function LOG1x () { LOG1 "$@" ; eval "$@" ; }
function LOG2x () { LOG2 "$@" ; eval "$@" ; }

#############################################################################
#	MAIN

ACTION=LOG2
while :; do
	case "$1" in
	-1)		ACTION=LOG1;;
	-1x | -x1)	ACTION=LOG1x;;
	-x | -2x | -x2)	ACTION=LOG2x;;
	-*)		;;
	*)		break;;
	esac
	shift
done

$ACTION "$@"

#	END
#############################################################################
