Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bash implementation interop carriage returns. #471

Merged
merged 4 commits into from
Dec 2, 2019

Conversation

chr15m
Copy link
Contributor

@chr15m chr15m commented Nov 30, 2019

Before this fix the 'sh*' function was joining the lines of the output of whatever command was run in a way that resulted in '\n' instead of a literal carriage return.

Without this fix:

$ ./mal
Mal [bash]
user> (println (sh* "head mal"))
#!/usr/bin/env bash\n#\n# mal (Make a Lisp) object types\n#\n\nif [ -z "${__mal_types_included__}" ]; then\n__mal_types_included=true\n\ndeclare -A ANON\n
nil

After this fix (carriage returns correctly inserted by sh*):

$ ./mal
Mal [bash]
user> (println (sh* "head mal"))
#!/usr/bin/env bash
#
# mal (Make a Lisp) object types
#

if [ -z "${__mal_types_included__}" ]; then
__mal_types_included=true

declare -A ANON


nil

Before this fix the 'sh*' function was joining the lines of the output of whatever command was run in a way that resulted in '\n' instead of a literal carriage return.
@chr15m
Copy link
Contributor Author

chr15m commented Dec 1, 2019

Added more tests, fixed the stripping of the final \n, and allow sh* to capture output which has no \n at all within it.

chr15m added a commit to chr15m/mal that referenced this pull request Dec 2, 2019
This supercedes kanaka#470 and includes kanaka#471.
This fixes some edge cases when passing an asterisk to an sh* interop call.
Before this fix mal would the string with any wildcard character converted to __STAR__ when passing to the subcommand.
See the tests for examples of where this would fail to do what the user expects.
See also: chr15m/flk#1
chr15m added a commit to chr15m/mal that referenced this pull request Dec 2, 2019
This supercedes kanaka#470 and includes kanaka#471.
This fixes some edge cases when passing an asterisk to an sh* interop call.
Before this fix mal would pass the string with any wildcard character converted to __STAR__ when passing to the subcommand.
For example `(sh* "ls *")` would become `ls __STAR__` when executed.
See the tests for examples of where this would fail to do what the user expects.
See also: chr15m/flk#1
@kanaka kanaka merged commit 3180f62 into kanaka:master Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants