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
  •  | 
  •  

Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top