8000 GitHub - gaurav-gogia/neo-core.sh: ๐Ÿš€ A Pure POSIX Shell Library for Data Structures and Utilities
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

gaurav-gogia/neo-core.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ› ๏ธ neo-core.sh

๐Ÿš€ A Pure POSIX Shell Library for Data Structures and Utilities

neo-core.sh is a lightweight, POSIX-compliant shell library providing essential data structures (maps, objects, linked lists) and utilities (file handling, XML parsing, etc.).

๐Ÿ”Œ Plug & Play: Easily import and use in any shell script. โšก

Pure POSIX: No Bash-isms, 100% POSIX-compliant. ๐Ÿ” Optimized: Efficient and memory-friendly implementations.


๐Ÿ“ฆ Installation

Clone the repository:

git clone https://github.com/gaurav-gogia/neo-core.sh.git

Then, source the required modules in your script: . path/to/neo-core.sh/core/map.sh . path/to/neo-core.sh/core/ll.sh

Another method of sourcing these scripts would be to use import functions provided in the library.

Features

Data Structures

  1. Set
  2. Map
  3. Object
  4. Nested Object
  5. Linked List

Parsing

  1. XML

Using Maps

#!/bin/sh

__imports=""

import() {
    file="$1"
    case "$__imports" in
        *"|$file|"*) return ;;
    esac
    __imports="$__imports|$file|"

    if [ -f "$file" ]; then
        printf "Importing %s\n" "$file"
        . "$file"
    else
        printf "Import Error: %s not found\n" "$file" >&2
        exit 1
    fi
}

import "path/to/neo-core.sh/core/map.sh"

map_set "key" "value"
map_get "key"
map_del "key"

Using Linked Lists

#!/bin/sh

__imports=""

import() {
    file="$1"
    case "$__imports" in
        *"|$file|"*) return ;;
    esac
    __imports="$__imports|$file|"

    if [ -f "$file" ]; then
        printf "Importing %s\n" "$file"
        . "$file"
    else
        printf "Import Error: %s not found\n" "$file" >&2
        exit 1
    fi
}

import "path/to/neo-core.sh/core/map.sh"
import "path/to/neo-core.sh/core/obj.sh"
import "path/to/neo-core.sh/core/ll.sh"

object_set "head" "name" "First Node"
object_set "second" "name" "Second Node"

list_append "head" "second"
list_iterate "head"

About

๐Ÿš€ A Pure POSIX Shell Library for Data Structures and Utilities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0