matejak / argbash

Bash argument parsing code generator
Other
1.39k stars 63 forks source link

Missing double quotes on DEFINE_LOAD_LIBRARY #149

Closed felipecrs closed 1 year ago

felipecrs commented 3 years ago

This is the current generated function:

load_lib_relativepath() {
    local lib_filename="$script_dir/$1"
    . $lib_filename || die "Not able to load library file '$lib_filename'"
}

Two issues raised by shellcheck:

load_lib_relativepath() {
    local lib_filename="$script_dir/$1"
    # Can't follow non-constant source. Use a directive to specify location.shellcheck(SC1090)
        # Double quote to prevent globbing and word splitting.shellcheck(SC2086)
    . $lib_filename || die "Not able to load library file '$lib_filename'"
}

They could be fixed with:

load_lib_relativepath() {
    local lib_filename="$script_dir/$1"
    # shellcheck disable=SC1090
    . "$lib_filename" || die "Not able to load library file '$lib_filename'"
}

References https://github.com/koalaman/shellcheck/issues/2038.