##
##  curl.sh -- OpenPKG Tools "curl" command
##  Copyright (c) 2000-2012 OpenPKG GmbH <http://openpkg.com/>
##
##  This software is property of the OpenPKG GmbH, DE MUC HRB 160208.
##  All rights reserved. Licenses which grant limited permission to use,
##  copy, modify and distribute this software are available from the
##  OpenPKG GmbH.
##
##  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   determine path to OpenPKG instance
PREFIX="${OPENPKG_PREFIX}"

#   determine curl and config
curl="$PREFIX/lib/openpkg/curl"
conf="$PREFIX/etc/openpkg/curlrc"

#   remove user supplied -q option (ignore ~/.curlrc)
[ ".$1" = .-q ] && shift

#   force -q option (ignore ~/.curlrc) and -f option (error checking)
set -- "-q" "-f" "$@"

#   prepend --config <file> option if conf file is readable
declare -a a;
[ -r "$conf" ] && set -- "--config" "$conf" "$@"

#   execute underlying application
exec $curl "$@"

