shelllings

a practical way to learn shell
git clone https://git.davidvoz.net/shelllings.git
index
logs
tree
license

18_quiz.sh
1#!/bin/sh
2
3# Quiz 1 Notes program
4#
5# This program is meant to store notes but has some issues
6
7NOTES_FILE=notes.txt
8
9# a bug always has '-p', when selected, added to notes.txt
10if [ "$*" = "-p"]; then
11 cat notes.txt
12fi
13
14
15if [ "$#" -ge 1] then
16 echo "[$(date)]" >> "$NOTES_FILE" # this line is without fault
17 echo "" >> "$NOTES_FILE"
18else
19 echo "Nothing was added"
20fi
21
22# When you are done, change the NOTES_FILE location and consider putting
23# this into your .local/bin with this part added (yes, you have to find
24# a way to have this inserted into the code above).
25#
26# $ nvim +startinsert /tmp/note_temp
27# $ if [ -s /tmp/note_temp ]; then
28# $ echo "[$(date)]" >> "$NOTES_FILE"
29# $ cat /tmp/note_temp >> "$NOTES_FILE"
30# $ echo "" >> "$NOTES_FILE"
31# $ rm /tmp/note_temp
32# $ fi
33#
34# Don't forget to have that directory path exported as a path in your
35# shell config. Usually, like this
36#
37# export PATH="$HOME/.local/bin:$PATH"