dd-ex: the start of the script

The first essential thing to do is to make sure we are not cheating. Therefore we save the paths of dd and rm in variables, and reset PATH to the empty string.
  #!/bin/sh

  # this is a line editor using only /bin/sh, /bin/dd and /bin/rm

  PATH=
  dd=/bin/dd
  rm=/bin/rm
Since rm is only needed to remove the temporary files, we can use a trap to do so - and then forget about rm.
  # temporary files we might need
  tmp=/tmp/silly.$$
  ed=/tmp/ed.$$
  trap "$rm -f $tmp $tmp.1 $tmp.2 $tmp.3 $tmp.4 $tmp.5 $tmp.6 $ed.a $ed.b $ed.c; exit" 0 1 2 3

  # from now on, no more rm - the above trap is enough
  unset rm
Some of the functions set the shell's field separator to weird values to split strings. We save the default value here just in case
  saveIFS="$IFS"
Finally, we keep using two functions, true and false, to control loops. The idiom is:
  go=true
  while $go
  do
    case "something" in
      "value") go=false ;;
    esac
  done
For simplicity, the functions are defined here right at the start:
  true () {
    return 0
  }

  false () {
    return 1
  }