branch: externals/shell-command+ commit 7555ded55b3adf345ba4031d6fbd46a03b4adcbe Author: Philip Kaludercic <phil...@posteo.net> Commit: Philip Kaludercic <phil...@posteo.net>
Improve whitespace-resilience during tokenization Thanks to Visuwesh for bringing the issue to my attention: https://lists.sr.ht/~pkal/public-inbox/%3C871qv6smim.fsf%40gmail.com%3E. --- shell-command+-tests.el | 7 +++++-- shell-command+.el | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/shell-command+-tests.el b/shell-command+-tests.el index 4823bf9145..c1026011fc 100644 --- a/shell-command+-tests.el +++ b/shell-command+-tests.el @@ -1,6 +1,6 @@ ;;; shell-command+-tests.el --- Tests for shell-command+ -*- lexical-binding: t; -*- -;; Copyright (C) 2021 Free Software Foundation, Inc. +;; Copyright (C) 2021, 2022 Free Software Foundation, Inc. ;; Author: Philip Kaludercic <phil...@posteo.net> @@ -187,7 +187,10 @@ ("a b\\\\c d" nil ("a" "b\\c" "d")) ("a b\\\\ c d" nil ("a" "b\\" "c" "d")) ("a b\\\\\\ c d" nil ("a" "b\\\\ c" "d")) - ("abcd\\ ef gh" nil ("abcd ef" "gh")))) + ("abcd\\ ef gh" nil ("abcd ef" "gh")) + ("abcd\\ ef gh" nil ("abcd ef" "gh")) + ("abcd\\ ef gh " nil ("abcd ef" "gh")) + (" abcd\\ ef gh " nil ("abcd ef" "gh")))) (should (equal (shell-command+-tokenize args expand) list)))) diff --git a/shell-command+.el b/shell-command+.el index ffcf86f3b1..453e5d6d26 100644 --- a/shell-command+.el +++ b/shell-command+.el @@ -177,7 +177,8 @@ is specified." (group-n 1 (* (or (: ?\\ anychar) (not (any ?\\ ?\'))))) ?\') (group (+ (not (any space ?\\ ?\" ?\'))) - (* ?\\ anychar (* (not (any space ?\\ ?\" ?\'))))))) + (* ?\\ anychar (* (not (any space ?\\ ?\" ?\')))))) + (* space)) "Regular expression for tokenizing shell commands.") (defun shell-command+-tokenize (command &optional expand)