Skip to content

Commit

Permalink
posix
Browse files Browse the repository at this point in the history
  • Loading branch information
junjiemars committed Oct 21, 2023
1 parent 1b2f3c1 commit 1cc229c
Showing 1 changed file with 21 additions and 51 deletions.
72 changes: 21 additions & 51 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ grep=$(PATH=$PH command -v grep)
iconv=$(PATH=$PH command -v iconv)
ls=$(PATH=$PH command -v ls)
mkdir=$(PATH=$PH command -v mkdir)
printf=$(PATH=$PH command -v printf)
ps=$(PATH=$PH command -v ps)
rm=$(PATH=$PH command -v rm)
sed=$(PATH=$PH command -v sed)
Expand All @@ -33,20 +34,6 @@ uname=$(PATH=$PH command -v uname)
uniq=$(PATH=$PH command -v uniq)
xargs=$(PATH=$PH command -v xargs)

# check command options
check_echo_opt () {
# check the echo's "-n" option and "\c" capability
echo_c='\c'
if echo "test\c" | $grep -q c; then
echo_c=
fi
echo_n='-n'
if echo -n test | tr '\n' _ | $grep -q _; then
echo_n=
fi
}
check_echo_opt

bootstrap_path () {
local p="$($dirname $0)"
local n="$(pwd)/.nore"
Expand Down Expand Up @@ -77,7 +64,7 @@ NORE_BRANCH=master
for option
do
case "$option" in
-*=*) value=`echo "$option" | $sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
-*=*) value=$(echo "$option" | $sed -e 's/[-_a-zA-Z0-9]*=//') ;;
*) value="" ;;
esac

Expand All @@ -87,7 +74,7 @@ do
--work=*) NORE_WORK="$value" ;;

*)
command="`echo $option | tr '[:upper:]' '[:lower:]'`"
command="$(echo "$option" | tr '[:upper:]' '[:lower:]')"
;;
esac
done
Expand Down Expand Up @@ -122,8 +109,8 @@ on_linux () {
check_nore () {
local r="junjiemars/nore"
if $git -C "${ROOT}" remote -v 2>/dev/null | $grep -q ${r}; then
if [ "`check_nore_branch`" != "${NORE_BRANCH}" -a "${ROOT}" != "${PWD}/.nore" ]; then
ROOT="$(PWD)/.nore"
if [ "$(check_nore_branch)" != "${NORE_BRANCH}" -a "${ROOT}" != "$(pwd)/.nore" ]; then
ROOT="$(pwd)/.nore"
test -d "${ROOT}" && rm -rf "${ROOT}"
return 1
else
Expand Down Expand Up @@ -167,22 +154,6 @@ cat_configure () {
# generated by Nore (${GITHUB_H}/nore)
#------------------------------------------------
check_echo_opt () {
# check the echo's "-n" option and "\c" capability
if echo "test\c" | grep -q c; then
echo_c=
if echo -n test | tr '\n' _ | grep -q _; then
echo_n=
else
echo_n=-n
fi
else
echo_n=
echo_c='\c'
fi
}
check_echo_opt
NORE_ROOT="${ROOT%/}"
NORE_BRANCH="${b}"
NORE_L_BOOT="\${NORE_ROOT}/bootstrap.sh"
Expand Down Expand Up @@ -210,7 +181,7 @@ do
esac
done
case "\`echo \${NORE_L_CONF_COMMAND} | tr '[:upper:]' '[:lower:]'\`" in
case "\$(echo \${NORE_L_CONF_COMMAND} | tr '[:upper:]' '[:lower:]')" in
upgrade)
if [ -f \${NORE_L_BOOT} ]; then
\$NORE_L_BOOT --branch=\${NORE_BRANCH} upgrade
Expand Down Expand Up @@ -469,18 +440,17 @@ END
echo_yes_or_no () {
local c="$1"
if [ 0 -eq $c ]; then
echo "yes"
$printf "yes\n"
else
echo "no"
$printf "no\n"
fi
return $c
}
echo_elapsed_seconds () {
local begin=$1
local end="`date +%s`"
echo
echo "... elpased $(( ${end}-${begin} )) seconds."
$printf "\n... elpased %d seconds\n" $(( ${end}-${begin} ))
}
exit_checking () {
Expand Down Expand Up @@ -522,39 +492,39 @@ echo
echo "configure Nore on $PLATFORM ..."
echo
echo $echo_n " + checking make ... $echo_c"
if `make -v 1>/dev/null 2>&1`; then
$printf " + checking make ... "
if $(make -v 1>/dev/null 2>&1); then
echo_yes_or_no $?
else
echo_yes_or_no $?
if `on_windows_nt`; then
echo $echo_n " + downloading make ... $echo_c"
echo_yes_or_no `download_gmake "${HOME}/.nore"; echo $?`
if on_windows_nt; then
$printf " + downloading make ... "
echo_yes_or_no $(download_gmake "${HOME}/.nore"; echo $?)
fi
fi
[ -d "${ROOT}" ] || mkdir -p "${ROOT}"
echo $echo_n " + checking nore ... $echo_c"
$printf " + checking nore ... "
if check_nore; then
echo_yes_or_no $?
if [ "yes" = "$NORE_UPGRADE" ]; then
echo $echo_n " + upgrading nore ... $echo_c"
$printf " + upgrading nore ... "
echo_yes_or_no `upgrade_nore ; echo $?`
exit_checking $? $BEGIN
fi
else
echo_yes_or_no $?
echo $echo_n " + cloning nore ... $echo_c"
echo_yes_or_no `clone_nore ; echo $?`
$printf $echo_n " + cloning nore ... "
echo_yes_or_no $(clone_nore ; echo $?)
exit_checking $? $BEGIN
fi
echo $echo_n " + generating configure ... $echo_c"
echo_yes_or_no `cat_configure ; echo $?`
$printf " + generating configure ... "
echo_yes_or_no $(cat_configure ; echo $?)
exit_checking $? $BEGIN
echo $echo_n " + generating ~/.nore/cc-env.sh ... $echo_c"
$printf " + generating ~/.nore/cc-env.sh ... "
echo_yes_or_no $(cat_cc_env "${HOME}/.nore/cc-env.sh"; echo $?)
exit_checking $? $BEGIN
Expand Down

0 comments on commit 1cc229c

Please sign in to comment.