From c5808b668c8f4ab33e30ecc4e0b580cd6320d7e0 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 5 Oct 2022 01:35:48 -0700 Subject: [PATCH] util: fit dedupe into a 80x48 screen --- notwa-util/dedupe | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/notwa-util/dedupe b/notwa-util/dedupe index ad10bf7..83c2c65 100755 --- a/notwa-util/dedupe +++ b/notwa-util/dedupe @@ -1,5 +1,4 @@ #!/usr/bin/env sh - # Copyright (C) 2022 Connor Olding usage='dedupe [OPTION...] {SOURCE} {TARGET} [FILE...] @@ -14,8 +13,15 @@ Optional file arguments allow for finer control of the order of files seen. This software is provided WITHOUT WARRANTY under the terms of the ISC license. ' -read -r program <<'EOF' -BEGIN{if(!D){print U;exit 64}E=(Q="'")"\"'\""Q;H=(G=".")(F="/");I=" -- "Q;J="[^/]*/";sub(F"?$",F,D)gsub(Q,E,D)}function C(x){if(X=system(x))exit X}{if((p=$2)==B){print V;exit 65}for(r=z=i=d=B;d!=!i;i++){b=a=p;d=sub("/.*",B,a);sub(J,B,p);if(a==G G)e=!sub(J,B,z);else z=a==G?z:b!=a?z a F:z a;if(e||!i&&!a){print W;exit 65}}P=p=!z?H:z;if((o=O[$1])==p)next;gsub(Q,E,P);M=m=D P;gsub("/[^/]+$",B,M);if(!u[M]++)C("mkdir -p"I M Q);if(o){T=split(o,t,F);S=split(p,s,F);for(i=1;t[i]==s[i];i++);for(j=i;j&2 "$2"; exit "$1" ;}