fix(): fix broken environment variables

jwerle 2 years ago
parent 58af5f1e62
commit 1ef61603b0

29
lib/env/env.sh vendored

@ -1,14 +1,5 @@
#!/usr/bin/env bash
if ! type -f bpkg-utils &>/dev/null; then
echo "error: bpkg-utils not found, aborting"
exit 1
else
# shellcheck disable=SC2230
# shellcheck source=lib/utils/utils.sh
source "$(which bpkg-utils)"
fi
if ! type -f bpkg-package &>/dev/null; then
echo "error: bpkg-package not found, aborting"
exit 1
@ -18,8 +9,6 @@ else
source "$(which bpkg-package)"
fi
bpkg_initrc
# Include config rc file if found
BPKG_USER_CONFIG_FILE="$HOME/.bpkgrc"
@ -29,13 +18,18 @@ BPKG_LOCAL_CONFIG_FILE="$(pwd)/.bpkgrc"
## meta
export BPKG_DATE="$(date)"
export BPKG_HOME="${BPKG_HOME:-$HOME}"
export BPKG_INDEX="$BPKG_INDEX"
export BPKG_INDEX
## os
export BPKG_OS="$(uname)"
export BPKG_CWD="$(pwd)"
export BPKG_BIN="$(which bpkg)"
export BPKG_USER="$USER"
export BPKG_BIN="${BPKG_BIN:-$(which bpkg)}"
export BPKG_USER="${BPKG_USER:-$USER}"
## git
export BPKG_REMOTES
export BPKG_GIT_REMOTE
export BPKG_GIT_REMOTES
## package
export BPKG_PACKAGE_USER
@ -44,12 +38,13 @@ export BPKG_PACKAGE_REPO="$(bpkg_package repo 2>/dev/null)"
export BPKG_PACKAGE_DEPS="${BPKG_PACKAGE_DEPS:-deps}"
export BPKG_PACKAGE_VERSION="$(bpkg_package version 2>/dev/null)"
export BPKG_PACKAGE_DESCRIPTION="$(bpkg_package description 2>/dev/null)"
export BPKG_PACKAGE_DEFAULT_USER="${BPKG_PACKAGE_DEFAULT_USER:-bpkg}"
## remote
export BPKG_REMOTE="$BPKG_REMOTE"
# shellcheck disable=SC2178
export BPKG_REMOTES="${BPKG_REMOTE[*]}"
export BPKG_REMOTE_RAW_PATH="$BPKG_REMOTE_RAW_PATH"
export BPKG_REMOTE
export BPKG_REMOTES
export BPKG_REMOTE_RAW_PATH
if test -f bpkg.json || test -f package.json; then
declare -a BPKG_SCRIPT_SOURCES=()

@ -1,14 +1,16 @@
#!/usr/bin/env bash
if ! type -f bpkg-env &>/dev/null; then
echo "error: bpkg-env not found, aborting"
if ! type -f bpkg-utils &>/dev/null; then
echo "error: bpkg-utils not found, aborting"
exit 1
else
# shellcheck disable=SC2230
# shellcheck source=lib/env/env.sh
source "$(which bpkg-env)"
# shellcheck source=lib/utils/utils.sh
source "$(which bpkg-utils)"
fi
bpkg_initrc
let prevent_prune=0
## check parameter consistency
@ -173,6 +175,7 @@ bpkg_install () {
shift
needs_global=1
;;
--no-prune)
shift
prevent_prune=1

@ -10,7 +10,7 @@ usage () {
## main
suggest () {
local found paths seen
local found paths seen find_supports_maxdepth
declare -a paths=()
declare -a seen=()
declare -a found=()
@ -35,6 +35,12 @@ suggest () {
;;
esac
if find --help 2>/dev/null | grep 'maxdepth'; then
find_supports_maxdepth=1
else
find_supports_maxdepth=0
fi
## search path
{
local res=""
@ -63,16 +69,20 @@ suggest () {
## mark seen
seen+=("$path")
if (( find_supports_maxdepth == 1 )); then
res=$(find "$path" -name "$query*" -prune -print -maxdepth 1 2>/dev/null | tr '\n' ' ');
else
res=$(find "$path" -name "$query*" -prune -print >/dev/null | tr '\n' ' ');
fi
## find in path
if res=$(find "$path" -name "$query*" -prune -print 2>/dev/null); then
if [ -z "$res" ]; then
continue
fi
res="$(echo "$res" | tr '\n' ' ')"
## add to found count
# shellcheck disable=SC2207
found+=($(echo -n "$res"))
if [ -z "$res" ]; then
continue
fi
## add to found count
# shellcheck disable=SC2207
found+=($(echo -n "$res"))
done
}

@ -1,5 +1,14 @@
#!/usr/bin/env bash
if ! type -f bpkg-env &>/dev/null; then
echo "error: bpkg-env not found, aborting"
exit 1
else
# shellcheck disable=SC2230
# shellcheck source=lib/env/env.sh
source "$(which bpkg-env)"
fi
## Collection of shared bpkg functions
## Init local config and set environmental defaults

Loading…
Cancel
Save