From 08204063138dce6bb183f7a056074b62616b7183 Mon Sep 17 00:00:00 2001 From: John Zhao Date: Fri, 9 Mar 2018 11:42:45 +0800 Subject: [PATCH] Using bash instead of sh --- CommonDefs.mk | 11 ++++++----- Makefile | 12 ++++++------ doc/build.sh | 2 +- doc/langs.sh | 2 +- scripts/common/detect.sh | 10 +++++++--- scripts/common/echo.sh | 8 ++------ scripts/common/host.sh | 2 +- scripts/common/mkdir.sh | 2 +- scripts/getfind.sh | 2 +- scripts/init.sh | 3 ++- scripts/open.sh | 2 +- 11 files changed, 29 insertions(+), 27 deletions(-) diff --git a/CommonDefs.mk b/CommonDefs.mk index 11cda72..43532d7 100644 --- a/CommonDefs.mk +++ b/CommonDefs.mk @@ -1,6 +1,8 @@ ifndef _COMMON_DEFS_MAKE_ _COMMON_DEFS_MAKE_ := 1 +SHELL := /bin/bash + EMPTY := SPACE := $(EMPTY) $(EMPTY) COMMA := , @@ -91,21 +93,22 @@ lower = $(shell echo $1 | tr '[:upper:]' '[:lower:]') # Command +SH := $(SHELL) +ECHO := echo -e +FIND := $(shell ./scripts/getfind.sh) + ifeq ($(HOST_OS),MinGW) - ECHO := echo -e CC := x86_64-w64-mingw32-gcc CXX := x86_64-w64-mingw32-g++ MAKE := mingw32-make BUILD := $(MAKE) else ifeq ($(HOST_OS),Win) - ECHO := echo -e CC := cl CXX := cl MAKE := make BUILD := msbuild.exe ALL_BUILD.vcxproj /property:Configuration=Release else # mac & linux - ECHO := echo # Set realpath for linux because of compiler not found with wrong path when cmake again CC := /usr/bin/cc CXX := /usr/bin/c++ @@ -113,8 +116,6 @@ else BUILD := $(MAKE) endif -FIND := $(shell ./scripts/getfind.sh) - ifeq ($(HOST_OS),Mac) LDD := otool -L else diff --git a/Makefile b/Makefile index 37eb1a9..70b79df 100644 --- a/Makefile +++ b/Makefile @@ -17,14 +17,14 @@ help: apidoc: @$(call echo,Make $@) - @sh ./doc/build.sh + @$(SH) ./doc/build.sh opendoc: apidoc @$(call echo,Make $@) - @$(shell sh ./doc/langs.sh 1); \ + @$(shell $(SH) ./doc/langs.sh 1); \ for lang in "$${LANGS[@]}"; do \ html=./doc/output/$$lang/html/index.html; \ - [ -f "$$html" ] && sh ./scripts/open.sh $$html; \ + [ -f "$$html" ] && $(SH) ./scripts/open.sh $$html; \ done .PHONY: apidoc opendoc @@ -33,7 +33,7 @@ opendoc: apidoc init: @$(call echo,Make $@) - @sh ./scripts/init.sh + @$(SH) ./scripts/init.sh .PHONY: init @@ -77,14 +77,14 @@ host: @$(call echo,Make $@) @echo HOST_OS: $(HOST_OS) @echo HOST_ARCH: $(HOST_ARCH) + @echo SH: $(SH) @echo ECHO: $(ECHO) + @echo FIND: $(FIND) @echo CC: $(CC) @echo CXX: $(CXX) @echo MAKE: $(MAKE) @echo BUILD: $(BUILD) - @echo FIND: $(FIND) @echo LDD: $(LDD) @echo CMAKE: $(CMAKE) - @#$(FIND) . -name READ* .PHONY: host diff --git a/doc/build.sh b/doc/build.sh index cf0f788..8b95f66 100755 --- a/doc/build.sh +++ b/doc/build.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # _VERBOSE_=1 # _TEST_=1 diff --git a/doc/langs.sh b/doc/langs.sh index a1e2af5..9fecfa3 100644 --- a/doc/langs.sh +++ b/doc/langs.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash LANGS=( en zh-Hans diff --git a/scripts/common/detect.sh b/scripts/common/detect.sh index ce5fe90..3734ba9 100644 --- a/scripts/common/detect.sh +++ b/scripts/common/detect.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash [ -n "${_DETECT_SH_}" ] && return || readonly _DETECT_SH_=1 [ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: detect.sh" @@ -13,8 +13,12 @@ _detect() { exit 1 fi else - [ -z "$verbose" ] || echo "-- DETECT: $cmd found" - eval "${cmd}_FOUND=1" + if [ -z "$verbose" ]; then + eval "${cmd}_FOUND=1" &> /dev/null + else + echo "-- DETECT: $cmd found" + eval "${cmd}_FOUND=1" + fi fi } diff --git a/scripts/common/echo.sh b/scripts/common/echo.sh index bf13acd..3e13a5b 100644 --- a/scripts/common/echo.sh +++ b/scripts/common/echo.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash [ -n "${_ECHO_SH_}" ] && return || readonly _ECHO_SH_=1 [ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: echo.sh" @@ -9,11 +9,7 @@ # source "$(dirname "$0")/echo.sh" # fi -if [ "$OS" = "Windows_NT" ]; then - ECHO="echo -e" -else - ECHO="echo" -fi +ECHO="echo -e" # task colors COLOR_STRONG="1;35" # Magenta diff --git a/scripts/common/host.sh b/scripts/common/host.sh index 9e48598..f841f9b 100755 --- a/scripts/common/host.sh +++ b/scripts/common/host.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash [ -n "${_HOST_SH_}" ] && return || readonly _HOST_SH_=1 [ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: host.sh" diff --git a/scripts/common/mkdir.sh b/scripts/common/mkdir.sh index a249288..11fa608 100644 --- a/scripts/common/mkdir.sh +++ b/scripts/common/mkdir.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash [ -n "${_MKDIR_SH_}" ] && return || readonly _MKDIR_SH_=1 [ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: mkdir.sh" diff --git a/scripts/getfind.sh b/scripts/getfind.sh index 2acd67a..ecdfd73 100755 --- a/scripts/getfind.sh +++ b/scripts/getfind.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash FIND="find" diff --git a/scripts/init.sh b/scripts/init.sh index e03a232..08fab1a 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -1,4 +1,5 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash +# _VERBOSE_=1 # _FORCE_INSRALL_=1 BASE_DIR=$(cd "$(dirname "$0")" && pwd) diff --git a/scripts/open.sh b/scripts/open.sh index 1d44ad9..84149e7 100755 --- a/scripts/open.sh +++ b/scripts/open.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash BASE_DIR=$(cd "$(dirname "$0")" && pwd)