compiler/
lib/
scripts/
count-lines-no-comments.sh
1.2 KiB
count-lines.sh
1.1 KiB
objdump
63 B
seed/
sublime/
test/
vim/
.gitignore
336 B
.gitsigners
112 B
CONTRIBUTING
2.1 KiB
LICENSE
1.1 KiB
Makefile
4.1 KiB
README
2.5 KiB
STYLE
2.6 KiB
std.lib
1.2 KiB
std.lib.test
347 B
scripts/count-lines-no-comments.sh
raw
| 1 | #!/bin/sh |
| 2 | # Count non-blank, non-comment lines in .rad files, skipping tests. |
| 3 | |
| 4 | if [ "$#" -eq 0 ]; then |
| 5 | set -- . |
| 6 | fi |
| 7 | |
| 8 | tmpList=$(mktemp) |
| 9 | tmpFiles=$(mktemp) |
| 10 | trap 'rm -f "$tmpList" "$tmpFiles"' EXIT HUP INT TERM |
| 11 | |
| 12 | for input in "$@"; do |
| 13 | if [ -d "$input" ]; then |
| 14 | find "$input" -type f -name "*.rad" -not -path "*/tests/*" -not -name "tests.rad" >> "$tmpList" |
| 15 | elif [ -f "$input" ]; then |
| 16 | case "$input" in |
| 17 | */tests/*|*/tests.rad|tests.rad) |
| 18 | ;; |
| 19 | *.rad) |
| 20 | printf '%s\n' "$input" >> "$tmpList" |
| 21 | ;; |
| 22 | *) |
| 23 | echo "Error: File '$input' is not a .rad file" >&2 |
| 24 | exit 1 |
| 25 | ;; |
| 26 | esac |
| 27 | else |
| 28 | echo "Error: Path '$input' does not exist" >&2 |
| 29 | exit 1 |
| 30 | fi |
| 31 | done |
| 32 | |
| 33 | echo "Counting non-blank, non-comment lines in .rad files for inputs: $*" |
| 34 | echo "---------------------------------------------------------------------" |
| 35 | |
| 36 | total=0 |
| 37 | sort -u "$tmpList" > "$tmpFiles" |
| 38 | |
| 39 | while IFS= read -r file; do |
| 40 | if [ -f "$file" ]; then |
| 41 | count=$(grep -v '^[[:space:]]*$' "$file" | grep -v '^[[:space:]]*//' | wc -l) |
| 42 | total=$((total + count)) |
| 43 | printf "%6d %s\n" "$count" "$file" |
| 44 | fi |
| 45 | done < "$tmpFiles" |
| 46 | |
| 47 | echo "---------------------------------------------------------------------" |
| 48 | printf "%6d TOTAL\n" "$total" |