fix(dfm): update traps and tests (#124)

* fix(dfm): update traps and tests

* fix(dfm): initialize defaults and secure tests

* fix(tests): secure helper quoting and extend install coverage

* fix(utils): avoid double extension when resolving command

* fix(tests): quote paths and add strict mode

* fix(utils): escape function name in regex
This commit is contained in:
2025-06-11 23:44:52 +03:00
parent 76076fdaa4
commit 1d0ea5ace4
6 changed files with 111 additions and 73 deletions

View File

@@ -1,5 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
# Default paths can be overridden via environment variables
: "${DOTFILES:=$HOME/.dotfiles}"
: "${BREWFILE:=$DOTFILES/config/homebrew/Brewfile}"
: "${TEMP_DIR:=$(mktemp -d)}"
: "${DFM_MAX_RETRIES:=3}"
# Installation functions for dfm, the dotfile manager
#
# @author Ismo Vuorinen <https://github.com/ivuorinen>
@@ -26,6 +32,9 @@ set -euo pipefail
#
# Example:
# all
#
# @description
# Parse command line options controlling installation steps.
parse_options()
{
NO_AUTOMATION=0
@@ -56,8 +65,10 @@ parse_options()
done
}
function all()
{
# @description
# Install all configured components by calling each individual
# installation routine unless skipped via options.
function all() {
parse_options "$@"
lib::log "Installing all packages..."
@@ -91,8 +102,12 @@ function all()
#
# Example:
# fonts
function fonts()
{
#
# @description Install all configured fonts from helper script, prompting the user unless automation is disabled.
function fonts() {
: "${SKIP_FONTS:=0}"
: "${NO_AUTOMATION:=0}"
if [[ $SKIP_FONTS -eq 1 ]]; then
lib::log "Skipping fonts installation"
@@ -126,8 +141,12 @@ function fonts()
#
# Example:
# brew
function brew()
{
#
# @description Install Homebrew and declared packages using the Brewfile.
function brew() {
: "${SKIP_BREW:=0}"
: "${NO_AUTOMATION:=0}"
if [[ $SKIP_BREW -eq 1 ]]; then
@@ -170,8 +189,12 @@ function brew()
#
# Example:
# cargo
function cargo()
{
#
# @description Install Rust tooling and cargo packages using helper scripts.
function cargo() {
: "${SKIP_CARGO:=0}"
: "${NO_AUTOMATION:=0}"
if [[ $SKIP_CARGO -eq 1 ]]; then