Files
dotfiles/scripts/shell/format-xml.sh
Matheus Albino Brunhara 3663cd0d05 Adds scripts
2024-11-19 08:57:18 -03:00

16 lines
358 B
Bash
Executable File

#!/bin/env bash
# Create a temporary file
temp_file=$(mktemp)
# Run xmllint and output to the temporary file
if xmllint --format "$1" >"$temp_file"; then
# If successful, replace the original file with the formatted file
mv "$temp_file" "$1"
else
# If unsuccessful, remove the temporary file
rm "$temp_file"
echo "Formatting failed."
exit 1
fi