Skip to content

eug/import

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

import.sh

An import system for shell script.

About

This project implements an import system for shell script, allowing to import specific functions and set alias for it. The current version only supports BASH, but it can be easily extended for any alternative. Also, some guidelines must be followed to avoid possible conflicts during the usage.

Basic usage

import <module>[.function][ as <alias>]

Guidelines

  • Each module must not have any dependency with other modules
  • Private functions must be prefixed with __ (double underscore)
  • Each public function must depend only by private functions
  • All modules must contain .sh extension

Example

#!/bin/bash

source ../import.sh

import core/file                     # import entire module
import core/string.to_lower          # import specific function
import core/string.to_upper as upper # import specific function and define an alias

if [ ! $(isdir "$1") ]; then
    echo $(to_lower "$1 IS NOT A DIRECTORY")
else
    echo $(upper "$1 is a directory")
fi

About

An import system for shell script

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages