From 9e5ed8416dc69cc904ab495f55feab164a7d6ad9 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Fri, 28 Apr 2017 21:06:31 +0200 Subject: [PATCH 1/4] tracefile: added --file. --- README | 22 ++++++++++++++++------ tracefile/tracefile | 34 +++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/README b/README index d91322d..783bbd3 100644 --- a/README +++ b/README @@ -2,6 +2,8 @@ Tools developed by Ole Tange . Probably not useful for you, but then again you never now. +blink - blink disks in a disk enclosure + bsearch - binary search through sorted text files. em - Force emacs to run in terminal. Use xemacs if installed. @@ -10,32 +12,40 @@ field - Split on space. Give the given field number. Supports syntax 1-3,6- forever - Run the same command or list of commands every second. -G - short hand for multi level grep. +G - shorthand for multi level grep. gitnext - Checkout next revision. Opposite of 'checkout HEAD^'. -gitundo - Undo last commit. +histogram - make and display a histogram on the command line. neno - No error no output. Only print STDERR and STDOUT if the command fails. -puniq - Print unique lines the first time they are seen. - pdfman - Convert man page to pdf and display it using evince. -rand - Generate (pseudo-)random data +puniq - Print unique lines the first time they are seen. + +ramusage - Display the ram usage of a program using `time -v`. + +rand - Generate (pseudo-)random data. rclean - Remove files with MD5 sums recorded by rrm (see below). reniced - Renice all commands running more than 1 CPU minute unless they are niced or whitelisted. -rn - Move file(s)/dir(s) to ~/.rm/ (wastebasket). +rn - Move file(s)/dir(s) to .rm/ (wastebasket). rrm - Record file's MD5 sum before removing it. stdout - Redirect both STDERR and STDOUT to STDOUT. +T - tee stdout to and from temporary files. + +timestamp - prepend timestamp to output. + tracefile - List files/dirs being accessed by program. +upsidedown - flip input upside down. + w4it-for-port-open - Block until the given port opens on a given host. wastebasket - VLC extension for moving current file to a wastebasket diff --git a/tracefile/tracefile b/tracefile/tracefile index b57e72c..3b6ded0 100755 --- a/tracefile/tracefile +++ b/tracefile/tracefile @@ -6,9 +6,9 @@ tracefile - list files being accessed =head1 SYNOPSIS -B [-adenu] I +B [-adefnu] I -B [-adenu] -p I +B [-adefnu] -p I =head1 DESCRIPTION @@ -44,6 +44,13 @@ List only dirs. List only existing files. +=item B<-f> + +=item B<--file> + +List only files. + + =item B<-n> =item B<--nonexist> @@ -81,7 +88,8 @@ know which one. Here B tries to find B. If it fails, B will search for which package it is in: - tracefile -n -u ls /usr/include/shisa.h | apt-file -f search - + tracefile -n -u ls /usr/include/shisa.h | apt-file -f search - | + grep /usr/include/shisa.h =head1 REPORTING BUGS @@ -90,7 +98,7 @@ Report bugs to . =head1 AUTHOR -Copyright (C) 2012,2016 Ole Tange, http://ole.tange.dk and Free +Copyright (C) 2012,2016,2017 Ole Tange, http://ole.tange.dk and Free Software Foundation, Inc. @@ -220,7 +228,7 @@ $Global::progname = "tracefile"; Getopt::Long::Configure("bundling","pass_through"); get_options_from_array(\@ARGV) || die_usage(); -if(not ($opt::exists or $opt::nonexists or $opt::all or $opt::dir)) { +if(not ($opt::exists or $opt::nonexists or $opt::all or $opt::dir or $opt::file)) { $opt::all = 1; } @@ -240,17 +248,16 @@ while() { my $file = shell_unquote($1); # Relative to $dir $file =~ s:^([^/]):$dir/$1:; - my $print = 0; - if($opt::all + my $print = 1; + if(($opt::dir and not -d $file) or - ($opt::exists and -e $file) + ($opt::file and not -f $file) or - ($opt::dir and -d $file) + ($opt::exists and not -e $file) or - ($opt::nonexists and not -e $file)) { - $print = 1; - } - if($opt::unique and $seen{$file}++) { + ($opt::nonexists and -e $file) + or + ($opt::unique and $seen{$file}++)) { $print = 0; } $print and print $file,"\n"; @@ -262,6 +269,7 @@ sub options_hash { return ("debug|D" => \$opt::debug, "dir|d" => \$opt::dir, + "file|f" => \$opt::file, "uniq|unique|u" => \$opt::unique, "exists|exist|e" => \$opt::exists, "nonexists|nonexist|non-exists|non-exist|n" => \$opt::nonexists, From 16daa13aa11c3bdb005b92761cb6a3e7c1fc7e66 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sun, 4 Jun 2017 22:34:00 +0200 Subject: [PATCH 2/4] WasteBasket.lua: shell quote dir name to allow for special chars. --- wastebasket/WasteBasket.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wastebasket/WasteBasket.lua b/wastebasket/WasteBasket.lua index 1b8cfa2..a56469f 100644 --- a/wastebasket/WasteBasket.lua +++ b/wastebasket/WasteBasket.lua @@ -83,6 +83,9 @@ end function directory_exists(dir) -- Simple checker if dir exists + -- shell quote the dirname + dir, _ = dir:gsub("([\002-\009\011-\026\\#?`(){}%[%]^*<>=~|; \"!$&'\130-\255])", "\\%1") + dir, _ = dir:gsub("\n", "'\n'") return os.execute("cd " .. dir) end From 553bc96f37ea00324d65310912cc5ebd8b187fd6 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sun, 4 Jun 2017 22:35:59 +0200 Subject: [PATCH 3/4] encdir: Mount encrypted dir with encfs. Make it if it does not exist. --- Makefile | 8 +++--- encdir/encdir | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 4 deletions(-) create mode 100755 encdir/encdir diff --git a/Makefile b/Makefile index e96cb7b..2c83057 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -CMD = blink bsearch em field forever G gitnext goodpasswd histogram \ -neno pdfman puniq ramusage rand rclean rn rrm stdout T timestamp \ -tracefile upsidedown w4it-for-port-open wifi-reload wssh +CMD = blink bsearch em encdir field forever G gitnext goodpasswd \ +histogram neno pdfman puniq ramusage rand rclean rn rrm stdout T \ +timestamp tracefile upsidedown w4it-for-port-open wifi-reload wssh -all: blink/blink.1 bsearch/bsearch.1 G/G.1 gitnext/gitnext.1 goodpasswd/goodpasswd.1 histogram/histogram.1 neno/neno.1 pdfman/pdfman.1 puniq/puniq.1 rand/rand.1 rn/rn.1 rrm/rrm.1 stdout/stdout.1 timestamp/timestamp.1 tracefile/tracefile.1 T/T.1 upsidedown/upsidedown.1 wifi-reload/wifi-reload.1 wssh/wssh.1 +all: blink/blink.1 bsearch/bsearch.1 encdir/encdir.1 G/G.1 gitnext/gitnext.1 goodpasswd/goodpasswd.1 histogram/histogram.1 neno/neno.1 pdfman/pdfman.1 puniq/puniq.1 rand/rand.1 rn/rn.1 rrm/rrm.1 stdout/stdout.1 timestamp/timestamp.1 tracefile/tracefile.1 T/T.1 upsidedown/upsidedown.1 wifi-reload/wifi-reload.1 wssh/wssh.1 %.1: % pod2man $< > $@ diff --git a/encdir/encdir b/encdir/encdir new file mode 100755 index 0000000..c433f9c --- /dev/null +++ b/encdir/encdir @@ -0,0 +1,73 @@ +#!/bin/bash + +: <<=cut +=pod + +=head1 NAME + +encdir - mount encfs dir or create it if missing + + +=head1 SYNOPSIS + +B I + + +=head1 DESCRIPTION + +B uses B to mount I.enc on I. + +If I or I.enc do not exist then they will be created. + +=head1 EXAMPLE + +Mount mydir.enc on mydir: + + encdir mydir + +=head1 AUTHOR + +Copyright (C) 2017 Ole Tange, +http://ole.tange.dk and Free Software Foundation, Inc. + + +=head1 LICENSE + +Copyright (C) 2012 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +at your option any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + + +=head1 DEPENDENCIES + +B uses B. + + +=head1 SEE ALSO + +B + + +=cut + + +if [ -z "$2" ] ; then + fusermount -u $1 2>/dev/null + encfs `readlink -f $1.enc` `readlink -f $1` +else + fusermount -u `readlink -f $2` 2>/dev/null + encfs `readlink -f $1` `readlink -f $2` +fi + + From 84d6f499b7768411adac91132a84e3f442790724 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sun, 4 Jun 2017 22:37:10 +0200 Subject: [PATCH 4/4] stdout: Keep exit code. --- stdout/stdout | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdout/stdout b/stdout/stdout index 99852dc..183ff90 100755 --- a/stdout/stdout +++ b/stdout/stdout @@ -1,7 +1,5 @@ #!/bin/bash -"$@" 2>&1 - : <<=cut =encoding utf8 @@ -54,3 +52,5 @@ B(1) =cut + +"$@" 2>&1