import
is a simple and fast module system for Bash and other Unix shells.
Inspired by Go's import command, you specify the URL of the shell script,
and the import
function downloads the file and caches it locally, forever.
The code will never change from below your feet, and will continue to work offline.
https://git.io/fAWiz ← This URL contains a simple add
shell function:
add() {
expr "$1" + "$2"
}
You can use the import
function to download, cache, and use that function in
your own script:
#!/usr/bin/env import
# The URL is downloaded once, cached forever, and then sourced
import "https://git.io/fAWiz"
add 20 22
# 42
The core import
function is fully POSIX-compliant, and maximum compatibility
is the goal. import
is unit tested against the following shell implementations:
- ash - Almquist Shell (BusyBox
ash
and Debiandash
) - ksh - KornShell (
oksh
,mksh
andloksh
flavors) - zsh - Z Shell
- bash - GNU's Bourne Again Shell
- Authentication - Making private GitHub repos work
- API - Application programming interface reference
- Caching - Explanation of the caching strategy
- Configuration - Customizing
import
with environment variables - Installation - Installing and bootstrapping
import
- Namespaced Imports - Top-level and community imports
- Relative Imports - Implementation for relative imports