See the Security and Bug Fixes Section - Grub EFI Install Updates Fix Sticky


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shell script returning divide by zero error
#1
'lite-tweaks-super' returning the following error:


Code:
:~/$ lite-tweaks-super
/usr/bin/lite-tweaks-super: line 812: ((: PERCENTAGE = 100 * 1 / 0 : division by 0 (error token is "0 ")

The 'while read  line' loop should not in theory at least by the looks execute any iterations if '$TOTAL_LINES' is zero, my scripting is largely POSIX (blame BSD) and not Bash so off the top of my head I'm not entirely sure what is going on here:


Code:
## Arrays execution
run_icon=/usr/share/icons/Faenza/actions/32/system-run.png
x=0
for k in "${!ARRAYC}"; do  x=$(( $x + 1 )); done  # Get the total number of selected items in the array

    TOTAL_LINES=$x

    printf '%s \n' "${ARRAYC}"|
    while read  line
        do
            $line     # Execute functions one by one
            if [ $? = 1 ]; then
                zenity --info --title=" Lite Tweaks" --text="Error:\n${line}"
            fi
        let i++
         (( PERCENTAGE = 100 \* ${i} / ${TOTAL_LINES} ))
         echo "$PERCENTAGE"

        if [ "$PERCENTAGE" == "100" ]; then
            echo "#Done"
            sleep 1
        fi
Reply


Messages In This Thread
Shell script returning divide by zero error - by Tegid - 03-26-2017, 08:06 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)