bsfl

Bash Shell Function Library
授权协议 BSD-3-Clause License
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 经俊茂
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

BSFL

The Bash Shell Function Library (BSFL) is a small bash script that acts as a library for bash scripts. It provides a couple of functions that makes the lives of most people using shell scripts a bit easier.

This project is a fork of the original work of Louwrentius.

Getting started

In order to use BSFL, you have to include the library in your bash scripts. You can do it with an absolute path:

source <absolute path to BSFL>

For example:

source /opt/bsfl/bsfl.sh

Or with a relative path:

declare -r DIR=$(cd "$(dirname "$0")" && pwd)
source $DIR/<relative path to BSFL>

For example:

declare -r DIR=$(cd "$(dirname "$0")" && pwd)
source $DIR/../lib/bsfl.sh

What's next?

The best way to learn how BSFL works is to look at the examples available in the examples folder.

Documentation

The online documentation is available here.

Building the documentation is done by using Doxygen:

cd <BSFL repository>/doc
git submodule update --init --recursive
doxygen Doxyfile

Dependencies

BSFL is implemented for bash version 4. Prior versions of bash will fail at interpreting its code.

In addition, BSFL depends of some external programs. Here is the list of these programs:

  • date
  • grep
  • logger
  • printf
  • tput
  • tr

However, we try to get as much as possible a standalone library. Hence, some of these external dependencies will be removed in the future.

Unit tests

BSFL uses Bats testing framework to verify the correct behaviour of its functions.

To run all the tests:

bats <BSFL repository>/test

Or, to run only the tests of a specific group:

bats <BSFL repository>/test/<test file>

For example, for the network group:

bats <BSFL repository>/test/network.bats

Releasing a new version

Below are the different steps to do before releasing a new version:

  • Run all tests and be sure they all pass
  • Update the BSFL_VERSION variable in lib/bsfl.sh
  • Update the PROJECT_NUMBER variable in doc/Doxygen
  • Update the Version variable in bsfl.spec
  • Update README.md if needed

Get involved!

This project is still under development. Contributions are welcomed.

License

New BSD

  • AT&T汇编语法: bsfl op1 op2 含义 扫描操作数op1,找到到第1个非0bit位, 把非0bit位的索引下标(从0计算)存入op2. 扫描从低位到高位扫描(也就是从右->左) 举例: 操作数:1 第一个非0bit的位置 0 操作数:2 第一个非0bit的位置 1 操作数:4 第一个非0bit的位置 2 ...... 适用场景举例1 linux内核在进程调用算法中,使用了数组来维护进程

  • 导读: bsfl汇编指令:       intel汇编指令:bsf   oprd1,oprd2;       顺向位扫描(bit   scan   forward)       从右向左(从位0-->位15或位31)扫描字或双字操作数oprd2中第一个含"1"的位,并把扫描到的第一个含'1'的位的位号送操作数oprd1       AT&T格式汇编指令bsfl类似bsf,只是源操作数和目的操作数顺

  • 导读:  bsfl汇编指令:        intel汇编指令:bsf   oprd1,oprd2;        顺向位扫描(bit   scan   forward)        从右向左(从位0-->位15或位31)扫描字或双字操作数oprd2中第一个含"1"的位,并把扫描到的第一个含'1'的位的位号送操作数oprd1        AT&T格式汇编指令bsfl类似bsf,只是源操作数和目

  • bsfl ecx,ecx           # 从低位(0位)开始扫描位图,看是否有1 的位,若有,则ecx保留该为的偏移值(即地址位0--31)。