From e5459191084f2266c21620511b1c1a4d5a97176c Mon Sep 17 00:00:00 2001 From: Naoya Horiguchi Date: Mon, 25 Dec 2017 09:58:32 +0900 Subject: [PATCH] Fix error messages in make clean "make clean" emits the following error message: root@ubuntu:~/docker-compose-files/hyperledger_fabric/v1.0.5# make clean Clean all HLF containers and fabric cc images awk: cmd. line:1: { print , } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print , } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print , } awk: cmd. line:1: ^ unexpected newline or end of string This is simply because $1 and $2 are not properly escaped. And we have another messages like below: "docker rm" requires at least 1 argument(s). See 'docker rm --help'. Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] Remove one or more containers Makefile:138: recipe for target 'clean' failed make: [clean] Error 1 (ignored) "docker rmi" requires at least 1 argument(s). See 'docker rmi --help'. Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] Remove one or more images Makefile:138: recipe for target 'clean' failed make: [clean] Error 1 (ignored) If we have no target containers or images, we don't want to call docker rm/rmi. xargs has -r option for this purpose, so let's turn it on. Signed-off-by: Naoya Horiguchi --- hyperledger_fabric/v1.0.5/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hyperledger_fabric/v1.0.5/Makefile b/hyperledger_fabric/v1.0.5/Makefile index 9f56f100..31b23366 100644 --- a/hyperledger_fabric/v1.0.5/Makefile +++ b/hyperledger_fabric/v1.0.5/Makefile @@ -136,9 +136,9 @@ check: # Check shell scripts grammar clean: # clean up containers @echo "Clean all HLF containers and fabric cc images" - @-docker ps -a | awk '{ print $1,$2 }' | grep "hyperledger/fabric" | awk '{print $1 }' | xargs -I {} docker rm -f {} - @-docker rm -f $$(docker ps -a | awk '$$2 ~ /dev-peer/ { print $$1}') - @-docker rmi $$(docker images | awk '$$1 ~ /dev-peer/ { print $$3}') + @-docker ps -a | awk '{ print $$1,$$2 }' | grep "hyperledger/fabric" | awk '{ print $$1 }' | xargs -r -I {} docker rm -f {} + @-docker ps -a | awk '$$2 ~ /dev-peer/ { print $$1 }' | xargs -r -I {} docker rm -f {} + @-docker images | awk '$$1 ~ /dev-peer/ { print $$3 }' | xargs -r -I {} docker rmi -f {} clean_env: # clean up environment @echo "Clean all images and containers"