#!/usr/bin/env perl
#
-# Copyright © 2012,2019 Nick Bowler
+# Copyright © 2012,2019-2020 Nick Bowler
#
# Send commands to MPD. Each command-line argument is quoted as necessary
# so it appears as a single argument at the protocol level. The result is
use Getopt::Long qw(:config gnu_getopt);
+use FindBin;
+use lib "$FindBin::Bin";
+use MPDHacks;
+
my $host = $ENV{MPD_HOST} // "localhost";
my $port = $ENV{MPD_PORT} // 6600;
my ($quiet, $binary, $ignore_errors, $download);
die "MPD failed to announce version: $!";
}
-sub mpd_escape {
- ($_) = @_;
-
- # No way to encode literal newlines in the protocol, so we convert
- # any newlines in the arguments into a space, which can help with
- # shell quoting.
- s/\n/ /g;
-
- if (/[ \t\\"]/) {
- s/[\\"]/\\$&/g;
- return "\"$_\"";
- }
- return $_;
-}
-
sub read_binary {
my ($count) = @_;
my $buf;
}
if (@ARGV) {
- mpd_exec(map { mpd_escape($_) } @ARGV)
+ mpd_exec(map { MPD::escape($_) } @ARGV)
} else {
while (<>) {
chomp;