|
11 月之前 | |
---|---|---|
src | 11 月之前 | |
test | 11 月之前 | |
README.md | 11 月之前 |
bash filters and validators collection.
All validators return either 0 or 1
Provide the validators file path preceded by dot then call validator
$ . /apath/to/src/validators.sh && echo $(isurl 'https://host.domain.tld')
1
$ . rpath/to/validators.sh && [[ $(isurl 'https://host.domain.tld') -eq 1 ]] && echo 'Happy' || echo 'Sad'
Happy
$ . rpath/to/validators.sh && [[ $(isurl 'phone://host.domain.tld') -eq 0 ]] && echo 'No' || echo 'Yes'
No
$ . rpath/to/validators.sh && (($(iscomment ' # commented'))) && echo ';)' || echo '^^'
;)
Just source the filter or validator file with a correct path as below.
#!/bin/bash
source /a/path/to/bafiva/src/validators.sh
source /a/path/to/bafiva/src/filters.sh
From an existing shell session sourcing once let validators to be ready until end session.
Sourcing validators.sh or filters.sh in your .bashrc bypass the first source requirement.
Thus command will be available from your autocompletion shell on prompt tabulating.
$ is<tab>
ischroot iscidr6 isdv4-serial-debugger isip4 ispell isurl
iscidr4 iscomment isdv4-serial-inputattach isip6 ispell-wrapper
$ isip4 192.168.168.168
1
Filter ipdesag requires ipcalc binary to be installed.
Validators suites will be rendered.
$ . /a/path/to/bafiva/test/validators.sh
Make pull request and don't forget to make the corresponding test before.