Skip to content

Commit

Permalink
Fix: revise all scripts to conform with shellcheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-south-guo committed Oct 25, 2020
1 parent c902074 commit 5c8235f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
2 changes: 2 additions & 0 deletions App/DefaultData/.bashrc → App/DefaultData/.ashrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

##### .bashrc for BusyBoxPortable
# This file will be sourced if BusyBoxPortable is invoked as interactive/login shell.
#####
Expand Down
17 changes: 5 additions & 12 deletions App/DefaultData/.color.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
# shellcheck disable=2034

# Color Constants
# Ref: https://wiki.archlinux.org/index.php/Color_Bash_Prompt
Expand Down Expand Up @@ -77,25 +78,17 @@ _COLOR_On_ICyan='\e[0;106m' # Cyan
_COLOR_On_IWhite='\e[0;107m' # White

echo_color_error() {
echo -n -e "${_COLOR_BRed}"
echo -e "$1"
echo -n -e "${_COLOR_Off}"
printf "${_COLOR_BRed}%b${_COLOR_Off}\n" "$*"
}

echo_color_warning() {
echo -n -e "${_COLOR_BYellow}"
echo -e "$1"
echo -n -e "${_COLOR_Off}"
printf "${_COLOR_BYellow}%b${_COLOR_Off}\n" "$*"
}

echo_color_highlight() {
echo -n -e "${_COLOR_BGreen}"
echo -e "$1"
echo -n -e "${_COLOR_Off}"
printf "${_COLOR_BGreen}%b${_COLOR_Off}\n" "$*"
}

echo_color_info() {
echo -n -e "${_COLOR_Off}"
echo -e "$1"
echo -n -e "${_COLOR_Off}"
printf "${_COLOR_Off}%b${_COLOR_Off}\n" "$*"
}
6 changes: 3 additions & 3 deletions App/DefaultData/.console-title.rc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh

echo_console_title() {
echo -en "\e]0;$1\007"
printf "\e]0;%b\007" "$*"
}

_PS_TITLE_BEGIN="\[\e]0;"
_PS_TITLE_END="\a\]"
export _PS_TITLE_BEGIN="\[\e]0;"
export _PS_TITLE_END="\a\]"
13 changes: 8 additions & 5 deletions App/DefaultData/.profile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/sh
# shellcheck disable=1090,2154

##### .profile for BusyBoxPortable
# This file will be sourced if BusyBoxPortable is invoked as interactive/login shell.
# Caution:
# - Do not modify this file unless absolute necessary.
# - It is recommended to put your own customization in `.bashrc` instead, which
# - It is recommended to put your own customization in `.ashrc` instead, which
# will be sourced right after this file.
#####

. "${HOME}/.color.rc"
. "${HOME}/.console-title.rc"
[ -f "${HOME}/.color.rc" ] && . "${HOME}/.color.rc"
[ -f "${HOME}/.console-title.rc" ] && . "${HOME}/.console-title.rc"

# --------------------
# Config prompt string.
Expand All @@ -16,7 +19,7 @@ test "${_CONSOLE_TITLE}" || _CONSOLE_TITLE="BusyBox - \u - \w"
_PS_ITEM_2ND_LINE="\$(date +%H:%M:%S)"

# Different settings for root or non-root.
if [[ "${USER}" == "root" ]]; then
if [ "${USER}" = "root" ]; then
_PS_ITEM_USER="${_COLOR_BWhite}${_COLOR_On_Red}\u@\h${_COLOR_Off}"
_PS_ITEM_LAST="${_COLOR_BRed}#${_COLOR_Off}"
else
Expand All @@ -35,4 +38,4 @@ then
fi
# ---------- Required by BusyBoxPortable: End

test -f "${HOME}/.bashrc" && . "${HOME}/.bashrc"
[ -f "${HOME}/.ashrc" ] && . "${HOME}/.ashrc"
9 changes: 6 additions & 3 deletions App/DefaultData/bin/hello-busybox.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh
# shellcheck disable=1090

[[ -f "${HOME}/.color.rc" ]] && source "${HOME}/.color.rc"
[ -f "${HOME}/.color.rc" ] && . "${HOME}/.color.rc"

echo -ne "${_COLOR_BGreen}BusyBox ${_COLOR_Cyan}Hello World!!! ${_COLOR_BRed}\n"
read -p "Press Enter to exit: " answer
# shellcheck disable=2059,2154
printf "${_COLOR_BGreen}BusyBox ${_COLOR_Cyan}Hello World!!! ${_COLOR_BRed}\n"

printf "Press [Enter] key to continue..."; read -r

0 comments on commit 5c8235f

Please sign in to comment.