Created
September 22, 2015 11:42
-
-
Save jordiclariana/a357f676c298a430fc98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
YAML="${1}" | |
[ -f "${YAML}" ] || { echo "No such file as '${YAML}'"; exit 1; } | |
eyaml decrypt -e "${YAML}" | awk ' | |
{ | |
l=$0; | |
getline nl; | |
if (nl ~ /DEC::PKCS7\[/) { | |
eb=1; # Encrypted block | |
spaces=gensub(/^( *).*/,"\\1","",nl) # Get the indentation | |
gsub(/DEC::PKCS7\[/, "", nl); # Get rid of the descryption header | |
gsub(/>/,"|",l); # subsitute > for | | |
# Print the blocks | |
print l; | |
print nl; | |
} else { | |
if (eb==1) { # We are into the encrypted block | |
if ($1 != "]!") { # Not the end of encrypted block | |
# Print with original identation | |
printf("%s%s\n", spaces, l); | |
printf("%s%s\n", spaces, nl); | |
} else { # End of encrypted block, do not print the suffix | |
print nl; | |
eb=0 | |
} | |
} else { # Not in encrypted block, just print | |
print l; | |
print nl; | |
} | |
} | |
}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment