github.com/qorio/etcd@v0.1.2-0.20131003183127-5cc585af9618/web/file2gostring.sh (about) 1 #!/bin/sh 2 3 # this file is copied from doozerd. 4 5 set -e 6 7 munge() { 8 printf %s "$1" | tr . _ | tr -d -c '[:alnum:]_' 9 } 10 11 quote() { 12 sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed 's/$/\\n/' | tr -d '\n' 13 } 14 15 pkg_path=$1 ; shift 16 file=$1 ; shift 17 18 pkg=`basename $pkg_path` 19 20 printf 'package %s\n' "$pkg" 21 printf '\n' 22 printf '// This file was generated from %s.\n' "$file" 23 printf '\n' 24 printf 'var ' 25 munge "`basename $file`" 26 printf ' string = "' 27 quote 28 printf '"\n'