Skip to content

carlocorradini/inline

Repository files navigation

Inline script sources

ci semantic-release: angular

Inline script sources (source or .).

It is convenient to be able to divide long scripts into many files to make them easier to work with while maintaining the ability to distribute them as a single script.

Inspired by @joehillen GitHub Gist

Features

  • POSIX compliant

  • Sourcing with quotes, spaces and more

  • Sourcing from $PATH

  • Sourcing from ShellCheck source: # shellcheck source=path/to/script.sh

    Warning: Available only if source or . is invalid

    # shellcheck source=path/to/script.sh
    . "$DIR/path/to/script.sh"
  • Sources in sources

  • Recursion detection

  • Shebang (#!) removal in sources

  • Skip source: # inline skip

    Note: Works with ShellCheck as well

    # inline skip
    # shellcheck source=path/to/script.sh
    . path/to/script.sh
  • Configurable
    See Options

Download

wget https://raw.githubusercontent.com/carlocorradini/inline/main/inline.sh

Usage

Warning: Script must have execute permission: chmod u+x ./inline.sh

Note: See Options for more configuration

Note: Type --help for more information

Pass the script to be aligned with --in-file path/to/script.sh
It creates a script called script.aligned.sh
The resulting script is automatically aligned: all sources (source or .) are directly included.

Examples

  1. Inline script hello.sh and save it as world.sh

    ./inline.sh --in-file hello.sh --out-file world.sh
  2. Inline script hello_world.sh and overwrite it

    ./inline.sh --in-file hello_world.sh --overwrite

Options

Name Description Default Values
--disable-color Disable color false
--help Show help message and exit
--in-file <FILE> Input file Any valid file
--log-level <LEVEL> Logger level info fatal Fatal level
warn Warning level
info Informational level
debug Debug level
silent Silent level
--out-file <FILE> Output file [IN_FILE_NAME].inlined[IN_FILE_EXTENSION] Any valid file
--overwrite Overwrite input file false

Contributing

I would love to see your contribution ❤️

See CONTRIBUTING guidelines.

License

This project is licensed under the MIT License.
See LICENSE file for details.