add format mode only

This commit is contained in:
q
2018-10-20 14:03:02 +03:00
parent 7711c4efae
commit fad5ce7df9

View File

@@ -7,6 +7,7 @@ function helpexit() {
echo " -s Summary mode, otherwise each argument folder calculated separate"
echo " -c Count files instead of summarizing sizes"
echo " -a Display animation while counting"
echo " -f # Format filesize to human readable. Command exits without scanning."
echo " --help This help"
exit
}
@@ -83,14 +84,25 @@ function displaysize() {
# Get options
what=()
for (( i=1; i<=$#; i++ )); do
[[ "${!i}" = "-a" ]] && { ANIMATE=1; continue; }
[[ "${!i}" = "-f" ]] && { FORMAT=1; ((i++)); FORMAT_VALUE=${!i}; continue; }
[[ "${!i}" = "--help" ]] && helpexit
[[ "${!i}" = "-h" ]] && { HUMAN=1; continue; }
[[ "${!i}" = "-c" ]] && { COUNT=1; continue; }
[[ "${!i}" = "-s" ]] && { SUMMARY=1; continue; }
[[ "${!i}" = "-a" ]] && { ANIMATE=1; continue; }
what+=( "${!i}" )
done
[[ -z "${what[@]}" ]] && what="."
# If formatting requested, do only that:
if [[ "$FORMAT" -eq 1 ]]; then
if [[ -z "$FORMAT_VALUE" ]]; then
echo -e "\nBytes argument missing\n\n"
helpexit
fi
filesize $FORMAT_VALUE
exit $?
fi
# If only one entry, dont print the name
[[ "${#what[@]}" -eq 1 ]] && SUMMARY=1