Piping not working within bash script when run from a GUI as opposed to bash shell

StackOverflow https://stackoverflow.com/questions/14411521

  •  16-01-2022
  •  | 
  •  

문제

As part of my build process I'm trying to mount a DMG using hdiutil.

I've written a shell script to do this, and because hdiutil asks for confirmation of the license agreement before opening, I have in my script something like yes | hdiutil .... When I run the script from a bash shell like Terminal.app there are no problems and the process works as expected.

However, when I add an 'external build system' target to Xcode and have /bin/bash run my script, it hangs forever after executing the hdiutil command.

I'm guessing that yes is not terminating; what would cause this to behave differently when the script is invoked by a GUI app as opposed to an interactive bash shell and how can I make it work using both approaches?

도움이 되었습니까?

해결책

I needed to use echo y | hdiutil isntead of yes | hdiutil as suggested by @trojanfoe.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top