Merge pull request #191 from nmarghetti/master

Add quote around path to handle case with space in $HOME or $OSH
This commit is contained in:
Koichi Murase
2022-10-07 19:50:14 +09:00
committed by GitHub
6 changed files with 59 additions and 5 deletions

22
.github/workflows/test.sh vendored Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e
tmpdir=$(mktemp -d)
export OSH="$tmpdir/path with space"
export HOME="$tmpdir/home with space"
mkdir -p "$HOME"
OSH_REPOSITORY="$PWD" ./tools/install.sh
source "$HOME/.bashrc"
set | grep -aE "^OSH"
if [[ "$OSH_THEME" == "font" ]]; then
echo "Installation succeeded"
else
echo "Installation failed, \$OSH_THEME is not set to 'font'"
exit 1
fi

28
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Test
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# ubuntu-20.04 available: https://github.com/actions/virtual-environments/issues/1816
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: false
- name: Upgrade bash on Mac
if: runner.os == 'macOs'
run: brew install bash
- name: Install oh-my-bash
shell: bash
run: bash --noprofile --norc -i "$PWD/.github/workflows/test.sh"

View File

@ -48,7 +48,7 @@ bind '"\e[C": forward-char'
bind '"\e[D": backward-char'
# Use standard ISO 8601 timestamp
# %F equivalent to %Y-%m-%d
# %F equivalent to %Y-%m-%d
# %T equivalent to %H:%M:%S (24-hours format)
# Show history

View File

@ -37,7 +37,7 @@
if [ ! -n "$SDIRS" ]; then
SDIRS=~/.sdirs
fi
touch $SDIRS
touch "$SDIRS"
# main function
function bm {

View File

@ -152,7 +152,7 @@ ___brainy_prompt_clock() {
}
___brainy_prompt_battery() {
[ ! -e $OSH/plugins/battery/battery.plugin.sh ] ||
[ ! -e "$OSH/plugins/battery/battery.plugin.sh" ] ||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return
info=$(battery_percentage)
color=$_omb_prompt_bold_green

View File

@ -137,7 +137,7 @@ _omb_install_user_bashrc() {
printf "${BLUE}Using the Oh My Bash template file and adding it to ~/.bashrc${NORMAL}\n"
_omb_install_run cp "$OSH"/templates/bashrc.osh-template ~/.bashrc
sed "/^export OSH=/ c\\
export OSH=$OSH
export OSH='${OSH//\'/\'\\\'\'}'
" ~/.bashrc >| ~/.bashrc.omb-temp
_omb_install_run mv -f ~/.bashrc.omb-temp ~/.bashrc
@ -230,6 +230,10 @@ _omb_install_main() {
OSH=~/.oh-my-bash
fi
if [[ ! $OSH_REPOSITORY ]]; then
OSH_REPOSITORY=https://github.com/ohmybash/oh-my-bash.git
fi
# Only enable exit-on-error after the non-critical colorization stuff,
# which may fail on systems lacking tput or terminfo
@ -261,7 +265,7 @@ _omb_install_main() {
return 1
fi
fi
_omb_install_run git clone --depth=1 https://github.com/ohmybash/oh-my-bash.git "$OSH" || {
_omb_install_run git clone --depth=1 "$OSH_REPOSITORY" "$OSH" || {
printf "Error: git clone of oh-my-bash repo failed\n"
return 1
}