#!/usr/bin/env bash OUTPUT_DIR="out" mkdir -p "$OUTPUT_DIR" if [[ ! -f "$OUTPUT_DIR/cgi-paths.txt" ]]; then find \ /home/pvv/?/*/web-docs \ -type f \ \( \ -name '*.cgi' \ -o -name '*.php' \ -o -name '*.php3' \ -o -name '*.pm' \ -o -name '*.pl' \ -o -name '*.sh' \ -o -name '*.bash' \ -o -name '*.phtml' \ -o -name '*.shtml' \ -o -name '*.lisp' \ -o -name '*.cl' \ \) \ 2>/dev/null \ | tee "$OUTPUT_DIR/cgi-paths.txt" fi if [[ ! -f out/perl-libs.txt ]]; then find \ /home/pvv/?/*/web-docs \ -type f \ \( \ -name '*.pm' \ -o -name '*.pl' \ \) \ -exec rg '^use ([^;]+);' {} -N -o -r '$1' \; \ 2>/dev/null \ | tee "$OUTPUT_DIR/perl-libs.txt" fi cat "$OUTPUT_DIR/perl-libs.txt" | sort > "$OUTPUT_DIR/perl-libs-tmp1.txt" # Remove import specifiers sed -E \ -e 's|\s*(qw)?\s*\(.*\)||g' \ -e 's|\s*(qw)?\s*\/.*\/||g' \ "$OUTPUT_DIR/perl-libs-tmp1.txt" | sort > "$OUTPUT_DIR/perl-libs-tmp2.txt" # Remove standard Perl modules comm -2 -3 "$OUTPUT_DIR/perl-libs-tmp2.txt" <(cat PERL_STANDARD_MODULES.txt | sort) > "$OUTPUT_DIR/perl-libs-tmp3.txt" # Remove pragmas readarray -t PERL_PRAGMAS < PERL_PRAGMAS.txt remove_pragmas_regex=$(printf '|^%s' "${PERL_PRAGMAS[@]}") remove_pragmas_regex="${remove_pragmas_regex:1}" # remove leading '| sed -E "/${remove_pragmas_regex}/d" "$OUTPUT_DIR/perl-libs-tmp3.txt" > "$OUTPUT_DIR/perl-libs-filtered.txt" cat "$OUTPUT_DIR/perl-libs-filtered.txt" | uniq -c | sort -gr > "$OUTPUT_DIR/perl-libs-overview.txt" if [[ ! -f "$OUTPUT_DIR/php-libs.txt" ]]; then find \ /home/pvv/?/*/web-docs \ -type f \ \( \ -name '*.php' \ -o -name '*.php3' \ -o -name '*.phtml' \ \) \ -exec rg '^use ([^;]+);' {} -N -o -r '$1' \; \ 2>/dev/null \ | tee "$OUTPUT_DIR/php-libs.txt" fi cat "$OUTPUT_DIR/php-libs.txt" | sort | uniq -c | sort -gr > "$OUTPUT_DIR/php-libs-overview.txt" if [[ ! -f "$OUTPUT_DIR/cgi-progs.txt" ]]; then readarray -t BIN_LOCATIONS < BIN_LOCATIONS.txt bin_locations_regex=$(printf '|%s' "${BIN_LOCATIONS[@]}") bin_locations_regex="${bin_locations_regex:1}" # remove leading '|' bin_locations_regex="(?:${bin_locations_regex})" find \ /home/pvv/?/*/web-docs \ -type f \ \( \ -name '*.cgi' \ -o -name '*.php' \ -o -name '*.php3' \ -o -name '*.pm' \ -o -name '*.pl' \ -o -name '*.sh' \ -o -name '*.bash' \ -o -name '*.phtml' \ -o -name '*.shtml' \ -o -name '*.lisp' \ -o -name '*.cl' \ \) \ -exec rg "$bin_locations_regex/(?:env\s*)?(\w+(?:/\w+)*)" {} -N -o -r '$1' \; \ 2>/dev/null \ | tee "$OUTPUT_DIR/cgi-progs.txt" fi cat "$OUTPUT_DIR/cgi-progs.txt" | sort | uniq -c | sort -gr > "$OUTPUT_DIR/cgi-progs-overview.txt" # TODO find lisp libraries