From b0a293a83242a9fbaef02a57d47e691c22b5fcc4 Mon Sep 17 00:00:00 2001 From: Benjamin Lupton Date: Fri, 17 Jan 2025 11:49:11 +0800 Subject: [PATCH] bash/ci: attempt fix for arm failures https://github.com/bevry/dorothy/actions/runs/12822259701/job/35754867873 --- commands/is-accessible.bash | 2 +- sources/bash.bash | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/commands/is-accessible.bash b/commands/is-accessible.bash index 6e73b09f8..367d0ba0d 100755 --- a/commands/is-accessible.bash +++ b/commands/is-accessible.bash @@ -18,7 +18,7 @@ while [[ $# -ne 0 ]]; do # stat: cannot statx '/home/runner/.cache/dorothy/5350/dir/subfile': Permission denied # MACOS # stat: /Users/balupton/.cache/dorothy/12776/dir/subfile: stat: Permission denied - if stat -L "$path" 2>&1 >/dev/null | grep --quiet --regexp=': Permission denied$'; then + if stat -L "$path" 2>&1 | grep --quiet --regexp=': Permission denied$'; then exit 13 # EACCES 13 Permission denied fi done diff --git a/sources/bash.bash b/sources/bash.bash index 5bf26506d..b1a232b85 100644 --- a/sources/bash.bash +++ b/sources/bash.bash @@ -218,6 +218,24 @@ function __mkdirp { done if [[ ${#missing[@]} -ne 0 ]]; then mkdir -p "${missing[@]}" || status=$? + if [[ $status -ne 0 ]]; then + local sudo_missing=() + status=0 + for dir in "${missing[@]}"; do + if [[ ! -d $dir ]]; then + sudo_missing+=("$dir") + # for some reason, this detection doesn't work: + # if mkdir -p "$dir" 2>&1 | grep --quiet --regexp=': Permission denied$'; then + # sudo_missing+=("$dir") + # else + # mkdir -p "$dir" || return + # fi + fi + done + if [[ ${#sudo_missing[@]} -ne 0 ]]; then + __sudo_mkdirp -- "${sudo_missing[@]}" || status=$? + fi + fi fi return "$status" }