The uniOS userspace shell supports basic scripting for diagnostics, automation, and system tasks.
Scripts are plain text files containing shell commands. Run a script with:
run /data/startup.shYou can also use source to run a script within the current shell context:
source diagnostics.shLines starting with # are treated as comments.
Variables are session-local. Use set to define or update a variable:
set PATH=/bin
set OS_NAME=uniOSTo remove a variable:
unset OS_NAMEPrefix the variable name with $ to expand its value:
echo $PATHThe special variable $? contains the exit status of the previous command (0 for success, non-zero for error).
if blocks allow for basic branching.
if $STATUS == 0
echo "Operation successful"
else
echo "Operation failed"
endifSupported operators:
- String:
==,!= - Numeric:
<,>,<=,>=
while blocks repeat execution as long as a condition is met.
# Example: Waiting for a file to appear
while ! stat /data/ready.txt
sleep 500
endNote
Variable increments are not natively supported in the current shell. Loops are primarily intended for polling or persistent diagnostic tasks.
The shell includes built-in support for:
- File System:
ls,cd,pwd,cat,touch,rm,mkdir,cp,mv. - System Info:
mem,ps,uptime,date,uname,sysinfo,cpuinfo. - Networking:
ping,resolve. - Process:
kill,exec,reboot,poweroff.
- Variable Count: Max 32 variables per session.
- Variable Length: Max 256 bytes per value.
- Script Length: Max 256 lines.
- Loop Iterations: Safety cap at 10,000 iterations.
- Nesting: Max 16 levels of nested blocks.