4

I want to build a package by Gradle (3.2.1) using a script.

The script (hoge.sh) is

#!/bin/sh
gradle build
echo "hello"

./hoge.sh works and prints "hello".

However, cat hoge.sh | /bin/sh -s stops at gradle build. The build looks successful but the process never prints "hello".

How can I fix hoge.sh to run by cat hoge.sh | /bin/sh -s correctly??

If I run cat hoge.sh | /bin/sh -i, it returns,

sh-4.2$ #!/bin/sh
sh-4.2$ gradle build
###gradle information###
sh-4.2$ exit

For information, using Gradle 2.1, the exit comes at last (after echo "hello").

sh-4.2$ #!/bin/sh
sh-4.2$ gradle build
###gradle information###
sh-4.2$ echo "hello"
hello
sh-4.2$ exit

How can I avoid the exit by Gradle and let echo "hello" survive?
add something to the second line gradle build ? or to cat hoge.sh | /bin/sh?

kensuke1984
  • 949
  • 1
  • 11
  • 21
  • What is for you need to run `./gradlew` before `./gradlew build`? Why don't you call a build at once? – Stanislav Dec 05 '16 at 12:15
  • I thought ```./gradlew``` is for those who has no gradle environment, which is installation. and even if I use ```./gradlew build```, its exit finishes the script...(I want to add some lines after ```./gradlew build``` as well) – kensuke1984 Dec 06 '16 at 02:38
  • 1
    anyway to clarify, I modified my question. Thank you! – kensuke1984 Dec 06 '16 at 03:37
  • Does `gradle build` consume its standard input? Try `gradle build – tripleee Apr 18 '22 at 15:01
  • 1
    (Tangentially also, avoid the [useless `cat`;](https://stackoverflow.com/questions/11710552/useless-use-of-cat) `sh -s – tripleee Apr 18 '22 at 15:02

0 Answers0