diff options
Diffstat (limited to 'posix-shell/utils.sh')
| -rw-r--r-- | posix-shell/utils.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/posix-shell/utils.sh b/posix-shell/utils.sh index 596263e..4354a37 100644 --- a/posix-shell/utils.sh +++ b/posix-shell/utils.sh @@ -216,3 +216,45 @@ url() { # open selected URL in browser firefox "${url}" } + +lar() { + temp="$(mktemp -d)" + tar -xf "$1" -C "$temp" + pushd "$temp" + lf + popd + rm -rf "$temp" +} + +hexdiff() { + if test "$#" -ne 2 + then + echo "Usage: hexdiff <file1> <file2>" + return 1 + fi + + dump1="$(mktemp)" + dump2="$(mktemp)" + + hexdump -C "$1" > "$dump1" + hexdump -C "$2" > "$dump2" + + diff --unified=4 --color=always "$dump1" "$dump2" + + rm -f "$dump1" "$dump2" +} + +lar() { + if test "$#" -ne 1 + then + echo "Usage: lar <archive-file>" + return 1 + fi + + temporary_directory="$(mktemp -d)" + tar -xf "$1" -C "$temporary_directory" + pushd "$temporary_directory" + lf + popd + rm -rf "$temporary_directory" +} |
