Remove bashisms from scm breeze update scripts
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
# Detect shell
|
# Detect shell
|
||||||
if [ -n "${ZSH_VERSION:-}" ]; then shell="zsh"; else shell="bash"; fi
|
if [ -n "${ZSH_VERSION:-}" ]; then shell="zsh"; else shell="bash"; fi
|
||||||
# Detect whether zsh 'shwordsplit' option is on by default.
|
# Detect whether zsh 'shwordsplit' option is on by default.
|
||||||
if [[ $shell == "zsh" ]]; then zsh_shwordsplit=$((setopt | grep -q shwordsplit) && echo "true"); fi
|
if [ $shell = "zsh" ]; then zsh_shwordsplit=$( (setopt | grep -q shwordsplit) && echo "true" ); fi
|
||||||
# Switch on/off shwordsplit for functions that require it.
|
# Switch on/off shwordsplit for functions that require it.
|
||||||
zsh_compat(){ if [[ $shell == "zsh" && -z $zsh_shwordsplit ]]; then setopt shwordsplit; fi; }
|
zsh_compat(){ if [ $shell = "zsh" && -z $zsh_shwordsplit ]; then setopt shwordsplit; fi; }
|
||||||
zsh_reset(){ if [[ $shell == "zsh" && -z $zsh_shwordsplit ]]; then unsetopt shwordsplit; fi; }
|
zsh_reset(){ if [ $shell = "zsh" && -z $zsh_shwordsplit ]; then unsetopt shwordsplit; fi; }
|
||||||
|
|
||||||
# Alias wrapper that ignores errors if alias is not defined.
|
# Alias wrapper that ignores errors if alias is not defined.
|
||||||
_alias(){ alias "$@" 2> /dev/null; }
|
_alias(){ alias "$@" 2> /dev/null; }
|
||||||
@@ -31,7 +31,7 @@ _create_or_patch_scmbrc() {
|
|||||||
# Create file from example if it doesn't already exist
|
# Create file from example if it doesn't already exist
|
||||||
if ! [ -e "$HOME/.$scm.scmbrc" ]; then
|
if ! [ -e "$HOME/.$scm.scmbrc" ]; then
|
||||||
cp "$HOME/.scm_breeze/$scm.scmbrc.example" "$HOME/.$scm.scmbrc"
|
cp "$HOME/.scm_breeze/$scm.scmbrc.example" "$HOME/.$scm.scmbrc"
|
||||||
echo "== '~/.$scm.scmbrc' has been created. Please edit this file to change SCM Breeze settings for '$scm'."
|
printf "== '~/.$scm.scmbrc' has been created. Please edit this file to change SCM Breeze settings for '$scm'.\n"
|
||||||
# If file exists, attempt to update it with any new settings
|
# If file exists, attempt to update it with any new settings
|
||||||
elif [ -n "$1" ]; then
|
elif [ -n "$1" ]; then
|
||||||
# Create diff of example file, substituting example file for user's config.
|
# Create diff of example file, substituting example file for user's config.
|
||||||
@@ -40,8 +40,8 @@ _create_or_patch_scmbrc() {
|
|||||||
cd $HOME
|
cd $HOME
|
||||||
# If the patch cannot be applied cleanly, show the updates and tell user to update file manually.
|
# If the patch cannot be applied cleanly, show the updates and tell user to update file manually.
|
||||||
if ! patch -f "$HOME/.$scm.scmbrc" $patchfile; then
|
if ! patch -f "$HOME/.$scm.scmbrc" $patchfile; then
|
||||||
echo -e "== \e[0;31mUpdates could not be applied to '\e[1m~/.$scm.scmbrc\e[0;31m'.\e[0m"
|
printf "== \e[0;31mUpdates could not be applied to '\e[1m~/.$scm.scmbrc\e[0;31m'.\e[0m\n"
|
||||||
echo -e "== Please look at the following changes and manually update '~/.$scm.scmbrc', if necessary.\n"
|
printf "== Please look at the following changes and manually update '~/.$scm.scmbrc', if necessary.\n\n"
|
||||||
cat "$HOME/.$scm.scmbrc.rej"
|
cat "$HOME/.$scm.scmbrc.rej"
|
||||||
fi
|
fi
|
||||||
cd "$scmbDir"
|
cd "$scmbDir"
|
||||||
|
|||||||
Reference in New Issue
Block a user