Skip to main content

๐Ÿ› ๏ธ Checking Tools

Utilities for verification tasks.


existโ€‹

Checks if paths exist.

ArgumentDescription
TYPEOptional: file, folder, symlink, block
PATHPath(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.

ArgumentDescription
FILEFile(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.

ArgumentDescription
fileFile 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.

ArgumentDescription
pathFile 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
note

Although a file has execution permissions does not mean that it is executable.


containsโ€‹

Checks if text exists in a file.

ArgumentDescription
TEXTText to search for
FILEFile to check
if contains "test" "file.txt"; then ui_print "Found"; fi

check_contentโ€‹

Checks if files exist within a ZIP.

ArgumentDescription
FILEFile(s) to check
ZIPZIP 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.

ArgumentDescription
FILEBinary file
if can_run "my_binary"; then ui_print "Runnable"; fi

is_numberโ€‹

Checks if a string is a number (supports decimals).

ArgumentDescription
TEXTText to check
if is_number "1.23"; then ui_print "Is number"; fi

is_hexโ€‹

Checks if a string is hexadecimal.

ArgumentDescription
TEXTText 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).

ArgumentDescription
TEXTText to check
if is_abc "Hello World"; then ui_print "Alphabetic"; fi

is_textโ€‹

Checks if a string has any visible characters.

ArgumentDescription
TEXTText 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.

ArgumentDescription
FILEFile 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.

ArgumentDescription
FILEFile 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.

ArgumentDescription
FILEFile 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.

ArgumentDescription
FILEFile 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.

ArgumentDescription
FILEFile 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).

ArgumentDescription
VAL1First value
VAL2Second value
if is_less "1.5" "2"; then ui_print "Less"; fi

is_greaterโ€‹

Checks if a number is greater than another (supports decimals).

ArgumentDescription
VAL1First value
VAL2Second 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).

ArgumentDescription
VAL1First value
VAL2Second 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).

ArgumentDescription
VAL1First value
VAL2Second 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).

ArgumentDescription
VAL1First value
VAL2Second value
if is_less_equal "1.5" "2"; then ui_print "Less or equal"; fi

is64bitโ€‹

Checks if a binary supports 64-bit architecture.

ArgumentDescription
FILEBinary file
if is64bit "my_binary"; then ui_print "64-bit"; fi

contains_arrayโ€‹

Checks if an array contains a value.

ArgumentDescription
STRINGValue to check
ARRAYArray 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.

ArgumentDescription
HEXHex code to match
-t TYPEPredefined 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
FILEFile to check
-o NOffset bytes
-b NBytes per line
-l NLines to check
-sShow parsed hex content
-slShow 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.

ArgumentDescription
FOLDERFolder(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.

ArgumentDescription
TEXTText to check
if testvarname "my_var"; then ui_print "Valid"; fi
if ! testvarname "90var"; then ui_print "Invalid"; fi