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

bin scripts style & portability #119

Closed
wants to merge 10 commits into from
Closed

bin scripts style & portability #119

wants to merge 10 commits into from

Conversation

boopcamt
Copy link

After issue-117 branch is merged, make the other arb4j/bin/ scripts as stylish and portable as bin/gaw and bin/caw.

Warning: these scripts call some commands that imply undocumented dependencies, such as valgrind, mvn (Maven), and dict.

consistent double-spacing for short scripts
Use dirname instead of appending /.. to a path to get its parent
directory, for consistent style.
Use $(...) instead of backticks `...` for command substition, because
$(...) can be nested, has more obvious handling of backslash escapes,
and for more consistent style. More info:
https://stackoverflow.com/questions/9449778/what-is-the-benefit-of-using-instead-of-backticks-in-shell-scripts
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03
Sadly there is no POSIX-standard util to resolve paths, so use realpath
because it is supported on most platforms nowadays: Linux (gnu
coreutils), the BSDs, MacOS 13. Why not readlink? Inconsistent behavior
across platforms; we could add some fancy system detection code for
fallback, or just live in the future.
Use shell quoting to expand variables in case some rocket scientist
decides to use whitespace in their filenames.
Reserve uppercase names for environment (exported) variables and use
lowercase for all others.
Use a for loop to apply dict to each argument of bin/lookup, and tee the
output to $HOME/words file, but append so you don't erase it each time.
Warning: dict is not documented as a dependency of this project.
Use a for loop to apply dict to each argument of bin/lookup and tee the
output to a file named for the argument in the "words" directory in the
user's home directory. Create the ${HOME}/words directory if it does
not exist.
Warning: dict is not documented as a dependency of this project.
If a script fails a change directory command, exit the script. This was
suggested by shellcheck.

At this point, all scripts in bin/ should pass shellcheck.
Remove the unnecessary trailing /. on the apidocs path.
The -v and -r options of cp are non-POSIX, so eliminate them for maximum
portability. Use -R instead of -r to copy a directory.
@boopcamt
Copy link
Author

Will merge this later.

@boopcamt boopcamt closed this Dec 21, 2022
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.

None yet

1 participant