3 ms·
Thanks man, your feedback is appreciated. I'm well aware of the dirty nature of this solution[1] but it seems to be the only way to achieve this within context
by pstadler 12y ago
Thanks man, your feedback is appreciated. I'm well aware of the dirty nature of this solution[1] but it seems to be the only way to achieve this within context (OS X, Alfred).
[1] https://github.com/pstadler/non-terminating-bash-processes#conclusion https://github.com/pstadler/non-terminating-bash-processes#c...
Edit:
$! is not working with the distributed Bash version (currently 3.2) on OS X. Unfortunately, dns-sd is the only utility to discover network services on OS X. There are many projects which use the same hack involving dns-sd.
I invite you to find a better solution to this problem.
- fensipens 12y agoTry something like this (untested): #! /bin/sh fifo=/tmp/discover-vnc.fifo rm -f $fifo mkfifo $fifo dns-sd -B _rfb._tcp >$fifo & pid=$! while read line; do case $line in *_rfb._tcp.*) # do something here.. then test # if flag=3 and break otherwise esac done <$fifo kill $pid
- pstadler 12y agoResults from dns-sd are not necessarily being delivered instantly and there might be no lines which contain this flag to check of it's the last entry. It's also rather ugly to create a named pipe for this purpose, don't you think?
- fensipens 12y agothere might be no lines which contain this flag Again, untested: #! /bin/sh timeout=5 fifo=/tmp/discover-vnc.fifo rm -f $fifo mkfifo $fifo dns-sd -B _rfb._tcp >$fifo & pid1=$! while read line; do case $line in *_rfb._tcp.*) # do something here.. then test # if flag=3 and break otherwise esac done <$fifo & pid2=$! sleep $timeout && kill $pid1 $pid2 & pid3=$! wait $pid2 kill $pid3 It's also rather ugly to create a named pipe for this purpose Because it creates a file in /tmp? Who cares? The alternative is bash voodoo magic.. the same magic that gave us shellshock.
- pstadler 12y agoThe alternative is bash voodoo magic.. the same magic that gave us shellshock. I love this one.
- fensipens 12y ago$! is not working with the distributed Bash version (currently 3.2) on OS X. $ bash --version GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) Copyright (C) 2007 Free Software Foundation, Inc. $ : & echo $! [1] 329 329
- pstadler 12y ago$BASHPID is not working with subshells prior to Bash v4.