-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkexerc
executable file
·54 lines (44 loc) · 1.75 KB
/
mkexerc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# ------------------------------------------------------------------------------
# settings settings
# ------------------------------------------------------------------------------
set -o errtrace # any trap on ERR is inherited by shell functions,
# command substitutions, and commands executed in a subshell
# environment
set -o nounset # treat unset variables and parameters other than the special
# parameters "@" and "*" as an error when performing
# parameter expansion
set -o pipefail # the return value of a pipeline is the value of the last
# (rightmost) command to exit with a non-zero status, or
# zero if all commands in the pipeline exit successfully
# set language
export LANG="en_US.UTF-8"
# use dot as decimal separator
export LC_NUMERIC="en_US.UTF-8"
# ------------------------------------------------------------------------------
# commands commands
# ------------------------------------------------------------------------------
# get unique ID
ID=$(date -uIns | sha1sum | sed -re "s/ .+//")
# start group
date "+%% %Y-%m-%d"
echo "\\begin{exercise}"
echo " {ID-$ID}"
echo " {TITLE}"
echo " \\ifproblem\\problem\\par"
echo " % <PROBLEM>"
# insert indent and remove trailing spaces
sed -re "s/^/ / ; s/[[:space:]]+$//"
echo " % </PROBLEM>"
# finish group
echo " \\fi"
echo " %\\ifoutline\\outline\\par"
echo " % <OUTLINE>"
echo " % </OUTLINE>"
echo " %\\fi"
echo " %\\ifoutcome\\outcome\\par"
echo " % <OUTCOME>"
echo " % </OUTCOME>"
echo " %\\fi"
echo "\\end{exercise}"
exit 0