Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Loadable Bash builtin for using an array as a table

License

NotificationsYou must be signed in to change notification settings

cjungmann/ate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OVERVIEW

ate is Array Table Extension, which creates and useshigh-performance vector indexes to elements of Bash arrays,permitting instant access to elements for reading and writing,fast sorting and searching using binary-searches for sortedtables.

FEATURES

  • Bash BuiltinBash builtins can avoid the performance penalty of starting childprocesses, and can initiate script responses through callbacks toscript functions.

  • C-language Vector of PointersUsing fixed-length memory C structs containing pointers to the Basharray elements permits access to the Bash array elements by indexthrough simple multiplication.

  • Establishes a Virtual TableThe pointers of the vector can simulate a table by pointing toBash array elements at fixed increments. For example, a tablewhose rows contain three fields will have pointers to everythird Bash array element.

  • Use Bash Memory ManagementThis is a mixed blessing. Using Bash variables and Bash arraysfor the data permits Bash garbage collection to manage theirlifetimes. The downside is that, without destructors, it isdifficult or impossible to guarantee an orderly release ofno-longer needed memory. Thus the indexes are not dynamic.That is, a table length is fixed until it is explicitely reindexed.

  • LibraryI'm experimenting with an interface for including Bash scriptfragments ofate solutions and utilities into new Bash scripts.The library interface provides a list of available scriptlets,basic usage info about each scriptlet, and a system for managingincludes without duplicates.

INSTALLATION

Prerequisites

Ensure you have the following:

  • Bash version4.0.0 or higher
  • A C-compiler (gcc) for compiling the command
  • bash_builtins development package
  • git to clone, build, and statically link afew library dependencies

The development environment is Linux. I should work on any Linuxdistribution, and will probably work on BSD as well (I haven't testedit there yet).

Installation Steps

  1. Clone the repository:
    git clone https://github.com/cjungmann/ate.git
  2. Navigate to the cloned directory:
    cd ate
  3. Run theconfigure script to resolve dependencies and prepare the Makefile.
    ./configure
  4. Build and install the builtin:
    makesudo make install
  5. Verify the installation by running:
    enable ateate list_actions

USAGE

Syntax

ate [action_name] [handle_name] [options]

Example

The following example will make and display anate two-columntable of file names and sizes:

enable atesource<( ate_sources ate_exit_on_error ate_print_formatted_table)# Make a two-field tabledeclare AHANDLEatedeclare AHANDLE 2ate_exit_on_errordeclare namewhile IFS='|'read -r -a row;do   ate append_data AHANDLE"${row[@]}"done<<( stat -c"%n|%s"*)ate index_rows AHANDLEate_exit_on_errorate_print_formatted_table AHANDLE

About

Loadable Bash builtin for using an array as a table

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp