NOTE: a newline appears but od -c doesn't display it.
My music player's status command (quodlibet --status | od -c) has three states, and I'm trying to write a conditional based on that output. The outputs from that command are like this (may differ depending on the configuration).
I think this is printing to stderr because
od -cdoesn't display properly, even though it does for the other commands.not-running 0000000paused
0000000 p a u s e d P a n e d B r o w 0000020 s e r 1 . 0 0 0 s h u f f l 0000040 e o n 0 . 2 2 8 \n 0000053playing
0000000 p l a y i n g P a n e d B r o 0000020 w s e r 1 . 0 0 0 s h u f f 0000040 l e o n 0 . 2 3 2 \n 0000054
My goal is to remove everything except "not-running", "paused", or "playing" and use that in a conditional, like this:
#!/bin/bash
status=$(quodlibet --status | awk '{split($0,m," "); printf "%s",m[1]}' | tr -d '\000\007\010\n')
if [ "$status" = "playing" ]; then
quodlibet --print-playing '<artist>: <title>' | cut -c1-45
else
echo -n "$status"
fi
In the case where the player isn't running though this always prints a newline in the terminal after "not-running." Even if I do something like this
echo -n "$(quodlibet --print-playing '<artist>: <title>' | cut -c1-45)"
If I pipe that output to od -c, I get the same
not-running
0000000
which isn't right. The newline doesn't show up, but its their in the terminal.
Questions
- What's causing this?
- Is the command printing to standard error when the program isn't running?
- How can I determine this?