silnrsi / smith

font development, testing and release
Other
14 stars 5 forks source link

`rrun` mishandles quoted parameters #66

Closed bobh0303 closed 3 years ago

bobh0303 commented 3 years ago

Observed:

rrun touch "my file.txt"

creates two files: my and file.txt

Expected:

It should create just one file called my file.txt

Attempts to fix

I thought the problem was in line 63: https://github.com/silnrsi/smith/blob/b7566e2fefe3ef3ac033d4c85ee7b2f57c4c1a56/contrib/rrun/rrun#L62-L63 where the $@ wants to be quoted to "$@"

However when I tried this I got inexplicable results:

$ rrun touch "my file.txt"
/bin/sh: 3: touch my file.txt: not found

which is what I would have expected with "$*" (and indeed, that generates the same error).

I've also tried bash's Q (quote feature):

${@@Q}

and while that seems to work, I can no longer put multiple commands on rrun. For example, with:

rrun smith clean \; smith build

the semicolon is passed as a parameter to smith rather than acting as a command separator.

I assume the underlying problem is that the $@ is within a heredoc and thus is subject to shell expansion twice, but I can't figure out a solution.

If a solution is found we can delete the "Known bugs" section of the README.

bobh0303 commented 3 years ago

escaping the spaces within quoted parameters, e.g., rrun touch "my\ file.txt", is a workaround