Skip to content

Commit

Permalink
Fix "unbound variable" error (#11)
Browse files Browse the repository at this point in the history
Fix "unbound variable" error
  • Loading branch information
fabasoad authored Jan 25, 2025
1 parent 087ae90 commit 5440c4a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sh-validators",
"version": "v0.4.0",
"version": "v0.4.1",
"description": "A set of scripts to validate user inputs",
"scripts": [
"fabasoad-validate-dir-exists",
Expand Down
2 changes: 1 addition & 1 deletion lib/validate-dir-exists.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _fail() {
fabasoad_validate_dir_exists() {
if [ ! -d "${1}" ]; then
msg=""
if [ -n "${2}" ]; then
if [ -n "${2:-""}" ]; then
msg="${msg}\"${2}\" parameter is invalid. "
fi
printf "%s\"%s\" is not a directory or does not exist.\n" "${msg}" "${1}" >&2
Expand Down
2 changes: 1 addition & 1 deletion lib/validate-enum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fabasoad_validate_enum() {
;;
*)
msg=""
if [ -n "${3}" ]; then
if [ -n "${3:-""}" ]; then
msg="${msg}\"${3}\" parameter is invalid. "
fi
printf "%s\"%s\" is invalid. Possible values: %s.\n" "${msg}" "${1}" "$(echo "${2}" | sed 's/,/, /g')" >&2
Expand Down
2 changes: 1 addition & 1 deletion lib/validate-file-exists.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _fail() {
fabasoad_validate_file_exists() {
if [ ! -f "${1}" ]; then
msg=""
if [ -n "${2}" ]; then
if [ -n "${2:-""}" ]; then
msg="${msg}\"${2}\" parameter is invalid. "
fi
printf "%s\"%s\" is not a file or does not exist.\n" "${msg}" "${1}" >&2
Expand Down
2 changes: 1 addition & 1 deletion lib/validate-semver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fabasoad_validate_semver() {

if ! [[ "${1}" =~ ^($D)\.($D)\.($D)(-(($D|$PW)(\.($D|$PW))*))?(\+($MW(\.$MW)*))?$ ]]; then
msg=""
if [ -n "${2}" ]; then
if [ -n "${2:-""}" ]; then
msg="${msg}\"${2}\" parameter is invalid. "
fi
printf "%s\"%s\" is not a valid semver.\n" "${msg}" "${1}" >&2
Expand Down
2 changes: 1 addition & 1 deletion lib/validate-tool-installed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _fail() {
fabasoad_validate_tool_installed() {
if ! command -v "${1}" &> /dev/null; then
msg=""
if [ -n "${2}" ]; then
if [ -n "${2:-""}" ]; then
msg="${msg}\"${2}\" parameter is invalid. "
fi
printf "%s\"%s\" is not installed on the current machine.\n" "${msg}" "${1}" >&2
Expand Down

0 comments on commit 5440c4a

Please sign in to comment.