From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 0EB1F1F852 for ; Sun, 23 Jan 2022 21:38:15 +0000 (UTC) Received: from localhost ([::1]:56308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBkYw-0007Lh-9p for e@80x24.org; Sun, 23 Jan 2022 16:38:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBkYu-0007LO-Q5 for dtas-all@nongnu.org; Sun, 23 Jan 2022 16:38:12 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:40014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBkYt-0000AE-BX for dtas-all@nongnu.org; Sun, 23 Jan 2022 16:38:12 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E71011FA10 for ; Sun, 23 Jan 2022 21:37:46 +0000 (UTC) From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH 5/9] dtas-tl: drop encoding hacks, use binary stdout+stderr Date: Sun, 23 Jan 2022 21:37:42 +0000 Message-Id: <20220123213746.21085-6-e@80x24.org> In-Reply-To: <20220123213746.21085-1-e@80x24.org> References: <20220123213746.21085-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.71.152.64; envelope-from=e@80x24.org; helo=dcvr.yhbt.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: duct tape audio suite List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: "dtas-all" Try to consistently treat pathnames as binary blobs everywhere, since POSIX FSes allow everything but "\0" in pathnames. --- bin/dtas-tl | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bin/dtas-tl b/bin/dtas-tl index 767b02d..e58ee31 100755 --- a/bin/dtas-tl +++ b/bin/dtas-tl @@ -7,6 +7,8 @@ # itself is also unstable, but better than this one probably). require 'dtas/unix_client' require 'shellwords' +$stdout.binmode +$stderr.binmode def get_track_ids(c) track_ids = c.req("tl tracks") @@ -16,18 +18,11 @@ def get_track_ids(c) track_ids end -def fix_enc!(str, enc) - str.force_encoding(enc) - str.force_encoding(Encoding::ASCII_8BIT) unless str.valid_encoding? -end - def each_track(c) - enc = Encoding.default_external get_track_ids(c).each_slice(128) do |track_ids| res = c.req("tl get #{track_ids.join(' ')}") res = Shellwords.split(res.sub!(/\A\d+ /, '')) while line = res.shift - fix_enc!(line, enc) yield line end end @@ -109,7 +104,6 @@ def do_edit(c) path = File.expand_path(path) unless File.exist?(path) path = orig.dup - fix_enc!(path, enc) path = Shellwords.split(path)[0] path = File.expand_path(path) end