Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'No "space bar" goodness' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
No "space bar" goodness
Authored by: Vynce on Jul 18, '10 06:51:20PM
That seems like an incredibly complex way of waiting for a keypress. The following script is much simpler and works just as well in my testing. To be honest, I didn't actually test your version of the script. Does it provide some other benefit that I'm just not seeing?

qlmanage -p "$@" &>/dev/null &

echo "Press any key to return"
read -s -n 1

kill $QL_PID

[ Reply to This | # ]
No "space bar" goodness
Authored by: dmw on Jul 19, '10 07:39:08AM
Does it provide some other benefit that I'm just not seeing?
In this venue, you're right, it is overly complicated. Its one benefit over using read -n 1 is that it's technically more portable across UNIXs. On OS X, sh is really bash, which provides the -n option. The real sh doesn't have this option.

But since this is a Mac forum, and the script itself is Mac specific (using qlmanage), your method is preferable. And to be honest, I think it may be unlikely you'd find a modern UNIX variant where sh isn't really bash, so I think I'm going to retire this snippet in favor of yours. Thanks!

[ Reply to This | # ]