#!/bin/sh # # A simple shell script for creating new articles # # Copyright © 2022 Andrew Yu # # This is free and unencumbered software released into the public domain. # # Anyone is free to copy, modify, publish, use, compile, sell, or # distribute this software, either in source code form or as a compiled # binary, for any purpose, commercial or non-commercial, and by any # means. # # In jurisdictions that recognize copyright laws, the author or authors # of this software dedicate any and all copyright interest in the # software to the public domain. We make this dedication for the benefit # of the public at large and to the detriment of our heirs and # successors. We intend this dedication to be an overt act of # relinquishment in perpetuity of all present and future rights to this # software under copyright law. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. [ -z "$2" ] && printf "$0: Not enough arguments.\n$0: You MUST run this script with the following arguments:\n$0: \n" > /dev/stderr && exit 1 [ "$3" ] && printf "$0: Too many arguments.\n$0: You MUST run this script with the following arguments:\n$0: \n" > /dev/stderr && exit 2 FILENAME="$1" RFDN="$2" mv TEMPLATE.md "$FILENAME".md sed -i 's/RFDN/'"$RFDN"'/g' "$FILENAME".md sed 's/FILENAME/'"$FILENAME"'/g' > Makefile << EOF update: FILENAME.txt FILENAME.7 FILENAME.html git add . git commit git push FILENAME.7: FILENAME.md mmark --man FILENAME.md > FILENAME.7 FILENAME.txt FILENAME.html: FILENAME.xml xml2rfc --text --html FILENAME.xml sed -i -e '/\f/{n;s/^.\{5\}/RFD 1/}' FILENAME.txt ed FILENAME.txt < Edfile FILENAME.xml: FILENAME.md sed '0,/title =/{s/ ."\$\$/"/}' FILENAME.md | mmark > FILENAME.xml EOF (sed 's/RFDN/'"$RFDN"'/g' << EOF 6 s/^DOTNUM/RFD RFDN/ wq EOF ) | sed 's/DOTNUM/'"$(printf 'RFD %s' "$RFDN" | sed 's/././g')"'/g' > Edfile printf "$0: Finished generating Makefile and Edfile.\n$0: You MUST now edit $FILENAME.md and replace the <++>s.\n" > /dev/stderr