浏览代码

clean up script base

tags/v1.4.20
Jonathan Cobb 4 年前
父节点
当前提交
6b7ef000a0
共有 1 个文件被更改,包括 30 次插入26 次删除
  1. +30
    -26
      bin/bubble_common

+ 30
- 26
bin/bubble_common 查看文件

@@ -2,8 +2,8 @@
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
function die {
if [[ -z "${SCRIPT}" ]] ; then
function die() {
if [[ -z "${SCRIPT}" ]]; then
echo 1>&2 "${1}"
else
echo 1>&2 "${SCRIPT}: ${1}"
@@ -11,60 +11,64 @@ function die {
exit 1
}

function handle_help_request () {
function handle_help_request() {

if [[ -z "${2}" ]] ; then
if [[ -z "${2}" ]]; then
return
fi

if [[ ${2} == "-h" || ${2} == "--help" ]] ; then
if [[ ${2} == "-h" || ${2} == "--help" ]]; then
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ ${line} =~ ^#.* ]] ; then
if [[ ! ${line} =~ ^#!/bin/bash.* ]] ; then
if [[ ${line} =~ ^#.* ]]; then
if [[ ! ${line} =~ ^#!/bin/bash.* ]]; then
echo "${line}"
fi
else
break
fi
done < "${1}"
done <"${1}"
exit 1
fi

}

function make_temp () {
function make_temp() {
prefix="${1}"
suffix="${2}"
echo "$(mktemp ${prefix}.${suffix}.XXXXXXXX)"
}

function make_temp_dir () {
function make_temp_dir() {
prefix="${1}"
suffix="${2}"
echo "$(mktemp -d ${prefix}.${suffix}.XXXXXXXX)"
}

function quote_args () {
args=""
for i in "$@"; do
if [[ "$i" =~ \ |\' ]] ; then
i="${i//\\/\\\\}"
args="$args \"${i//\"/\\\"}\""
else
args="$args ${i}"
fi
done
echo -n ${args}
function quote_args() {
args=""
for i in "$@"; do
if [[ "$i" =~ \ |\' ]]; then
i="${i//\\/\\\\}"
args="$args \"${i//\"/\\\"}\""
else
args="$args ${i}"
fi
done
echo -n ${args}
}

handle_help_request ${0} ${1}
handle_help_request "${0}" "${1}"

# Ensure we can find run.sh
if [[ -z "${BUBBLE_SCRIPTS}" ]] ; then
RUN_SH="$(find $(cd $(dirname ${0}) && pwd) -type f -name "run.sh" | head -1)"
BC_DIR="$(cd "$(dirname "${0}")" && pwd)"
RUN_SH="$(find "${BC_DIR}" -type f -name "run.sh" | head -1)"
if [[ -z "${RUN_SH}" ]] ; then
RUN_SH="$(find . -type f -name "run.sh" | head -1)"
fi
if [[ -z "${RUN_SH}" ]] ; then
RUN_SH="$(find ${BC_DIR}/../../bubble -type f -name "run.sh" | head -1)"
fi
if [[ -z "${RUN_SH}" ]] ; then
die "run.sh script not found. Set BUBBLE_SCRIPTS to be the directory containing run.sh"
fi
@@ -107,7 +111,7 @@ if [[ -z "${BUBBLE_JAR}" ]] ; then
elif [[ -f "${BUBBLE_SCRIPTS}/../bubble.jar" ]] ; then
BUBBLE_JAR="${BUBBLE_SCRIPTS}/../bubble.jar"
else
BUBBLE_JAR="$(find ${BUBBLE_SCRIPTS}/../bubble-server/target -type f -name "bubble*.jar" | head -1)"
BUBBLE_JAR="$(find "${BUBBLE_SCRIPTS}/../bubble-server/target" -type f -name "bubble*.jar" | head -1)"
fi
fi
if [[ -z "${BUBBLE_JAR}" ]] ; then
@@ -115,8 +119,8 @@ if [[ -z "${BUBBLE_JAR}" ]] ; then
fi

# Check to see if we are on the PATH, if not suggest that we could be
BUBBLE_BIN="$(cd $(dirname ${0}) && pwd)"
if [[ -z "${BUBBLE_SKIP_PATH_WARNING}" && -z "$(which $(basename ${0}))" ]] ; then
BUBBLE_BIN="$(cd "$(dirname "${0}")" && pwd)"
if [[ -z "${BUBBLE_SKIP_PATH_WARNING}" && -z "$(which "$(basename "${0}")")" ]] ; then
echo 1>&2 "Note: ${BUBBLE_BIN} is not on your PATH. To make things easier, add it to your PATH:"
echo 1>&2 ""
echo 1>&2 "export PATH=\${PATH}:${BUBBLE_BIN}"


正在加载...
取消
保存