Fork me on GitHub
#code-reviews
<
2018-07-18
>
lispyclouds07:07:50

Hello all! I am writing a function to tokenize a shell command as a string and tokenize it into the commad and its args. For example: Input: "sh -c \"while sleep 1; do echo \\\"${RANDOM}\\\"; done\"" Output: ["sh", "-c", "while sleep 1; do echo \"${RANDOM}\"; done"] This is what I've come up with. Its a direct conversion of https://sourceforge.net/p/drjava/git_repo/ci/master/tree/drjava/src/edu/rice/cs/util/ArgumentTokenizer.java#l70

lispyclouds07:07:25

Need help in the follwing areas: - How to collect the recurs into a single recur - Making it more idiomatic - General feedback and improvements All help is much appreciated! 😄

hiredman16:07:25

finite state transducer + reduce

hiredman16:07:51

which may or may not help, maybe look at automat

hiredman16:07:35

or maybe replace it with a regex