#!/bin/bash #----------------------------------------------- # Opens an RFC from the RFCs directory. If the # RFC isn't present it tries to fetch it. #----------------------------------------------- # # Version 1.2 # May 3, 2007 # Randall Gellens # #----------------------------------------------- RFC_DIR="$HOME/IETF/RFCs" # # For those of us who like BBEdit, often a # command-line flag or variant is used in # $EDITOR which doesn't return until the file # is closed. This is great for things like # crontab, but not so good when we want to just # open the file in the editor. So, if the # environment variable EDITOR_NOWAIT is defined, # use it, otherwise use EDITOR. # OPEN=${EDITOR_NOWAIT:-$EDITOR} if [ -z $OPEN ]; then echo "Neither \$EDITOR nor \$EDITOR_NOWAIT set" exit 1 fi if [ $# -eq 0 ]; then X=`basename $0` echo "usage: $X | \"index\""; exit 1 fi cd $RFC_DIR for rfcx do rfc="rfc${rfcx}.txt" #echo "rfc: $rfc" #echo `pwd` #echo `ls -l $rfc` # Special case 'index' if [ "$rfcx" == "index" ]; then $OPEN ../rfc-index.txt elif [ -f $rfc ]; then $OPEN $rfc elif [ ! -f $rfc ]; then echo "$rfcx not found locally; fetching..." /usr/local/bin/get_rfc $rfcx; if [ -f $rfc ]; then $OPEN $rfc else echo "RFC $rfcx does not exist"; fi; fi; done