From: Lady <redacted>
Date: Mon, 22 Jan 2024 01:05:45 +0000 (-0500)
Subject: Only use utf-8-mac when iconv supports it
X-Git-Tag: 0.1.1^0
X-Git-Url: https://git.ladys.computer/Yseme/commitdiff_plain/HEAD

Only use utf-8-mac when iconv supports it

This should hopefully avoid needing device‐specific character set
configuration for repositories.
---

diff --git a/GNUmakefile b/GNUmakefile
index e07079b..9f17dbc 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -5,16 +5,10 @@ SHELL = /bin/sh
 # This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
 # If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 
-BUILDTARGET := .grass
-DESTDIR := .
-
-CLIENTCHARSET := utf-8-mac
-SERVER := computer
-SERVERCHARSET := utf-8
-SERVERPATH := $(notdir $(abspath .))
-
 AWK := awk
 ECHO := echo
+GREP := grep
+ICONV := iconv
 SED := sed
 TEST := test
 
@@ -29,6 +23,14 @@ RSYNCFILTER := .rsync-filter
 endif
 RSYNCOPTS := --checksum --compress --del --links --omit-dir-times --prune-empty-dirs --recursive --times --verbose
 
+BUILDTARGET := .grass
+DESTDIR := .
+
+CLIENTCHARSET := $(if $(shell $(ICONV) -l | $(GREP) -i 'utf-8-mac' - || true),utf-8-mac,utf-8)
+SERVER := computer
+SERVERCHARSET := utf-8
+SERVERPATH := $(notdir $(abspath .))
+
 override comma := ,
 
 ifneq ($(wildcard $(BUILDTARGET)),)
diff --git a/README.markdown b/README.markdown
index f52b25e..217bf70 100644
--- a/README.markdown
+++ b/README.markdown
@@ -91,6 +91,8 @@ In every case, you may supply your own implementation by overriding the
 - `awk`
 - `echo`
 - `git`
+- `grep`
+- `iconv`
 - `rsync` (version 3.0 or later)
 - `sed`
 - `test`
@@ -120,7 +122,8 @@ The following variables configure Git :⁠—
 The following variables configuer R·Sync :⁠—
 
 - **`CLIENTCHARSET`:**
-  The character set of the local machine (default: `utf-8-mac`).
+  The character set of the local machine (default: `utf-8-mac` if
+    supported by `iconv`; `utf-8` otherwise).
   If both this and `SERVERCHARSET` are set and not equal, an appropriate
     `--iconv` option will be added to the R·Sync call.