Skip to content

Additional information in the default script template header #592

@DannyBen

Description

@DannyBen

Discussed in #591

Originally posted by meleu December 27, 2024

request

I suggest to put in the default script template header an information saying that the code in that file is going to be put inside a function.

Something like the second line below:

echo "# this file is located in 'src/upload_command.sh'"
echo "# the code here will be placed **inside a function**"

I'm not really suggesting this exact text, but the message I'd like to be conveyed.

reasoning

I'm used to put all bash code inside functions. Even for simple scripts, I create a main function and then call it with main "$@".

The very first time I was trying bashly, I've coded my src/root_command.sh as I would do with my usual way of coding, and it generated this:

cli_upload_command() {
  # src/upload_command.sh
  hello() {
    echo "hello world"
  }
  hello
}

That is actually valid and really works, but the "function inside a function" situation wasn't what I was expecting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions