Repository navigation
MacOS compatibility for gotta-patch-em-all!.sh - #1976
Conversation
Finii
left a comment
There was a problem hiding this comment.
Thanks for the PR and disentangling the icon addition from the source code.
Some small remarks.
b023fc1 to
afdb5bd
Compare
There was a problem hiding this comment.
I removed some more remaims (see below) into your commit, and added a new commit with a code simplification.
What do you think?
git rebase -i HEAD~5
<marking first of your commits as 'edit'>
git rm src/svgs/cachyos.svg
git rm src/svgs/zsh.svg
git checkout HEAD^ -- src/svgs/icons.tsv
git checkout HEAD^ -- src/glyphs/original-source.otf
git checkout HEAD^ -- bin/scripts/lib/i_seti.sh
git commit --amend
git rebase --continue
Edit: With 'into your commit' I mean I edited your commit and force pushed the new version back to your repo.
afdb5bd to
e42951e
Compare
|
Hmm, we both forgot to increase the script version numbers, put that into my commit and force push. |
|
Thank you, I appreciate your guidance and corrections, and especially patience with my first attempt at contributing to an OSS project! |
Updated gotta-patch-em-all-font-patcher!.sh to enhance the filename filtering logic by ensuring that the filter matches fonts that start with the specified filter argument. This change improves the accuracy of font searches and maintains the script's functionality. Changes include: - Modified the filename filter to match fonts starting with the filter argument. - Updated comments for clarity regarding the filtering patterns.
…atibility - Improved the find command to support both directory and filename filters for font files. - Retained compatibility with existing patterns while updating the filtering logic. - Enhanced date command handling for cross-platform compatibility between GNU and BSD systems. - Updated comments for clarity and maintainability. Updated gotta-patch-em-all-font-patcher!.sh to include additional comments clarifying the patterns used for directory and filename filters. This change improves code readability and maintains the script's functionality by ensuring users understand the filtering mechanisms in place. Changes include: - Added comments for directory and filename filter patterns. - Ensured existing functionality remains intact while enhancing clarity.
bin/scripts/lib/i_seti.sh: removed two glyph lines missed during previous revert Summary of changes to bin/scripts/gotta-patch-em-all-font-patcher!.sh: - Add error checks to actual date conversion commands (not just version detection) - Ensure script exits immediately on invalid SOURCE_DATE_EPOCH - Add consistent error handling in patch_font() function - Addresses maintainer feedback on lines 213 and 256" --- Details: > This changes the behavior, before - if the user gives an invalid `SOURCE_DATE_EPOCH` the script complained and exited. Now it just runs on - and the error message is output when no compatible `date` is found. > > I would insist that on new line 213 you should `if` on the actual command and not on `date --version`. - Fixed misplaced conditional to check for success of actual conversion and not just success of date util-based "OS" detection. --- > This can never happen, becaus we would exit farther up, right? Suggest exiting here also. - Fixed the error handling behavior to be consistent (exit with code 2) if timestamp conversion fails (safe failure) rather than continuing with invalid date value (silent but an error and failure that was not recognized)
We can unify the error message, and thereby also not relying on the mare existance of `--version` but on actual parsability of the timestamp. [note] Also increasing script versions after most recent changes. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
a39b0ce to
8461ead
Compare
|
Strangely I didn't see this the last time 🤔
And There are also some SC2155 warnings (by me) that I would remove then in one go. |
|
I would do this: From 7c654f115ae6c3e93c754ae59e6948054bfcd756 Mon Sep 17 00:00:00 2001
From: Fini Jastrow <ulf.fini.jastrow@desy.de>
Date: Thu, 22 Jan 2026 16:21:23 +0100
Subject: [PATCH] gotta-patch-em: Remove shellcheck warnings
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
---
.../gotta-patch-em-all-font-patcher!.sh | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/bin/scripts/gotta-patch-em-all-font-patcher!.sh b/bin/scripts/gotta-patch-em-all-font-patcher!.sh
index e85787d15..7927d85da 100755
--- a/bin/scripts/gotta-patch-em-all-font-patcher!.sh
+++ b/bin/scripts/gotta-patch-em-all-font-patcher!.sh
@@ -30,7 +30,6 @@ sd="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit ; pwd -P )"
repo_root_dir=$(dirname "$(dirname "${sd}")") # two levels up (i.e. ../../)
# Set source and target directories
-like_pattern='.*\.\(otf\|ttf\|sfd\)'
last_font_root=""
unpatched_parent_dir="src/unpatched-fonts"
patched_parent_dir="patched-fonts"
@@ -155,28 +154,20 @@ then
# For directory filter, -ipath must be outside the parentheses grouping
find_cmd_args=(-iname "*.ttf" -o -iname "*.otf" -o -iname "*.sfd")
find_path_filter="-ipath"
- find_path_pattern="*${filter_dir}/*"
find_path_filter_with_pattern=(-ipath "*${filter_dir}/*")
echo "$LINE_PREFIX Filter given, limiting search and patch to pathname pattern '$filter_arg'"
- # Pattern for directory filter: match paths containing the directory
- like_pattern=".*/${filter_dir}/.*\.\(otf\|ttf\|sfd\)"
else
# Filename filter: match fonts with filter in filename
find_cmd_args=(-iname "*${filter_arg}*.ttf" -o -iname "*${filter_arg}*.otf" -o -iname "*${filter_arg}*.sfd")
find_path_filter=""
- find_path_pattern=""
find_path_filter_with_pattern=()
echo "$LINE_PREFIX Filter given, limiting search and patch to filename pattern '$filter_arg'"
- # Pattern for filename filter: match filter in filename
- like_pattern=".*${filter_arg}.*\.\(otf\|ttf\|sfd\)"
fi
else
# No filter
find_cmd_args=(-iname "*.ttf" -o -iname "*.otf" -o -iname "*.sfd")
find_path_filter=""
- find_path_pattern=""
find_path_filter_with_pattern=()
- like_pattern='.*\.\(otf\|ttf\|sfd\)'
fi
# correct way to output find results into an array (when files have space chars, etc)
@@ -207,7 +198,8 @@ echo "$LINE_PREFIX Total source fonts found: ${#source_fonts[*]}"
# Use one date-time for ALL fonts and for creation and modification date in the font file
if [ -z "${SOURCE_DATE_EPOCH}" ]
then
- export SOURCE_DATE_EPOCH=$(date +%s)
+ SOURCE_DATE_EPOCH=$(date +%s)
+ export SOURCE_DATE_EPOCH
fi
# Detect GNU vs BSD date implementations reliably
if date -R "--date=@${SOURCE_DATE_EPOCH}" >/dev/null 2>&1; then
@@ -233,7 +225,8 @@ function patch_font {
# take everything before the last slash (/) to start building the full path
local ts_font_dir="${f%/*}/"
local ts_font_dir="${ts_font_dir/$unpatched_parent_dir/$timestamp_parent_dir}"
- local one_font=$(find "${ts_font_dir}" -name '*.[ot]tf' | head -n 1)
+ local one_font
+ one_font=$(find "${ts_font_dir}" -name '*.[ot]tf' | head -n 1)
if [ -n "${one_font}" ]
then
orig_font_date=$(ttfdump -t head "${one_font}" | \
@@ -353,7 +346,8 @@ function generate_info {
[[ -d "$patched_font_dir" ]] || mkdir -p "$patched_font_dir"
- local font_root=$(echo "$patched_font_dir" | sed "s|.*$patched_parent_dir/||;s|/.*||")
+ local font_root
+ font_root=$(echo "$patched_font_dir" | sed "s|.*$patched_parent_dir/||;s|/.*||")
# if first time with this font then re-build parent dir readme, else skip:
if [ "$last_font_root" != "$font_root" ]
then
--
2.51.0
|
|
Sorry for delay responding! Thank you for your diligence; I missed cleaning up the deprecated |



Description
This PR improves the gotta-patch-em-all-font-patcher!.sh script with enhanced font filtering logic and cross-platform compatibility fixes for macOS/BSD systems.
Key changes:
GNU: date -R "--date=@${SOURCE_DATE_EPOCH}"
BSD: date -r "${SOURCE_DATE_EPOCH}" "+%a, %d %b %Y %H:%M:%S %z"
Requirements / Checklist
Issue number where discussion took place: #xxx
What does this Pull Request (PR) do?
Fixes cross-platform compatibility issues in the font patching script, particularly for macOS users. The filtering logic now works correctly on BSD-based systems (macOS) where find -iregex and date command syntax differ from GNU coreutils.
How should this be manually tested?
Any background context you can provide?
Intended to add icons for CachyOS and zsh, and while doing that using a Mac (M4max MacBook Pro, macOS 26.2, stock Mac bash 3.2.57 and Homebrew bash 5.3.9 used for testing) discovered that the command syntax for some of the basic utils was not cleanly compatible with Mac's BSD-origin utils. Found issues with filtering logic that presented similar incompatibility. Separating the code contribution from new icons request.
What are the relevant tickets (if any)?
(no tickets)
Screenshots (if appropriate or helpful)
(not particularly helpful here I think)