Make shell scripts shellcheck-compliant

pull/995/head
Lomanic 5 years ago
parent b0b7969cbf
commit 2f46781b0e

@ -7,12 +7,12 @@ set -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)"
ROOT=$(cd ${DIR}/../.. && pwd) ROOT=$(cd "${DIR}"/../.. && pwd)
## 1. refresh ## 1. refresh
cd ${ROOT} cd "${ROOT}"
/bin/rm -rf v3 /bin/rm -rf v3
@ -23,22 +23,22 @@ cp -rp cpu disk docker host internal load mem net process winservices v3
cp Makefile v3 cp Makefile v3
# build migartion tool # build migartion tool
go build -o v3/v3migration ${DIR}/v3migration.go go build -o v3/v3migration "${DIR}"/v3migration.go
V3DIR=$(cd ${ROOT}/v3 && pwd) V3DIR=$(cd "${ROOT}"/v3 && pwd)
cd ${V3DIR} cd "${V3DIR}"
## 3. mod ## 3. mod
go mod init go mod init
### change import path ### change import path
find . -name "*.go" | xargs -I@ sed -i 's|"github.com/shirou/gopsutil/|"github.com/shirou/gopsutil/v3/|g' @ find . -name "*.go" -print0 | xargs -0 -I@ sed -i 's|"github.com/shirou/gopsutil/|"github.com/shirou/gopsutil/v3/|g' @
############ Issues ############ Issues
# #429 process.NetIOCounters is pointless on Linux # #429 process.NetIOCounters is pointless on Linux
./v3migration `pwd` 429 ./v3migration "$(pwd)" 429
sed -i '/NetIOCounters/d' process/process.go sed -i '/NetIOCounters/d' process/process.go
sed -i "/github.com\/shirou\/gopsutil\/v3\/net/d" process/process_bsd.go sed -i "/github.com\/shirou\/gopsutil\/v3\/net/d" process/process_bsd.go
@ -165,10 +165,7 @@ sed -i 's|PrioProcess|prioProcess|g' process/process_*.go
sed -i 's|ClockTicks|clockTicks|g' process/process_*.go sed -i 's|ClockTicks|clockTicks|g' process/process_*.go
./v3migration `pwd` issueRemoveUnusedValue ./v3migration "$(pwd)" issueRemoveUnusedValue
############ SHOULD BE FIXED BY HAND ############ SHOULD BE FIXED BY HAND

@ -1,12 +1,12 @@
#/bin/sh #!/bin/sh
# see http://www.songmu.jp/riji/entry/2015-01-15-goveralls-multi-package.html # see http://www.songmu.jp/riji/entry/2015-01-15-goveralls-multi-package.html
set -e set -e
# cleanup # cleanup
cleanup() { cleanup() {
if [ $tmpprof != "" ] && [ -f $tmpprof ]; then if [ "$tmpprof" != "" ] && [ -f "$tmpprof" ]; then
rm -f $tmpprof rm -f "$tmpprof"
fi fi
exit exit
} }
@ -14,13 +14,13 @@ trap cleanup INT QUIT TERM EXIT
# メインの処理 # メインの処理
prof=${1:-".profile.cov"} prof=${1:-".profile.cov"}
echo "mode: count" > $prof echo "mode: count" > "$prof"
gopath1=$(echo $GOPATH | cut -d: -f1) gopath1=$(echo "$GOPATH" | cut -d: -f1)
for pkg in $(go list ./...); do for pkg in $(go list ./...); do
tmpprof=$gopath1/src/$pkg/profile.tmp tmpprof="$gopath1/src/$pkg/profile.tmp"
go test -covermode=count -coverprofile=$tmpprof $pkg go test -covermode=count -coverprofile="$tmpprof" "$pkg"
if [ -f $tmpprof ]; then if [ -f "$tmpprof" ]; then
cat $tmpprof | tail -n +2 >> $prof tail -n +2 "$tmpprof" >> "$prof"
rm $tmpprof rm "$tmpprof"
fi fi
done done

@ -1,3 +1,4 @@
#!/usr/bin/env bash
# This script is a helper of migration to gopsutil v2 using gorename # This script is a helper of migration to gopsutil v2 using gorename
# #
# go get golang.org/x/tools/cmd/gorename # go get golang.org/x/tools/cmd/gorename
@ -12,7 +13,7 @@ IFS=$'\n'
# This scripts replace process.NetIOCounters() to IOCounters(). # This scripts replace process.NetIOCounters() to IOCounters().
# So you need hand-fixing process. # So you need hand-fixing process.
TARGETS=`cat <<EOF TARGETS=$(cat <<EOF
CPUTimesStat -> TimesStat CPUTimesStat -> TimesStat
CPUInfoStat -> InfoStat CPUInfoStat -> InfoStat
CPUTimes -> Times CPUTimes -> Times
@ -48,11 +49,12 @@ NetConnectionsPid -> ConnectionsPid
Uid -> UID Uid -> UID
Id -> ID Id -> ID
convertCpuTimes -> convertCPUTimes convertCpuTimes -> convertCPUTimes
EOF` EOF
)
for T in $TARGETS for T in $TARGETS
do do
echo $T echo "$T"
gofmt -w -r "$T" ./*.go gofmt -w -r "$T" ./*.go
done done

Loading…
Cancel
Save