From 5de470b1030c932b4e99ce685c0f27078a5db428 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 23 May 2026 20:01:25 -0500 Subject: fix(dwim-shell): build video-concat filelist in elisp cj/dwim-shell-commands-concatenate-videos built the ffmpeg concat list with echo '<<*>>' | tr ' ' '\n' | sed 's/^/file /'. That splits on spaces, so any video whose name contains a space produced a broken list, and a name with a quote broke the echo outright. I extracted cj/dwim-shell--build-concat-filelist, which renders each path as an escaped file '...' line. I write that list to a temp file and run ffmpeg against the quoted listfile, with a trailing rm to clean up after the process exits. The <<*>> token stays only as an inert shell comment, since dwim-shell needs it to run one command over all marked files instead of once per file. --- tests/test-dwim-shell-config-concat.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/test-dwim-shell-config-concat.el (limited to 'tests') diff --git a/tests/test-dwim-shell-config-concat.el b/tests/test-dwim-shell-config-concat.el new file mode 100644 index 00000000..acbbbb2b --- /dev/null +++ b/tests/test-dwim-shell-config-concat.el @@ -0,0 +1,29 @@ +;;; test-dwim-shell-config-concat.el --- Tests for concat filelist builder -*- lexical-binding: t; -*- + +;;; Commentary: +;; Covers cj/dwim-shell--build-concat-filelist, which renders an ffmpeg +;; concat-demuxer filelist from a list of paths. Building it in Elisp (rather +;; than echo/tr/sed over <<*>>) keeps paths with spaces and quotes intact. + +;;; Code: + +(require 'ert) +(require 'dwim-shell-config) + +(ert-deftest test-dwim-concat-filelist-plain-paths () + "Normal: plain paths become single-quoted file lines, newline-separated." + (should (equal (cj/dwim-shell--build-concat-filelist '("/v/a.mp4" "/v/b.mp4")) + "file '/v/a.mp4'\nfile '/v/b.mp4'"))) + +(ert-deftest test-dwim-concat-filelist-space-in-path () + "Boundary: a path with spaces stays inside the quotes, unsplit." + (should (equal (cj/dwim-shell--build-concat-filelist '("/v/my movie.mp4")) + "file '/v/my movie.mp4'"))) + +(ert-deftest test-dwim-concat-filelist-quote-in-path () + "Error/edge: a single quote in a path is escaped for the concat list." + (should (equal (cj/dwim-shell--build-concat-filelist '("/v/it's here.mp4")) + "file '/v/it'\\''s here.mp4'"))) + +(provide 'test-dwim-shell-config-concat) +;;; test-dwim-shell-config-concat.el ends here -- cgit v1.2.3