๐ ๏ธ Checking Tools
Utilities for verification tasks.
existโ
Checks if paths exist.
| Argument | Description |
|---|---|
TYPE | Optional: file, folder, symlink, block |
PATH | Path(s) to check |
if exist "Myfile.bin"; then ui_print "Exists"; fi
if exist folder "FOLDER"; then ui_print "Folder exists"; fi
if exist file "myfile.txt"; then ui_print "File exists"; fi
if exist symlink "/system/vendor"; then ui_print "Symlink exists"; fi
if exist block "/dev/block/dm-0"; then ui_print "Block exists"; fi
if exist "Myfile.bin" "OTHER.bin" "FOLDER"; then ui_print "All exist"; fi
is_validโ
Checks if files exist and are non-empty.
| Argument | Description |
|---|---|
FILE | File(s) to check |
if is_valid "file.txt"; then ui_print "Valid file"; fi
is_readableโ
Checks if a file exist and is readable as text.
| Argument | Description |
|---|---|
file | File path to check. |
<max-bytes> | Maximum bytes to read (default: 32). |
<min-bytes> | Minimum readable bytes required (default: 4). |
if is_readable "/sdcard/test.txt"; then ui_print "File is readable"; fi
if is_readable "/sdcard/test.txt" 50 50; then # Read 50 bytes and all must be readable text
ui_print "File is readable"
fi
is_execโ
Checks if a file or folder exists and has execute permissions.
| Argument | Description |
|---|---|
path | File or folder path to check |
if is_exec "/system/bin/sh"; then ui_print "The file has execution permissions"; fi
if is_exec "/system/bin"; then ui_print "The folder has and can grant execution permissions"; fi
Although a file has execution permissions does not mean that it is executable.
containsโ
Checks if text exists in a file.
| Argument | Description |
|---|---|
TEXT | Text to search for |
FILE | File to check |
if contains "test" "file.txt"; then ui_print "Found"; fi
check_contentโ
Checks if files exist within a ZIP.
| Argument | Description |
|---|---|
FILE | File(s) to check |
ZIP | ZIP file |
if check_content "file.txt" "Main.zip"; then ui_print "Exists"; fi
if check_content "file.txt" "file2.txt" "folder/huh.bin" "MAIN.zip"; then ui_print "All exist"; fi
can_runโ
Checks if a binary can run on the device.
| Argument | Description |
|---|---|
FILE | Binary file |
if can_run "my_binary"; then ui_print "Runnable"; fi
is_numberโ
Checks if a string is a number (supports decimals).
| Argument | Description |
|---|---|
TEXT | Text to check |
if is_number "1.23"; then ui_print "Is number"; fi
is_hexโ
Checks if a string is hexadecimal.
| Argument | Description |
|---|---|
TEXT | Text to check |
if is_hex "1a2b3c"; then ui_print "Is hex"; fi
is_abcโ
Checks if a string is purely alphabetic (A-Z, spaces allowed).
| Argument | Description |
|---|---|
TEXT | Text to check |
if is_abc "Hello World"; then ui_print "Alphabetic"; fi
is_textโ
Checks if a string has any visible characters.
| Argument | Description |
|---|---|
TEXT | Text to check |
if is_text "Hello"; then ui_print "Has text"; fi
if ! is_text " "; then ui_print "Empty"; fi
is_zipโ
Checks if a file is a ZIP using hex magic.
| Argument | Description |
|---|---|
FILE | File to check |
if is_zip "test.zip"; then ui_print "Is ZIP"; fi
is_tarโ
Checks if a file is a TAR using hex magic.
| Argument | Description |
|---|---|
FILE | File to check |
if is_tar "test.tar"; then ui_print "Is TAR"; fi
is_gzipโ
Checks if a file is a GZIP using hex magic.
| Argument | Description |
|---|---|
FILE | File to check |
if is_gzip "test.gz"; then ui_print "Is GZIP"; fi
is_bzipโ
Checks if a file is a BZIP using hex magic.
| Argument | Description |
|---|---|
FILE | File to check |
if is_bzip "test.bz2"; then ui_print "Is BZIP"; fi
is_xzโ
Checks if a file is an XZ using hex magic.
| Argument | Description |
|---|---|
FILE | File to check |
if is_xz "test.xz"; then ui_print "Is XZ"; fi
is_lessโ
Checks if a number is less than another (supports decimals).
| Argument | Description |
|---|---|
VAL1 | First value |
VAL2 | Second value |
if is_less "1.5" "2"; then ui_print "Less"; fi
is_greaterโ
Checks if a number is greater than another (supports decimals).
| Argument | Description |
|---|---|
VAL1 | First value |
VAL2 | Second value |
if is_greater "2.2" "1.5"; then ui_print "Greater"; fi
is_equalโ
Checks if two values are equal (supports text and numbers).
| Argument | Description |
|---|---|
VAL1 | First value |
VAL2 | Second value |
if is_equal "test" "test"; then ui_print "Equal"; fi
is_greater_equalโ
Checks if a number is greater than or equal to another (supports decimals).
| Argument | Description |
|---|---|
VAL1 | First value |
VAL2 | Second value |
if is_greater_equal "2" "2"; then ui_print "Greater or equal"; fi
is_less_equalโ
Checks if a number is less than or equal to another (supports decimals).
| Argument | Description |
|---|---|
VAL1 | First value |
VAL2 | Second value |
if is_less_equal "1.5" "2"; then ui_print "Less or equal"; fi
is64bitโ
Checks if a binary supports 64-bit architecture.
| Argument | Description |
|---|---|
FILE | Binary file |
if is64bit "my_binary"; then ui_print "64-bit"; fi
contains_arrayโ
Checks if an array contains a value.
| Argument | Description |
|---|---|
STRING | Value to check |
ARRAY | Array to search |
test=("a" "o l e" "huh")
if contains_array "o l e" "${test[@]}"; then ui_print "Found"; fi
magic_fileโ
Checks file type using custom hex magic values.
| Argument | Description |
|---|---|
HEX | Hex code to match |
-t TYPE | Predefined type: zip, gzip, bzip, xz, tar, Z, rar, 7z, lz4, png, jpg, webp, ico, bmp, gif, gks, rgb, pm, mp3, ogg, wav, mp4, avi, msdos, unix, dex, cpio, ramdisk, sparse, super, erofs, ext4 |
FILE | File to check |
-o N | Offset bytes |
-b N | Bytes per line |
-l N | Lines to check |
-s | Show parsed hex content |
-sl | Show only matching hex line |
if magic_file -t jpg "Test.jpg"; then ui_print "JPG detected"; fi
if magic_file -t tar "test.tar"; then ui_print "TAR detected"; fi
if magic_file ffd8ffe0 "possible_jpg_image"; then ui_print "JPG detected"; fi
if magic_file -o 257 7573746172 "possible_tar_file"; then ui_print "TAR detected"; fi
testrwโ
Tests if folders have write permissions.
| Argument | Description |
|---|---|
FOLDER | Folder(s) to test |
if testrw "/system"; then ui_print "Writable"; else ui_print "Read-only"; fi
if ! testrw "/system" "/vendor" "/odm"; then abort "Read-only partition"; fi
testvarnameโ
Verifies if text is a valid variable name.
| Argument | Description |
|---|---|
TEXT | Text to check |
if testvarname "my_var"; then ui_print "Valid"; fi
if ! testvarname "90var"; then ui_print "Invalid"; fi