From f1cd3c042aaf8aaa29ab166976012d2ed9cc907d Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 21 Dec 2020 11:29:26 +0000 Subject: cpt-lib: add ability to be used as a script - cpt script no longer ignores anything. - If cpt-lib is invoked from the command-line, it parses the given command-line arguments, making it possible to be used as a script. FossilOrigin-Name: 8484d0ff082d03f38fa41d7a5e76c21bfdd5951b6db5193bb4a7f17e74a5025e --- src/cpt-lib.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/cpt-lib.in') diff --git a/src/cpt-lib.in b/src/cpt-lib.in index 34af54b..27ea686 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -1,4 +1,5 @@ #!/bin/sh -ef +# @DOCSTRING@ # shellcheck source=/dev/null # # This is the Carbs Packaging Toolchain written for Carbs Linux. @@ -1912,3 +1913,15 @@ create_cache() { fi } + +# If the library is being called with its own name, run arguments. +if [ "${0##*/}" = cpt-lib ]; then + pd() { + setup REST help:usage -- "usage: ${0##*/} [funcall...]" + global_options + } + eval "$(getoptions pd parse "$0")" + parse "$@" + eval set -- "$REST" + "$@" +fi -- cgit v1.2.3