[dev] a suckless hex editor

From: Greg Reagle <greg.reagle_AT_umbc.edu>
Date: Fri, 13 Nov 2015 11:28:36 -0500

What do you think? I was afraid to overwrite the infile so I make the
user specify an outfile. Maybe if I did better error checking it would
be okay to overwrite?

The user can choose to overwrite by specifying the same file for both
infile and outfile.

#!/bin/sh

[ -z "$1" -o -z "$2" ] && { echo "$0 infile outfile"; exit 1; }
[ -z "$EDITOR" ] && { echo "\$EDITOR must be defined"; exit 1; }

infile="$1"
outfile="$2"
dump="xxd -g1"
dedump="xxd -r"

tmpfile=$(mktemp)
$dump "$infile" > "$tmpfile"
$EDITOR "$tmpfile"
$dedump $tmpfile > "$outfile"
rm "$tmpfile"
Received on Fri Nov 13 2015 - 17:28:36 CET

This archive was generated by hypermail 2.3.0 : Fri Nov 13 2015 - 17:36:08 CET