Created
November 21, 2012 03:31
-
-
Save creade/4122834 to your computer and use it in GitHub Desktop.
selfDoc
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/sh | |
cat <<EOT >doced | |
#!/bin/sh | |
printCut() { | |
while IFS= read -t 1 piped | |
do | |
my_array=("\${my_array[@]}" "\$piped") | |
done | |
printed=0 | |
for i in "\${my_array[@]}" | |
do | |
if [ \$printed == 0 ] | |
then | |
echo \$@ 1>&2 | |
printed=1 | |
fi | |
echo "\$i" 1>&2 | |
done | |
for j in "\${my_array[@]}" | |
do | |
echo "\$j" | |
done | |
} | |
EOT | |
cat $@ | grep -Ev '#!/bin/sh' | | |
sed 's/\(cut [^|]*\)/ \1 | printCut "Using { \1 }"/g'| | |
sed 's/\(awk [^|]*\)/ \1 | printCut "Using { \1 }"/g'| | |
sed 's/\(grep [^|]*\)/ \1 | printCut "Using { \1 }"/g'| | |
sed 's/\(sort [^|]*\)/ \1 | printCut "Using { \1 }"/g'| | |
sed 's/tee \/dev\/tty/printCut "teeing"/g' | | |
perl -pi -e "s/(sed.*?(').*?(').*?([^|]*))/ \1 | printCut \"Using { \1 }\" /g"| | |
perl -pi -e "s/(perl.*?(').*?(').*?([^|]*))/ \1 | printCut \"Using { \1 }\" /g" >> doced |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment