#!/bin/sh ## dictver -- dictionary versioning ## by C. Duckworth # # DICTVER is a new versioning scheme that I've just decided I will use # everywhere. It works like this: # # - Versions are words. # - If version A comes after version B in the dictionary, it's a later # version. # - If the first letter of version A is different than the first # letter of version B, it's a major (possibly backward-incompatible) # upgrade. # - Otherwise, it's a minor upgrade. # # This program will, when given the current version of a project, bump # that version to another one. See usage() for details. usage() { cat >&2 <&2 "$word" until grep -q "^$word" "$DICT" do word="${word%?}" #; echo >&2 "$word" done # echo >&2 "$word" grep -i -A "$MAX" "^$word" "$DICT" | head -n "$MAX" | while read -r line do test $((MIN--)) -ge 0 || echo "$line" done } next_letter() { case "$1" in (a*|A*) echo ^b ;; (b*|B*) echo ^c ;; (c*|C*) echo ^d ;; (d*|D*) echo ^e ;; (e*|E*) echo ^f ;; (f*|F*) echo ^g ;; (g*|G*) echo ^h ;; (h*|H*) echo ^i ;; (i*|I*) echo ^j ;; (j*|J*) echo ^k ;; (k*|K*) echo ^l ;; (l*|L*) echo ^m ;; (m*|M*) echo ^n ;; (n*|N*) echo ^o ;; (o*|O*) echo ^p ;; (p*|P*) echo ^q ;; (q*|Q*) echo ^r ;; (r*|R*) echo ^s ;; (s*|S*) echo ^t ;; (t*|T*) echo ^u ;; (u*|U*) echo ^v ;; (v*|V*) echo ^w ;; (w*|W*) echo ^x ;; (x*|X*) echo ^y ;; (y*|Y*) echo ^z ;; (*) echo >&2 "No more letters?!" ;; esac } main() { do_opts "$@"; shift $((OPTIND-1)) test -n "$1" || usage 1 get_context "$1" | sort -R | head -n1 } # set -x main "$@"