Only non whitespace characters are left in the string.
Both Rich (with the '$1=$1' idea) and Paul_123 hint at a more general solution for whitespace. Noted.
I made a small change to treegen.awk: Rather than eliminating trailing whitespace, it now eliminates all whitespace.
The result: We only process lines that contain ".tcz", and only after we've stripped any whitespace.
#!/usr/bin/awk -f
# treegen.awk v3.2 (May 5, 2026)
# usage example: $ treegen.awk labwc.tcz
BEGIN {
N_SPACES = 0
LINUX_VERSION = "6.18.2-tinycore64"
MIRROR_PATH = "/mnt/usb/http/tinycorelinux/17.x/x86_64/tcz/"
get_dependencies(ARGV[1])
}
function get_dependencies(tczname, line) {
gsub(/KERNEL/, LINUX_VERSION, tczname)
printf("%"N_SPACES"s%s\n", "", tczname)
N_SPACES+=3
if (getline line <(MIRROR_PATH tczname ".dep") > 0) {
do {
if (line ~ /\.tcz/) { # because some .dep files have blank lines
gsub(/[ \t\r]+/, "", line) # because some lines in .dep files have whitespace
get_dependencies(line)
}
} while (getline line <(MIRROR_PATH tczname ".dep") > 0)
close(MIRROR_PATH tczname ".dep")
}
N_SPACES-=3
}I did some tests and this version is actually slightly faster than treegen.awk 3.1. I'm on C++'s heels now

awk C++
Size ~900 bytes ~25K bytes
Time to generate vlc-dev.tcz.tree 0.45 Secs. 0.31 Secs.