Skip to content

Question regarding embedding script #116

Open
@damianoneill

Description

Hi, is there a reason why the following won't work?

$ cat make.sh
#!/usr/bin/env bash

read -r -d '' __usage <<-'EOF' || true
  -p --print_deps  Print dependencies
  -c --clean       Clean project
  -b --build       Build project
  -t --test        Run tests
  -v               Enable verbose mode, print script as it is executed
  -d --debug       Enables debug mode
  -h --help        This page
  -n --no-color    Disable color output
EOF

read -r -d '' __helptext <<-'EOF' || true # exits non-zero when EOF encountered
 This is a script to support the build of Healthbot Projects, it is intended to be used by all projects 
 and provide required boilerplate functions
EOF

source main.sh

# print_deps mode
if [[ "${arg_p:?}" == "1" ]]; then
    info "Print dependencies"
fi

# clean mode
if [[ "${arg_c:?}" == "1" ]]; then
    info "Clean project"
fi

# build mode
if [[ "${arg_b:?}" == "1" ]]; then
    info "Build project"
fi

# test mode
if [[ "${arg_t:?}" == "1" ]]; then
    info "Running Tests"
fi

I've left main.sh as is, other than commenting out the Validation and Runtime sections at the bottom of the file.

./make.sh -p
2019-09-05 21:32:42 UTC [     info] Print dependencies

But the following results in no output.

./make.sh -h

I was expecting that the help mode below in main.sh would work

# help mode
if [[ "${arg_h:?}" == "1" ]]; then
  # Help exists with code 1
  help "Help using ${0}"
fi

The rationale for this approach, rather than updating main.sh, is that I can pull the latest main.sh (with fixes / new features) and use with minimal changes.

Any help, much appreciated.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions