Expanding on question answer by @chepner in
Bash script fails when running command with embedded quotes (source parameters)
Do I have to do anything special to with the $cmd variable if I want to pipe another command into it? Previously it has been split into args array to handle escaped quotes.
ie. Does the pipe symbol and adding an extra command also require special treatment?
I want to change the first line in this:
cmd=avconv
args=(-re -i /home/pi/test.mp3 -c:a libmp3lame -content_type audio/mpeg -b:a "$stream_bitrate" -legacy_icecast "$icecast_legacy")
stream_parameters=(-ice_name "$icecast_show" -f mp3)
icecast_setup="icecast://$icecast_user:$icecast_password@$icecast_server:$icecast_port$icecast_mount_url"
test_cmd="$start_cmd $stream_parameters $icecast_setup"
echo "Testing command: $cmd ${args} ${stream_parameters[@]} $icecast_setup"
# Run command
"$cmd" "${args[@]}" "${stream_parameters[@]}" "$icecast_setup"
To this:
cmd="arecord -f cd -D plughw:1,0 | avconv"
Will that still work on the last line? Or does the $cmd and $args have to be adjusted?
Also - what is the meaning of [@]
in the last command - is that just expanding the array?