echo與@echo區別

有無@在echo前面這個要分情況來說明,如果是寫在Makefile裏面:

@echo

這樣不會回寫命令行,什麼意思呢,就是直接顯示echo輸出的內容.
在上一篇介紹go Makefile時,有下面這樣一段:

.PHONY: clean test
test:
        @echo "testing..."
        go test github.com/user/stringutil
        @echo "test Done!"

執行後是:

jack@jxes-VirtualBox:~/gopath$ make test
testing...
go test github.com/user/stringutil
ok      github.com/user/stringutil  0.011s
test Done!

echo

在Makefile中沒有@就會回顯命令行內容,將上面栗子中的@去掉後的情形如下:

.PHONY: clean test
test:
        echo "testing..."
        go test github.com/user/stringutil
        echo "test Done!"

執行後是:

jack@jxes-VirtualBox:~/gopath$ make test
echo "testing..."
testing...
go test github.com/user/stringutil
ok      github.com/user/stringutil  0.009s
echo "test Done!"
test Done!

最後說下,在shell下面,是沒有@echo這種寫法的。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章