Skip to content

Commit

Permalink
rk: new dot-removal and relative-path logic - see "local" option
Browse files Browse the repository at this point in the history
  • Loading branch information
luxagen committed May 9, 2023
1 parent 713f902 commit 9da3772
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# RotKraken
TODO: libfile-chdir-perl

# RotKraken

## What is it?

Expand Down
14 changes: 13 additions & 1 deletion rk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ my @options_spec = (
Switch( '--quiet|-q')->doc('Suppress stdout logging' ),
Switch( '--unquiet|-Q')->doc('Force stdout logging (ignore .rk.quiet files)'),
Switch( '--export|-e')->doc('Log files to stdout in `md5deep -zl` format' ),
Switch( '--local|-l')->doc('Log paths as local to each argument' ),
Switch( '--init|-i')->doc('Initialise files that are missing metadata' ),
Switch( '--update|-u')->doc('Update metadata for changed files' ),
Switch( '--verify|-v')->doc('Verify initialised files against metadata' ),
Expand All @@ -35,6 +36,7 @@ STDERR->autoflush(1);

my $mode_clear = $options->get_clear ;
my $mode_export = $options->get_export ;
my $mode_local = $options->get_local ;
my $mode_init = $options->get_init ;
my $mode_update = $options->get_update ;
my $mode_verify = $options->get_verify ;
Expand Down Expand Up @@ -62,6 +64,14 @@ foreach my $item (@ARGV) {
}

foreach my $item (@ARGV) {
use File::chdir;
local $CWD;

if ($mode_local) {
$CWD = $item; # Scoped change-directory
$item = '.';
}

&item_process($item, $mode_quiet);
}

Expand Down Expand Up @@ -120,7 +130,9 @@ sub item_process {
foreach my $nested (readdir($handle)) {
next if $nested eq "." or $nested eq "..";
next if exists $kids_skip{$nested};
&item_process("$item/$nested", $quiet || defined $kids_quiet{$nested});

my $kidPath = ($item eq '.') ? $nested : "$item/$nested";
&item_process($kidPath, $quiet || defined $kids_quiet{$nested});
}

closedir($handle);
Expand Down
2 changes: 1 addition & 1 deletion rkdiff-stdin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ if [ "$#" -ne 1 ]; then
exit 1
fi

sort - | diff - <(rke "$1" | sort)
sort - | diff - <(rk -el "$1" | sort)

0 comments on commit 9da3772

Please sign in to comment.