eval-bob (971B)
1 #!/bin/sh 2 # 3 # Don't drink and code. 4 # Eval BOB! 5 # 6 # https://www.bob.be/ 7 # 8 # We want to create awareness of people writing code while being drunken. 9 # See PHP or Ruby on Rails for how to not do it. You will end up in a 10 # life of misery, where you cannot escape and need to keep going until 11 # your pension with some ugly language, reinventing what has been done 12 # before. Noone will remember you, since you write shit code and the next 13 # hype kid replaced your idea with their own hype, rewriting what you 14 # already did. 15 # 16 # Example BOB file: 17 # 18 # <?geomyidae echo hello bob ?> 19 # 20 # See index.bob for an example file. 21 # 22 23 if [ -z "$1" ]; 24 then 25 input="/dev/stdin" 26 else 27 input="$1" 28 fi 29 30 { 31 awk -v "bob=1" \ 32 'BEGIN { 33 print "cat <<BOBEND" bob ";" 34 } 35 /^#!\// && NR==1 { 36 next; 37 } 38 /<\?geomyidae/ { 39 sub(/<\?geomyidae/, "BOBEND" bob "\n"); 40 bob=bob+1; 41 } 42 /\?>/ { 43 sub(/?>/,"\ncat <<BOBEND" bob ";\n"); 44 } 45 { 46 print; 47 } 48 END { 49 print "BOBEND" bob 50 } 51 ' "${input}" 52 } | sh 53