Giter Site home page Giter Site logo

qithub-bot / oliosource Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 15 KB

✅ A simple shell script that merges "sourced" shell scripts as a single script for distribution.

License: MIT License

Dockerfile 5.47% Shell 94.53%
posix-compatible posix-sh shellscript shell-script

oliosource's Introduction

All Tests

OlioSource

"oliosource" is a simple shell script that merges "sourced" shell scripts as a single script for your convenient distribution.

In other words, " . ./foo.sh " or " source ./foo.sh " lines in a shell script get replaced with the content of " ./foo.sh " without the shebang.

Usage

oliosource /path/to/target/main.sh
  • Note
    • If shfmt is installed then it will format the output as well.
    • Runs on POSIX compatible shells.
    • Tested on latest macOS and Linux(Ubuntu).

About OlioSource

Grouping the frequently used functions in other files and import or source them eliminates duplicate code and reduces the size of a script for better visibility and maintenance.

Even though we like this approach, we felt distributing as a single script is much convenient for the users to download.

To solve this problem, "oliosource" is our rough draft to merge the "sourced" scripts into one file. It simply replaces the " . " or " source " line to the source file's content without the shebang and nothing more.

Any contribution for the better is welcome!

Example

$ cat ./path/to/main_script.sh
#!/bin/bash

# shellcheck disable=SC1091
. ./parrotry.sh

if [ 0 = $# ]; then
    echo >&2 "argument missing"
    exit 1
fi

parrotry "$@"
$ cat ./path/to/parrotry.sh
#!/bin/bash

# parrotry echoes the given args to STDOUT
parrotry() {
    echo "$@"
}
$ # Let's run!!
$ oliosource ./path/to/main_script.sh
#!/bin/bash

# parrotry echoes the given args to STDOUT
parrotry() {
    echo "$@"
}

if [ 0 = $# ]; then
    echo >&2 "argument missing"
    exit 1
fi

parrotry "$@"

Download

curl -sL https://git.io/oliosource
  • To install the script, place it in any path at $PATH env variable and chmod +x to give access.
# Sample to install OlioSource under /usr/local/bin
# (you may need sudo to chmod and mv)
curl -sL https://git.io/oliosource > oliosource && \
chmod +x oliosource && \
mv ./oliosource /usr/local/bin

Remarks

  • Issues and PRs may be in Japanese, Spanish or English.
  • Providing a test that reproduces the failure in the issue will help us a lot.

License

oliosource's People

Contributors

keinos avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.