Recently Written · git

sbm

dmenu bookmarks. Instantly fuzzy search thousands of bookmarks and plumb them. LOOKING FOR SUCKLESS SOFTWARE EDITION? GO TO sbm-suckless INSTEAD

git clone https://github.com/equwal/sbm

Log | Files | Refs


commit d5dfc1de57cdbc8b73b5992ae1347cad5472f71f
Spenser Truex <truex@equwal.com>
2026-09-22 22:45:51 -0700

Windows installer: stop the old bm-watch at an upgrade

The installer starts sbm-setup with the PATH of Windows. That PATH does
not have the Cygwin tools. So "sbm-setup stop" did not find tr, found
no bm-watch, and stopped nothing. After an upgrade, two bm-watch
processes ran. On a new install, "sbm-setup data" did not find mkdir
and cp.

sbm-setup now puts /usr/bin at the start of the PATH.

The installer ran the installed sbm-setup of the earlier version before
it changed the files. The sbm-setup of sbm 0.4 to 0.6 has the problem.
So the installer now installs its own sbm-setup first, and runs it.

 contrib/windows/sbm-setup |  4 ++++
 contrib/windows/sbm.nsi   | 11 ++++++-----
 test/run.sh               | 13 +++++++++++++
 3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/contrib/windows/sbm-setup b/contrib/windows/sbm-setup
index 370737c..ec771aa 100755
--- a/contrib/windows/sbm-setup
+++ b/contrib/windows/sbm-setup
@@ -6,6 +6,10 @@
 #                       and keep the files that the user has
 #     sbm-setup stop    stop the bm-watch that the installer started
 
+# The installer starts this script with the PATH of Windows. That PATH does
+# not have the Cygwin tools, for example tr, mkdir and cp.
+PATH=/usr/bin:$PATH
+
 case ${1-} in
     data)
         d=${XDG_DATA_HOME:-$HOME/.local/share}/sbm
diff --git a/contrib/windows/sbm.nsi b/contrib/windows/sbm.nsi
index f5e541e..9ae3ac1 100755
--- a/contrib/windows/sbm.nsi
+++ b/contrib/windows/sbm.nsi
@@ -75,10 +75,12 @@ FunctionEnd
 
 Section
   ; An earlier version can run bm-watch. Stop it before its files change.
-  ${If} ${FileExists} "$Cygwin\usr\local\libexec\sbm\sbm-setup"
-    nsExec::ExecToLog '"$Cygwin\bin\sh.exe" /usr/local/libexec/sbm/sbm-setup stop'
-    Pop $0
-  ${EndIf}
+  ; Use the sbm-setup of this installer. The sbm-setup of sbm 0.4 to 0.6
+  ; does not find tr in the PATH of Windows, so it does not stop bm-watch.
+  SetOutPath "$Cygwin\usr\local\libexec\sbm"
+  File "${SRC}\libexec\sbm-setup"
+  nsExec::ExecToLog '"$Cygwin\bin\sh.exe" /usr/local/libexec/sbm/sbm-setup stop'
+  Pop $0
 
   SetOutPath "$Cygwin\usr\local\bin"
   File "${SRC}\bin\bm"
@@ -95,7 +97,6 @@ Section
   SetOutPath "$Cygwin\usr\local\libexec\sbm"
   File "${SRC}\libexec\fzf.exe"
   File "${SRC}\libexec\fzf-LICENSE.txt"
-  File "${SRC}\libexec\sbm-setup"
   SetOutPath "$Cygwin\usr\local\share\sbm"
   File "${SRC}\share\engines"
   File "${SRC}\share\usertags"
diff --git a/test/run.sh b/test/run.sh
index 9fa6b15..3755398 100755
--- a/test/run.sh
+++ b/test/run.sh
@@ -1307,6 +1307,19 @@ if command -v make >/dev/null 2>&1; then
         "$(ls "$work/dest/usr/share/applications" | wc -l | tr -d ' ')" '0'
 fi
 
+# ---- Windows installer ----
+
+# The installer runs sbm-setup with the PATH of Windows. That PATH has no
+# Cygwin tools.
+case $(uname -s) in
+    CYGWIN*)
+        XDG_DATA_HOME="$work/setup" PATH="$work/nobin" \
+            "$(command -v "${SBM_SH:-sh}")" "$top/contrib/windows/sbm-setup" data 2>/dev/null
+        eq 'sbm-setup finds the Cygwin tools when the PATH has none' \
+            "$([ -d "$work/setup/sbm" ] && echo yes)" 'yes'
+        ;;
+esac
+
 # ---- defaults ----
 
 (