Skip to content

Commit

Permalink
Merge pull request #21 from chromebrew/extglob2
Browse files Browse the repository at this point in the history
Second try on fixing function and variable loading
  • Loading branch information
uberhacker authored Apr 11, 2024
2 parents eefa996 + 586de28 commit 1b13128
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/bash.d/01-crew
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
# 01-crew: bash completion for crew command

shopt -s extglob

function _crew () {
local CREW_PACKAGES_PATH="${CREW_PREFIX}/lib/crew/packages/"
local CREW_LOCAL_REPO_ROOT="$(git rev-parse --show-toplevel 2> /dev/null)"
Expand Down
2 changes: 1 addition & 1 deletion src/bash.d/02-history
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Immediately save each command executed to history, so that crew opening a new shell on exit is less disruptive.
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
export PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
4 changes: 4 additions & 0 deletions src/env.d/01-locale
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Locale settings

set -a

# The user's primary language (defaults to American English)
# It is HIGHLY RECOMMENDED to use a UTF-8 locale
# LANG="POSIX"
Expand All @@ -26,3 +28,5 @@
# This variable overrides all previous variables except LANGUAGE
# Dangerous to set, leave unset unless you know what you're doing
#LC_ALL=

set +a
4 changes: 3 additions & 1 deletion src/env.d/02-editor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The user's preferred editor


set -a
# The EDITOR variable is for terminals without special capabilities, programs will prefer VISUAL.
#EDITOR="vi -e"

Expand All @@ -12,3 +12,5 @@

# The SUDOEDITOR variable is for the `sudo -e` and `sudoeditor` commands.
#SUDOEDITOR="${VISUAL}"

set +a
4 changes: 4 additions & 0 deletions src/env.d/03-pager
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# The user's preferred pager

set -a

PAGER="more"
#PAGER="less"
#PAGER="most"

set +a
2 changes: 1 addition & 1 deletion src/env.d/04-dbus
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dbus settings
DBUS_SYSTEM_BUS_ADDRESS='unix:path=/var/run/dbus/system_bus_socket'
export DBUS_SYSTEM_BUS_ADDRESS='unix:path=/var/run/dbus/system_bus_socket'
[[ "$DBUS_SESSION_BUS_ADDRESS"=="disabled:" ]] && unset DBUS_SESSION_BUS_ADDRESS
if [ -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then
# if not found, launch a new one
Expand Down
2 changes: 1 addition & 1 deletion src/env.d/05-iconv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Set GCONV_PATH since the built-in glibc files are limited, causing iconv checks fail.
GCONV_PATH=${CREW_LIB_PREFIX}/gconv
export GCONV_PATH=${CREW_LIB_PREFIX}/gconv
20 changes: 4 additions & 16 deletions src/profile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
# Instead, add custom environment variables to env.d/99-custom and
# custom scripting to profile.d/99-custom

shopt -s extglob

function _set_crew_variables () {
# Export variables set (set allexport)
set -a
local ARCH="$(uname -m)"
LIB_SUFFIX=''
[ "${ARCH}" = "x86_64" ] && LIB_SUFFIX='64'
export LIB_SUFFIX=''
[ "${ARCH}" = "x86_64" ] && export LIB_SUFFIX='64'

# Find chromebrew prefix
# same logic can be found in lib/const.rb, line 17-25
Expand All @@ -20,17 +16,14 @@ function _set_crew_variables () {
: "${CREW_LIB_PREFIX:=$CREW_PREFIX/lib$LIB_SUFFIX}"

# Find system configuration directory
CREW_SYSCONFDIR="${CREW_PREFIX}/etc"

# Stop exporting variables set (unset allexport)
set +a
export CREW_SYSCONFDIR="${CREW_PREFIX}/etc"
}
_set_crew_variables

# Bash in path will be the Chromebrew bash if it is installed.
# Switch to Chromebrew bash as early as possible if it is installed.
if [ -x "$CREW_PREFIX/bin/bash" ]; then
CREW_BASH_VERSION=$("$CREW_PREFIX"/bin/bash --norc -c "echo \"$BASH_VERSION\"")
export CREW_BASH_VERSION=$("$CREW_PREFIX"/bin/bash --norc -c "echo \"$BASH_VERSION\"")
if [ -n "$CREW_BASH_VERSION" ] && [ "${CREW_BASH_VERSION}" != "${BASH_VERSION}" ]; then
echo "Starting Chromebrew bash."
exec "$CREW_PREFIX"/bin/bash
Expand All @@ -42,9 +35,6 @@ fi
# Source the base /etc/profile file
. /etc/profile

# Export variables set (set allexport)
set -a

# Disable hashing
set +h

Expand All @@ -67,5 +57,3 @@ if [ -n "${ZSH_NAME}" ]; then
fi

unset i
# Stop exporting variables set (unset allexport)
set +a

0 comments on commit 1b13128

Please sign in to comment.