Reviewed-on: StarOpenSource/core#1 Rewrote CORE and improved the startup process and startup time significantly. The documentation has been beefed up too and is now much better. Existing projects may need major refactoring however. Co-authored-by: JeremyStarTM <jeremystartm@staropensource.de> Co-committed-by: JeremyStarTM <jeremystartm@staropensource.de>
52 lines
1.6 KiB
Bash
Executable file
52 lines
1.6 KiB
Bash
Executable file
#!/bin/bash
|
|
if [ "$1" == "--help" ]; then
|
|
echo "Environment variables: VERBOSE (false)"
|
|
echo " FILEEXTENSION (*)"
|
|
echo " IGNORE_SCRIPT (false)"
|
|
echo " IGNORE_DOCUMENTATION (false)"
|
|
echo " NUMBER_ONLY (false)"
|
|
exit 0
|
|
fi
|
|
function dircount() {
|
|
if [ "$VERBOSE" == "true" ]; then echo ":: Checking directory \"$*\"..."; fi
|
|
cd "$*" || exit 54
|
|
for file in $FILEEXTENSION; do
|
|
export "file_full=$*/$file"
|
|
if [ -d "$file" ]; then
|
|
if [ "$file" == "devprj" ]; then
|
|
if [ "$VERBOSE" == "true" ]; then echo ":: Skipping directory \"devprj\"";fi
|
|
else
|
|
if [ "$IGNORE_DOCUMENTATION" == "true" ] && [ "$file" == "docs" ]; then
|
|
if [ "$VERBOSE" == "true" ]; then echo ":: Skipping directory \"docs\"";fi
|
|
else
|
|
dircount "$file_full"
|
|
fi
|
|
fi
|
|
elif [ -f "$file" ]; then
|
|
if [ "$IGNORE_SCRIPT" == "true" ] && [ "$file" == "count_characters.sh" ]; then
|
|
if [ "$VERBOSE" == "true" ]; then echo ":: Skipping this script"; fi
|
|
else
|
|
if [ "$VERBOSE" == "true" ]; then echo ":: Counting characters in file \"$file_full\"..."; fi
|
|
export "COUNT_FILE=$(wc -m < "$file_full")"
|
|
export "COUNT=$((COUNT + COUNT_FILE))"
|
|
fi
|
|
else
|
|
if [ "$VERBOSE" == "true" ]; then echo ":: Skipping \"$file_full\" (no file or directory)"; fi
|
|
fi
|
|
done
|
|
cd ..
|
|
}
|
|
if [ "$FILEEXTENSION" == "" ]; then
|
|
export "FILEEXTENSION=*"
|
|
fi
|
|
if [ "$*" == "" ]; then
|
|
dircount "$(pwd)"
|
|
else
|
|
dircount "$(pwd)/$*"
|
|
fi
|
|
if [ "$VERBOSE" == "true" ]; then echo ""; fi
|
|
if [ "$NUMBER_ONLY" == "true" ]; then
|
|
echo "$COUNT"
|
|
else
|
|
echo "Characters counted: $COUNT"
|
|
fi
|