I get annoyed each time I have to mess around with files when I want to edit a file which is on the rom, so I wrote a small (well it was when I started..) script to wrap vi. The basic idea is that you type romvi and then you can edit the file.
I'm no shell expert - it works for me but could probably be cleaned up a lot (I couldn't figure out the ash syntax so I used sed for almost everything)..
#!/bin/sh
# Clean up the path a bit
if [ "$(echo "$1" | sed 's!^/.*!!')" = "" ]; then
file=$1
else
file=$(echo "$(pwd)/$1" | sed 's![^/]+/../!!')
fi
rom="/rom$file"
# Replace file with the real file (if linked to /rom)
if [ -s "$file" ]; then
link=$(ls -l "$file" | sed -e's/.*-> //')
if [ $(echo "$link" | sed 's!/rom!!') = "$file" -a "$link" != "$file" ]; then
rm "$file"
cp $link $file
fi
fi
/rom/bin/vi $*
# Check if file is the same as /rom
if [ -f "$file" ]; then
rommd5="$(md5sum "$rom" | awk '{print $1}')"
filemd5="$(md5sum "$file" | awk '{print $1}')"
if [ "$rommd5" = "$filemd5" -a "$rom" != "$file" ]; then
ln -sf $rom $1
fi
fi
Todo/thoughts:
Maybe store files in /tmp so we don't use flash more than needed.
Think about replacing vi with this?