This project consists of a set of Bash scripts designed to format and process XML files. The primary script is xml_formatter.sh
, which relies on several helper scripts to parse options, check the operating system, verify necessary commands, and process XML files.
- xml_formatter.sh
- parse_options.sh
- check_os.sh
- check_commands.sh
- process_xml_files.sh
This is the main script that orchestrates the XML formatting process. It utilizes the other scripts to ensure a smooth operation.
This script parses the command-line options and arguments. It ensures that at least one path is provided and sets up necessary variables for further processing.
This script checks the operating system and ensures the script is not run on incompatible systems like Windows.
This script verifies that required commands (xmllint
and diff
) are installed on the system before proceeding.
This script processes the XML files, either formatting them or showing differences based on the options provided.
Run xml_formatter.sh
with the appropriate options and paths to process XML files.
./xml_formatter.sh [OPTIONS] path1 [path2 ... pathN]
-f
: Fix the XML files instead of just showing differences.-i
: Set the XML indentation (e.g.,' '
for 4 spaces or$'\t'
for a tab).-h, --help
: Show the help message and exit.
To format XML files in the current directory with a tab indentation:
./xml_formatter.sh -i $'\t' *.xml
To show differences without fixing:
./xml_formatter.sh *.xml