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

New convenience function: load library #119

Closed
felipecrs opened this issue Jun 26, 2020 · 1 comment · Fixed by #127
Closed

New convenience function: load library #119

felipecrs opened this issue Jun 26, 2020 · 1 comment · Fixed by #127
Milestone

Comments

@felipecrs
Copy link
Contributor

felipecrs commented Jun 26, 2020

This function is supposed to load a library file (source lib.sh) relative to the script's current folder and properly deal with the errors, such as not being able to find the library file.

Something like this:

function load_lib() {
  local lib_file=$1
  # shellcheck disable=SC1090
  source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$lib_file" || die "[ERROR] Not able to load the library $lib_file"
}

laod_lib "../common.sh"
load_lib "lib.sh"

With the template:

# DEFINE_LOAD_LIB
@matejak matejak added this to the 2.9.0 milestone Jul 8, 2020
@matejak
Copy link
Owner

matejak commented Jul 8, 2020

Thanks for the suggestion, I will look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants