dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles # fast
git clone https://src.adamsgaard.dk/dotfiles.git # slow
Log | Files | Refs | README | LICENSE Back to index

sisterfile (897B)


      1 #!/bin/sh
      2 # return header file name for source files, and vice versa
      3 
      4 die()
      5 {
      6 	printf '%s: error: %s\n' "${0##*/}" "$1" >&2
      7 	exit 1
      8 }
      9 
     10 print_if_file()
     11 {
     12 	if test -e "$1"; then
     13 		printf '%s\n' "$1"
     14 		exit
     15 	fi
     16 }
     17 
     18 case "$1" in
     19 	*.hh)
     20 		print_if_file "${1%.hh}.cc"
     21 		print_if_file "${1%.hh}.cpp"
     22 		print_if_file "${1%.hh}.cxx"
     23 		print_if_file "${1%.hh}.c"
     24 		;;
     25 	*.cc)
     26 		print_if_file "${1%.cc}.hh"
     27 		print_if_file "${1%.cc}.hpp"
     28 		print_if_file "${1%.cc}.hxx"
     29 		print_if_file "${1%.cc}.h"
     30 		;;
     31 	*.cpp)
     32 		print_if_file "${1%.cpp}.hpp"
     33 		print_if_file "${1%.cpp}.hh"
     34 		print_if_file "${1%.cpp}.hxx"
     35 		print_if_file "${1%.cpp}.h"
     36 		;;
     37 	*.cxx)
     38 		print_if_file "${1%.cxx}.hxx"
     39 		print_if_file "${1%.cxx}.hh"
     40 		print_if_file "${1%.cxx}.hpp"
     41 		print_if_file "${1%.cxx}.h"
     42 		;;
     43 	*.h)
     44 		print_if_file "${1%.h}.c";;
     45 	*.c)
     46 		print_if_file "${1%.c}.h";;
     47 	*)
     48 		die "file ending for $1 not supported";;
     49 esac
     50 exit 1