Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding embedding script #116

Open
damianoneill opened this issue Sep 5, 2019 · 0 comments
Open

Question regarding embedding script #116

damianoneill opened this issue Sep 5, 2019 · 0 comments

Comments

@damianoneill
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant