Files
would-reformat/do-reformat.sh
Michael Wolf 7c503cecf7 Try to do a few things
FIXME: do them correctly; squash and reword this travesty of a commit.
2024-04-03 11:26:50 -06:00

42 lines
627 B
Bash
Executable File

#!/bin/bash
set -uo pipefail
IFS=$'\n\t'
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$DIR/_reformat-common.bash"
#export LOG_DEST="$LOG_TO"
file="$1"
PROJECT_ROOT=$(project_root "$file")
export PROJECT_ROOT="$PROJECT_ROOT"
WF_ROOT=$(wf_root)
export WF_ROOT="$WF_ROOT"
file_type=$(sniff_file_type "$file")
export WOULD_REFORMAT=do_reformat
wrapper=$(choose_wrapper "$file_type")
wrflog got wrapper: $wrapper
set +e
out=$("$wrapper" "$file" 2>&1 >/dev/null)
retval="$?"
set -e
success_retval=0
if [[ "$retval" == "$success_retval" ]]; then
echo "$out"
exit 0
else
exit $retval
fi
exit 0