-
-
Notifications
You must be signed in to change notification settings - Fork 1
Split main() into smaller functions. #4
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
base: main
Are you sure you want to change the base?
Conversation
fcf6fa0 to
65f315e
Compare
| Verbose= | ||
| DryRun= | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these may have been initialized here, empty, as documentation / for developer awareness of their existence.
LMK if you want them restored.
| initialize | ||
| main_prerequisites; | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user is sourcing apt-bundle then the temporary directory & files need to be present in order for any of the subsequent source / package statements to work.
Prerequisites are also obviously necessary.
Prerequisites leverage the same system for installing packages so they need the same temp directory & files.
| cat -- "$@" > "$TmpDir/Debfile" | ||
| . "$TmpDir/Debfile" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user is sourcing apt-bundle then the calling script is the Debfile (sort of).
Meaning we can't copy & source the entire (list of) Debfiles into the temp dir.
We have to let the user invoke source/package and eventually a "flush" function (not yet defined).
| } | ||
|
|
||
| main() { | ||
| local opt file destdir filename dest tmpfile ppa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables within this declaration became unused after extraction.
Replaced with local varname= in their respective functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: AFAIK sh doesn't have local variables, or even the keyword itself.
Most of the time sh is actually an aliased bash with a compatibility flag enabled and bash gives it the local keyword even though POSIX sh doesn't support it.
| return | ||
| fi | ||
|
|
||
| set -e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exit on first error can be enabled from the shebang #!/bin/sh -e, is this not useful?
65f315e to
544fa52
Compare
544fa52 to
7181160
Compare
First step towards allowing apt-bundle to be used as a library is splitting the functions.
I've created this draft PR with functionality split -- not much attention to function names, I just wanted to get the ball rolling.