Skip to content

Navigation Menu

Sign in
Appearance settings

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
Appearance settings

yyu/kissbash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

15 Commits

Repository files navigation

kissbash - A Simple and Stupid Bash Script Library

Despite what people say, I decide to write a bash script library.

If nobody cares, at least it will benefit myself.

How to use

Set the KISSBASH_PATH environment variable and you are good to go.

$ git clone https://github.com/yyu/kissbash.git ~/.kissbash
$ export KISSBASH_PATH=~/.kissbash/kissbash

Example

$ cat > /tmp/myscript << "EOF"
. "$KISSBASH_PATH/console/lines"
echos 3; echo line1
echo line2 | line_pre_echo_control up1 up1 up1
echo line3
echos 10
cat /tmp/myscript | line_pre_echo_control up1 up1
echos 7
EOF

output:

$ bash4 /tmp/myscript
line2
line3
line1
echos 7
cat /tmp/myscript | line_pre_echo_control up1 up1
echos 10
echo line3
echo line2 | line_pre_echo_control up1 up1 up1
echos 3; echo line1
. "$KISSBASH_PATH/console/lines"
$

Document

console/lines

echos

One argument:

$ . $KISSBASH_PATH/console/lines
$ (echos 2; echo hello) | cat -n
 1	
 2	
 3	hello

More than one argument:

$ . $KISSBASH_PATH/console/lines
$ (echos 3 .; echo hello) | cat -n
 1	...hello

serr_with_color

$ . $KISSBASH_PATH/console/lines
$ echo hello | serr_with_color red
hello

You should see red hello in your console.

tee_serr_with_color

$ . $KISSBASH_PATH/console/lines
$ echo hello | tee_serr_with_color red
hello
hello
$ echo hello | tee_serr_with_color red > /dev/null
hello

You should see red hello for stderr and normal hello for stdout.

line_pre_echo_control

$ . $KISSBASH_PATH/console/lines
$ echo -e "\none\n"; echo two; echo three
one
two
three
$ echo -e "\none\n"; echo two | line_pre_echo_control up1; echo three
one
two
three

exec/explicitly

$ . $KISSBASH_PATH/exec/explicitly
$ explicitly echo "2+3" | bc
echo 2+3
5

testing

$ t/test-all
Running /.../kissbash/t/bash/test-assoc-array
PASS test_bash_version_too_low
PASS test_bash_version_ok
PASS test_bash_version_high
Running /.../kissbash/t/util/test-explicitly-exec
PASS test_explicitly_good
**************************************DONE**************************************
for details,
cat /var/folders/yd/c3kph1693ns3rtft7jwscyj5snhf_t/T/tmp.qWVmW057
```

Tip: t/test-all -v will automatically show details.

About

Simple and Stupid Bash Script Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /