-
Notifications
You must be signed in to change notification settings - Fork 53
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
embedded docopts.sh wrapper into docopts binary #60
Comments
Since there's a way around this -- just output to file and you get the same result as right now -- I think we can mostly overlook this con. Just needs to be addressed in the docs in a way that encourages the preferred behavior.
I was wondering how to load it at compile-time! Cool to know you can do that with Looks good to me at least. The only thing I remember having to deal with when outputting like this is line endings between different OS's, but I'm guessing Go handles that properly when cross-compiled (I had to manually change line endings in Bash on different OS's before... do not recommend lol). |
handling line endings for different OSOh, so long time ago I didn't think about this. That's true. #54 will help to watch for that.
Do you have proof? Did you test the code above on mac? If you build it on a macos, some behavior may be handled automatically what about cross-compilation? under Linux I go
[...] 00001ad0: 7273 6520 2224 7b42 4153 485f 534f 5552 rse "${BASH_SOUR 00001ae0: 4345 5b31 5d7d 2220 2224 4022 2922 0a20 CE[1]}" "$@")". 00001af0: 2020 2066 690a 6669 0a fi.fi. attached base64 encode cross-compiled binaryfrom the branch dev-embedded-docopts_sh $ base64 < ./build/docopts_darwin_amd64 > docopts_darwin_amd64.txt
$ md5sum ./build/docopts_darwin_amd64
167295ef8fa7d5b6541c939e118c47fc ./build/docopts_darwin_amd64 where line ending breaks on macos?Worst case is mixed line ending output.
I never had issue yet about line ending on macos. |
Hi @Sylvain303, I'm back after a long delay (see this comment for more details on the delay) and did some testing for this!
So that was just a guess / assumption; I hadn't tested at the time.
So I tested this and it worked fine on macOS, so can confirm now! Thanks for cross-compiling it 👍
Sorry, this was my bad, I looked back at my past code / issues / PRs etc and remembered that this was specifically an issue with Docker: moby/moby#8513 . As such I think this code is good to go and would love to see it released so that the wrapper can be embedded into a single |
So as the discussion seems to actually brings no blocker, and as the examples also don't use any Should we close this discussion issue and open a working issue with some steps?
|
next steps
I think we can move straight to PR from here and work out any kinks in code review, if necessary. Tbh, since you had already made the commit, I thought you were just going to push that. If not, then I can work on a PR with some additional docs etc.
Yea I think command is standard for these types of things, like Two words ( discouraged
|
Following #59 (Search "
Sidebar -- docopts.sh entrypoint wrapper
" heading)We discussed how to embed
docopts.sh
wrapper intodocopts
binary itself. One of the purpose is to keep a single standalone binary. May be it could also open some new feature and or behavior. So lets explore.Pros
docopts
and shell helper at the same placeevaled
content$PATH
too at user preference ex:docopts get-wrapper docopts.sh > $HOME/bin/docopts.sh
Cons
eval
if the code is also evaled at run timeGo sample code
Go code ref
https://pkg.go.dev/embed
https://go.dev/src/fmt/print.go
golang/go#28822 - discussion about automatic handling NEWLINE
https://en.wikipedia.org/wiki/Newline#Representation (seems macos moved to
\n
)from issue above: notepad seems windows 10 to support
\n
May 8th, 2018 - https://devblogs.microsoft.com/commandline/extended-eol-in-notepad/
The text was updated successfully, but these errors were encountered: