From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 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 A91881F545 for ; Mon, 3 Jul 2023 00:43:23 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=80x24.org header.i=@80x24.org header.a=rsa-sha256 header.s=selector1 header.b=epylQW6q; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qG7ew-0006Nq-Tj; Sun, 02 Jul 2023 20:43:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qG7ew-0006Na-4k for dtas-all@nongnu.org; Sun, 02 Jul 2023 20:43:18 -0400 Received: from dcvr.yhbt.net ([173.255.242.215]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qG7eu-0005zW-Eh for dtas-all@nongnu.org; Sun, 02 Jul 2023 20:43:17 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7A5B41F547 for ; Mon, 3 Jul 2023 00:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1688344987; bh=IoU9S0TT0wZueSJiapFIzz3CddqyDm2L8RypGEmGW+M=; h=From:To:Subject:Date:From; b=epylQW6qqqmHRMUhwk/1fcZcE6R4IrTJjUPpfVYmRysbg36DYJfQUQBsIUAqsTDmp /O5VqI0MOHv+xYo8JkwGTlRnH0bI+jD/g93HCwjIHxATv+zrY86I8A4sT5/oTR918W E8GJEnDpQw4ovVVdPDSrrqVoXxbiuA9OIwqI6qs8= From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH] dtas-archive: support -m/--match=REGEXP switch Date: Mon, 3 Jul 2023 00:43:07 +0000 Message-ID: <20230703004307.928267-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=173.255.242.215; envelope-from=e@80x24.org; helo=dcvr.yhbt.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+e=80x24.org@nongnu.org Sometimes I only want to archive files matching a certain regexp pattern. --- Documentation/dtas-archive.pod | 11 ++++++++++- bin/dtas-archive | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Documentation/dtas-archive.pod b/Documentation/dtas-archive.pod index 157ea70..50237e8 100644 --- a/Documentation/dtas-archive.pod +++ b/Documentation/dtas-archive.pod @@ -52,11 +52,20 @@ Continue after error Number of times to repeat the L check. Default: 1 +=item -m, --match REGEX + +Only archive files matching a given Ruby (or Perl-compatible) regular +expression. The regular expression is implementation-dependent and +using the Perl-compatible subset of Ruby regexps is recommended as dtas +will be moving away from Ruby at some point. + +Added for dtas v0.22.0 + =back =head1 COPYRIGHT -Copyright 2013-2020 all contributors L +Copyright all contributors L License: GPL-3.0+ L diff --git a/bin/dtas-archive b/bin/dtas-archive index c88873e..7c0e4f7 100755 --- a/bin/dtas-archive +++ b/bin/dtas-archive @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -# Copyright (C) 2015-2020 all contributors +# Copyright (C) all contributors # License: GPL-3.0+ # frozen_string_literal: true usage = "#$0 SOURCE DESTINATION" @@ -30,6 +30,7 @@ keep_going = false compression = [] comment = [] +match = nil OptionParser.new('', 24, ' ') do |op| op.banner = usage @@ -47,6 +48,7 @@ op.on('-r', '--repeat [COUNT]', 'number of times to check', Integer) do |r| repeat = r end + op.on('-m', '--match=REGEX', String) { |s| match = Regexp.new(s) } op.on('-s', '--quiet', '--silent') { silent = true } op.on('-h', '--help') do puts(op.to_s) @@ -55,6 +57,7 @@ op.parse!(ARGV) end +match ||= %r/./ comment.push('--comment', '') if comment.empty? dst = ARGV.pop @@ -67,6 +70,7 @@ src_st = File.stat(s) if src_st.directory? Find.find(s) do |path| + path =~ match or next File.file?(path) or next dir = File.dirname(path) dir_st = File.stat(dir)