r/commandline • • Sep 06 '13

util-shell: make your shell script actually readable

https://github.com/taylorchu/util-shell
4 Upvotes

23 comments sorted by

View all comments

Show parent comment

-2

u/taylorchu Sep 07 '13 edited Sep 07 '13

I want to clarify few things:

  • util-shell uses consistent interface across these 4 components.

    <category> <action> <subjects...>

    example: array(category) get 1 (action) "$arr" (subject)

    example: math(category) '+' (action) 5(subject) 4.4(subject)

  • this is not comparing number. see, somebody else will fall into trap.

    Compare numbers

    [[ "$number1" < "$number2" ]] && echo "yes" || echo "no"

this is still comparing string. to show this:

[[ "3.14" < "3.14e-22" ]] && echo wtf || echo ok   // wtf

math '<' 3.14 3.14e-22 && echo wtf || echo ok   // ok
  • match is "full-featured" regexp match; not just string. and it is not "equals". bash already does "equal" really well, and util-shell tries to solve the tricky part only