diff options
author | Viktor Kleen <viktor@kleen.org> | 2015-03-03 05:55:33 +0000 |
---|---|---|
committer | Viktor Kleen <viktor@kleen.org> | 2015-03-03 05:55:33 +0000 |
commit | f81be5dfb7720994f6deca3bc738c63f48f26309 (patch) | |
tree | 9faff874354ca64e8e0b711fea816645ed58334b /posts.sh | |
parent | 8648faa6c224be177461fc7e93155ceabf8f6ca5 (diff) | |
download | dirty-haskell.org-f81be5dfb7720994f6deca3bc738c63f48f26309.tar dirty-haskell.org-f81be5dfb7720994f6deca3bc738c63f48f26309.tar.gz dirty-haskell.org-f81be5dfb7720994f6deca3bc738c63f48f26309.tar.bz2 dirty-haskell.org-f81be5dfb7720994f6deca3bc738c63f48f26309.tar.xz dirty-haskell.org-f81be5dfb7720994f6deca3bc738c63f48f26309.zip |
start writing on torsors
Diffstat (limited to 'posts.sh')
-rwxr-xr-x | posts.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/posts.sh b/posts.sh new file mode 100755 index 0000000..a259dd4 --- /dev/null +++ b/posts.sh | |||
@@ -0,0 +1,32 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | shopt -s extglob nullglob | ||
4 | |||
5 | |||
6 | new_post() { | ||
7 | filename="$1" | ||
8 | shift 1 | ||
9 | cat >posts/$filename <<EOF | ||
10 | % $@ | ||
11 | EOF | ||
12 | last_link=$(find ./lists/zz_all -regex '.*/[0-9]*$' -printf '%f\n' | sort | tail -n1) | ||
13 | new_link=$(printf '%03d\n' $(($last_link + 1))) | ||
14 | ln -s ../../posts/"$filename" ./lists/zz_all/"$new_link" | ||
15 | } | ||
16 | |||
17 | |||
18 | . ./getopts_long.sh | ||
19 | |||
20 | while getopts_long ":n:" opt \ | ||
21 | "" "$@" | ||
22 | do | ||
23 | case $opt in | ||
24 | n) | ||
25 | shift "$(($OPTLIND - 1))" | ||
26 | new_post "$OPTLARG" "$@" | ||
27 | exit 0;; | ||
28 | :) | ||
29 | printf >&2 '%s: %s\n' "${0##*/}" "$OPTLERR" | ||
30 | exit 1;; | ||
31 | esac | ||
32 | done | ||