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.
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
The best way to learn how BSFL works is to look at the examples available in the examples folder.
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
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:
However, we try to get as much as possible a standalone library. Hence, some of these external dependencies will be removed in the future.
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
Below are the different steps to do before releasing a new version:
BSFL_VERSION
variable in lib/bsfl.sh
PROJECT_NUMBER
variable in doc/Doxygen
Version
variable in bsfl.spec
README.md
if neededThis project is still under development. Contributions are welcomed.
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)。