#!/usr/bin/env bash # # Dump the AST of an org-mode document from emacs set -euo pipefail IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" REALPATH=$(command -v uu-realpath || command -v realpath) MAKE=$(command -v gmake || command -v make) ############## Setup ######################### function die { local status_code="$1" shift (>&2 echo "${@}") exit "$status_code" } function log { (>&2 echo "${@}") } ############## Program ######################### function main { if [ $# -eq 0 ]; then dump_ast_stdin "${@}" else dump_ast_file "${@}" fi } function dump_ast_stdin { # Until we can find a good way to encode stdin as an elisp string in bash, I cannot operate on stdin. die 1 "This script only works on files." } function dump_ast_file { local target_file mounted_file elisp_script target_file=$($REALPATH "$1") mounted_file="/input${target_file}" elisp_script=$(cat <