bash/tools/build-rbashrc.sh
raw ยท 515 bytes
#!/usr/bin/env bash
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
out="$root/bash/rbashrc"
{
cat "$root/bash/rbashrc.in"
shopt -s nullglob
core_files=( "$root"/bash/core/*.bash )
if [ "${#core_files[@]}" -eq 0 ]; then
echo "error: no core files found under bash/core/*.bash" >&2
exit 1
fi
for f in "${core_files[@]}"; do
rel="${f#$root/}"
printf '\n\n# ---- rbash: %s ----\n\n' "$rel"
cat "$f"
done
} > "$out"
chmod +x "$out"
echo "wrote $out"