Skip to content

Commit

Permalink
Silence bash's output before reading from pipe in atom.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrunsfeld committed Jun 5, 2018
1 parent 41bbac7 commit c59ebdf
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions atom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,20 @@ on_die() {
}
trap 'on_die' SIGQUIT SIGTERM

# If the wait flag is set, don't exit this process until Atom tells it to.
# If the wait flag is set, don't exit this process until Atom kills it.
if [ $WAIT ]; then
WAIT_FIFO="$ATOM_HOME/.wait_fifo"
while true; do
[ -f "$WAIT_FIFO" ] && rm "$WAIT_FIFO"
[ ! -p "$WAIT_FIFO" ] && mkfifo "$WAIT_FIFO"
read < "$WAIT_FIFO" || break
sleep 1 # prevent a tight loop
done

# fall back to sleep
if [ ! -p "$WAIT_FIFO" ]; then
rm -f "$WAIT_FIFO"
mkfifo "$WAIT_FIFO"
fi

# Block endlessly by reading from a named pipe.
exec 2>/dev/null
read < "$WAIT_FIFO"

# If the read completes for some reason, fall back to sleeping in a loop.
while true; do
sleep 1
done
Expand Down

0 comments on commit c59ebdf

Please sign in to comment.