From 430a233879548094c49e36406a9a62a47b7be480 Mon Sep 17 00:00:00 2001 From: EnumDev Date: Tue, 8 Oct 2024 09:42:49 +0300 Subject: [PATCH] It is no longer necessary to type the output name of the source bpm file --- bpm-package | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/bpm-package b/bpm-package index f913e2f..206ef59 100755 --- a/bpm-package +++ b/bpm-package @@ -1,9 +1,4 @@ #!/bin/bash -if [ $# -eq 0 ] -then - echo "No output package name given!" - exit 1 -fi if [ -f .compilation-options ]; then source ./.compilation-options @@ -20,9 +15,19 @@ while getopts "cskfa:" flag; do esac done -output="${@:$OPTIND:1}" +if [ -f pkg.info ]; then + echo "pkg.info file found" +else + echo "pkg.info file not found in $PWD" + exit 1 +fi -if [[ ! "$output" =~ ^[a-z.A-Z0-9_-]{1,}$ ]]; then +output="${@:$OPTIND:1}" +if [ -z "$output" ]; then + pkgname=$(grep "^name: " pkg.info) + output=$(echo "$pkgname" | cut -d' ' -f2)"-src.bpm" +fi +if [ -z "$output" ] || [[ ! "$output" =~ ^[a-z.A-Z0-9_-]{1,}$ ]]; then echo "Invalid output name! The name must only contain letters, numbers, hyphens or underscores!" exit 1 fi @@ -72,13 +77,6 @@ else fi fi -if [ -f pkg.info ]; then - echo "pkg.info file found" -else - echo "pkg.info file not found in $PWD" - exit 1 -fi - for pkginfo in ./pkg.inf*; do pkginfo=$(basename "$pkginfo") echo "${pkginfo} file found"