Skip to content

Commit

Permalink
Use quoted-string-split on editor open commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmonettas committed Aug 26, 2024
1 parent 2ce401a commit c78d512
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### New Features

### Changes

- Use quoted-string-split on editor open commands
### Bugs fixed

Expand Down
2 changes: 1 addition & 1 deletion src-dbg/flow_storm/debugger/ui/flows/general.clj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@

(when command
(utils/log (str "Running : " command))
(apply shell/sh (str/split command #"\s"))))))
(apply shell/sh (utils/quoted-string-split command \space))))))
(catch Exception e
(utils/log-error (.getMessage e))))))
22 changes: 22 additions & 0 deletions src-shared/flow_storm/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,25 @@
(let [klass (Class/forName class-name)
method (.getMethod klass method-name (into-array java.lang.Class (mapv class args)))]
(.invoke method nil (into-array args)))))

(defn quoted-string-split

"Split string s with sep-char but don't split inside single quotes."

[s sep-char]
(loop [[c & rinput] s
quote-on? false
tokens []
curr-tok ""]
(if-not c
(conj tokens curr-tok)

(cond
(= c \')
(recur rinput (not quote-on?) tokens curr-tok)

(and (= c sep-char) (not quote-on?))
(recur rinput quote-on? (conj tokens curr-tok) "")

:else
(recur rinput quote-on? tokens (str curr-tok c))))))

0 comments on commit c78d512

Please sign in to comment.