Inline script sources
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
-
POSIXcompliant -
Sourcing with quotes, spaces and more
-
Sourcing from
$PATH -
Sourcing from ShellCheck source:
# shellcheck source=path/to/script.shWarning: Available only if
sourceor.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 skipNote: Works with ShellCheck as well
# inline skip # shellcheck source=path/to/script.sh . path/to/script.sh
-
Configurable
See Options
wget https://raw.githubusercontent.com/carlocorradini/inline/main/inline.shWarning: Script must have execute permission:
chmod u+x ./inline.sh
Note: See Options for more configuration
Note: Type
--helpfor 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.
-
Inline script
hello.shand save it asworld.sh./inline.sh --in-file hello.sh --out-file world.sh
-
Inline script
hello_world.shand overwrite it./inline.sh --in-file hello_world.sh --overwrite
| 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 |
I would love to see your contribution ❤️
See CONTRIBUTING guidelines.
This project is licensed under the MIT License.
See LICENSE file for details.