diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-05-08 19:19:41 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-05-08 19:19:41 +0200 |
| commit | 82bcfe3f25b1f0c08c93fd35497019b546e24ce2 (patch) | |
| tree | 055309330ff16f6d3f754b2ef6eaff92fe3925ed /scripts/sdep-add | |
| parent | 61d15dd4854fe4607442b87602448d6dee16b6a8 (diff) | |
| download | sdep-82bcfe3f25b1f0c08c93fd35497019b546e24ce2.tar.gz sdep-82bcfe3f25b1f0c08c93fd35497019b546e24ce2.zip | |
First commit, v0.1
Diffstat (limited to 'scripts/sdep-add')
| -rwxr-xr-x | scripts/sdep-add | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/sdep-add b/scripts/sdep-add new file mode 100755 index 0000000..bb0b2c8 --- /dev/null +++ b/scripts/sdep-add | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Adds a line to SDEPDATA/once. It is possible to specify a date, which will be | ||
| 4 | # read by date -d and prepended to the input text. | ||
| 5 | # -d is a non-portable option of GNU date. On some other systems one can | ||
| 6 | # accomplish the same with the -j option. | ||
| 7 | |||
| 8 | # Usage: sdep-add [date] | ||
| 9 | # Example: sdep-add "next monday" | ||
| 10 | |||
| 11 | file="SDEPDATA/once" | ||
| 12 | date="" | ||
| 13 | |||
| 14 | [ -n "$1" ] && date=$(date -d "$1" +%Y-%m-%d) | ||
| 15 | |||
| 16 | [ -n "$date" ] && printf "$date " | ||
| 17 | |||
| 18 | read text | ||
| 19 | |||
| 20 | if [ -n "$text" ]; then | ||
| 21 | printf "${date}\t${text}\n" >> "$file" | ||
| 22 | else | ||
| 23 | echo "Event not saved" | ||
| 24 | fi | ||
