help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] progress bar in bash


From: Matthew Cengia
Subject: Re: [Help-bash] progress bar in bash
Date: Tue, 22 Jul 2014 22:13:02 +1000
User-agent: Mutt/1.5.21 (2010-09-15)

On 2014-07-22 10:11, Paolo Supino wrote:
> This email is a open heart surgery to the progress bar drawing, feel free
> to rip it apart as you see fit...

Since it's late in my timezone, and I'm not really feeling up to writing
a lengthy response about everything that's wrong (stylistically etc.)
with this script, here are a few things that jumped out at me just by
glanceing at it:

* Send the entire script through http://www.shellcheck.net/, fixing any
  problems it finds
* Use more quotes. There are lots of unquoted variable expansions
* Don't pass arguments to echo. I realise this is a bash script, and
  echo can be assumed to handle -e and -n, but just use printf instead;
  that's what it's for.
* Don't use seq; it's old and a separate program. Use brace expansion
  {1..10} or, if doing a loop, use a C-style loop as you've used
  elsewhere in the code.
* You use [[ for numeric comparison (e.g. [[ $percent -le 100 ]]).
  Better to use (( arithmetic operators instead.
* Do *NOT* manually echo terminal escape sequences. Use tput to generate
  them based on termcap etc. I can only see one instance where you don't
  use tput: echo -en "\033[6n" > /dev/tty
* You don't need to use == inside [[; one = is sufficient.
* You use bc where I think you can just as easily use ((a*b)); unless
  you're dealing with float, which I don't think you are.

Hopefully this is helpful.

-- 
Regards,
Matthew Cengia

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]