[svlug] Calcurse Mail Reminder

Jesse Monroy jesse650 at gmail.com
Mon Jan 19 23:11:43 PST 2015


On 1/18/15, Scott DuBois <rhcom.linux at gmail.com> wrote:
> So I've been working with this program Calcurse which is a console based
> calendaring/scheduling program. It's cool but, I wanted it to send me
> reminders
> either by email or text so I wrote a bash script to do that.
>
> The bash script reads the message file and compares the current date to the
::::SNIP::::
>

Scott,
I read through your script and I would make a few Stylistic changes.
Again style, mostly for read ability.

ON Line 33 you have:
     if [ "$today" != '' ]; then

I would change this to:
     if [ X"$today" != X"" ]; then

There are two (2) changes:

1) The consistent use of double quotes (")
There is technically nothing wrong with with what you wrote; it will
work on most all shells.
However, for human readability the consistent use of double quotes (")
makes such
that the reader (user) does not have to do a double take, and possible
waste time
copying and pasting to verify that the codes is syntactically correct.

2) The use of the "X" is a trick I learned to validate the results.
For some scripting engines, namely Javascript, there is a big
difference between:
* empty string
* null (value)
* undefined (value or variable)

The "X" means there are less nuances you need to think about when scripting,
and NOT just Javascript. I've been bitten by similar issues when dealing with
awk, sed, PERL, TCL, and YACC.

To be clear, you won't need to use "X" everywhere, but for basic shell scripts
it's a pretty cool trick.

ON Line 57 you have:

  else

Your indentation appears to be off. This is technically not a problem, but
if you get to coding Python, python gets to ornery.

That's it
Jesse



More information about the svlug mailing list