-
- Notifications
You must be signed in to change notification settings - Fork 95
Add support for generating tab-indented scripts using BASHLY_TAB_INDENT #217
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
Conversation
BASHLY_TAB_INDENT | Just tested this and seems to be working for my specific usecase. However as documented it currently doesn't support tab/space indention in the heredoc itself. Note: Depending on the usecase using U+3000 might not be a feasble solution. Consider a bash script or other template that you want to keep inline. This specific usecase doesn't allow to use unicode chars for spacing as it is not supported by the underlying language. That beeing said, although the heredoc support is not perfect yet, it definitily has improved with this PR |
| Thanks for testing. I agree, perfect it is not. Considering all the discussed aspects, I feel this is the best possible implementation at this stage. I will go ahead and merge it, and start working on the user settings. |
| @hojerst btw - when an inline indentation is needed, wouldn't the originally proposed solution work? The one where you write your function-that-returns-heredoc inside one of the If so - I will re-add this as an alternative example. |
| normally yes, but this breaks when you use the |
| Maybe not indenting the code in the wrapper function would be the most compatible way (but this results in a wrongly indented generated script) |
| Yeah, well if you want to wrap and use heredocs and indent your heredocs - the official answer is "touch luck" :) I am curious - why use wrap at all? Isn't bashly providing you with sufficient tools to generate the full result without the need to wrap it in a function? |
| Wrapping isn't a functionality I personally need. I just want to provide this function to the users of my script. This allows to source the script without executing it directly. Isn't this the main function of the On the other hand moving 90% of my business logic to a function in lib and passing args from command to the lib function easily kills readability of code. (one of the major features of bashly imho). Maybe for clarity my specific usecase: Needing to deal with double and tripple escaping |
| I see... and here-strings wont work? <<<'script goes here 'and have you considered taking all the "SSH scripts" and putting them in an external file, that is read from? |
| yeah I considered those, but there are multiple downsides to both approaches.
Heredocs are just the simplest/most readable solution for my usecase. (I use heredocs quite often as a 'poor-mans template engine'). Anyway, I got a solution for my usecase which allows me to stick with bashly (which I really like btw). |
| Alright. A version will be released tomorrow. Thanks for the feedback. |
As discussed in #216