-
Notifications
You must be signed in to change notification settings - Fork 2
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
Pure POSIX sh version #12
Open
WhitePeter
wants to merge
20
commits into
master
Choose a base branch
from
less_bash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Also add a vi modeline for convenience.
Don't need to assign a variable only to then unset it. The description only get shown, if there is no further action anyway.
Added convenience functions to reduce clutter. Also got rid of some bashisms with the long term goal of making this more portable by being pure POSIX sh code.
According to the docs io-redirections should be done for the whole compound command.
When in non-interactive mode, i.e. in a script, aliases are not expanded. Aliases like `alias rm='rm -i'` are the primary reason for the inflationary, and ill-advised, use of `rm -f`, which has more implications than "overriding" `-i`. It basically does what it advertises and, in the process, shuts up any warning that might be useful in some corner cases.
This should now be a truly POSIX-compliant sh-script. Yay! In the process, progress display via filePos() got a little improvement.
And just to prove a point I removed the `LC_NUMERIC=C` line, which should not have been necessary in the first place. But I guess the bash devs have a different opinion on that.
Use printf only when it is actually needed, i.e. when generating the tags. Also use `grep -E` rather than `-P` since this is about POSIX compliance. P.S.: I take back what I said about LC_NUMERIC.
Totally forgot to set IFS.
Nice to have folding. Plus, it adds some rudimentary code documentation.
There were a lot of stale tmp files in my $TMPDIR, because cleantmp() did not always run, i.e. when exiting without calling it explicitly. Explicit call of cleantmp removed.
Nice to know which signal caused the exit. Before, there was an error stating that `$tmpFile` could not be removed when in fact it was. Took me a while to realize that the trap for EXIT had to be reset.
New function tag_tracks() gets called right after successful remux. Fixes #16
I think it is more convenient to set options as arguments to the program rather than by setting environment variables. The latter is still possible but command line options will take precedence in case of conflict. No documentation yet.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an attempt at getting rid of all bashisms to make mkvrg more portable by being pure POSIX sh. While I was looking at the script after being AWOL for a long time, I felt that some refactoring was in order to reduce clutter. I also don't like to rely on bash too much, as a matter of taste an style.
A further goal, which might warrant another branch, is to actually get rid of the handling of more than one file, because I find it unnecessary. I think it would be better to simplify the script and leverage OS utilities to do the "bigger picture" stuff. For instance there is GNU parallel, with which one can get multi-process execution, whereas this script is strictly sequential and can only do one track of one file at a time. Plus, bash and zsh have very powerful file name glob expressions, which makes the "recursive" mode superfluous.
Let me say it with this example, which uses zsh and parallel:
For the uninitiated,
**
(which also works in bash, as I have been told) is a convenient shortcut to similar functionality offind
:I really think less is more, given the power of the Linux/Unix envrionment. "Do one thing and do it well", and glue together robust one-trick ponies to achieve your goal.
So, what do you think?
P.S.: Case in point, the handling of multiple files is the one thing that stands in the way of being pure POSIX sh, since it relies on arrays, which are an extension beyond POSIX.