mirror of
https://github.com/A2osX/A2osX.git
synced 2025-04-18 21:37:29 +00:00
122 lines
2.1 KiB
Plaintext
122 lines
2.1 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
#!/bin/sh
|
||
#set -x
|
||
|
||
echo abcd > TEST.LOG
|
||
echo efgh >> TEST.LOG
|
||
|
||
echo set exec 1...
|
||
set TEST = `cat TEST.LOG`
|
||
echo $TEST
|
||
echo ...
|
||
pause
|
||
|
||
echo set exec 2...
|
||
set PS = `ps 2`
|
||
echo $PS
|
||
echo ...
|
||
pause
|
||
|
||
echo ARG0=$0
|
||
echo CWD=$CWD
|
||
|
||
echo for exec 1...
|
||
for f in `ls -c sh*`;echo $f;next
|
||
echo ...
|
||
pause
|
||
|
||
echo for exec 2...
|
||
for f in `ls -c notfound*`;echo $f;next
|
||
echo ...
|
||
pause
|
||
|
||
if [ -z $f ]
|
||
echo f is empty....
|
||
set f = 0
|
||
else
|
||
set f = 30
|
||
fi
|
||
|
||
echo f = $f
|
||
set f = $f + 1
|
||
echo f+1 = $f
|
||
pause
|
||
|
||
echo for file...
|
||
for n in (TEST.LOG); echo TEST.LOG: $n; next
|
||
pause
|
||
|
||
echo for list...
|
||
set LIST = " aa bb ccc d "
|
||
for l in $LIST
|
||
echo l = $l
|
||
next
|
||
|
||
for n in "1 2 3 4"
|
||
echo n1 = $n
|
||
next
|
||
pause
|
||
|
||
echo test if...
|
||
if [ 12 -le 23 ]; echo test if ok;fi
|
||
if [ 12 -ne 23 ] and [ 23 -ge 12 ]; echo test and ok;fi
|
||
if [ abc .< abd ];echo str test 1 ok;else;echo str test 1 ko;fi
|
||
if [ abc >= abd ];echo str test 2 ko;else;echo str test 2 ok;fi
|
||
pause
|
||
|
||
echo test integer...
|
||
set k = -4
|
||
echo k = $k
|
||
set k = $k + 5
|
||
echo k = $k
|
||
set k = -1 + 22
|
||
echo k = $k
|
||
set k = -1 - 2
|
||
echo k = $k
|
||
echo "..."
|
||
pause
|
||
|
||
echo pid=$$,argc = $#, a0=$0, a1=$1, a2=$2
|
||
if [ -z ];echo z test true;else;echo z test failed;fi
|
||
if [ -n $0 ];echo n test true;else;echo n test failed;fi
|
||
|
||
if [ -f $0 ]
|
||
echo "file $0 exists"
|
||
else
|
||
echo "-f $0 test failed"
|
||
fi
|
||
|
||
if ![ -e nothing ];echo file/dir nothing does not exist;else;echo "-e test failed";fi
|
||
if [ -d /sys ];echo directory sys exists;else;echo "-d test failed";fi
|
||
if [ 123 -gt 45 ];echo numeric test 1 ok;else;echo numeric test 1 ko;fi
|
||
if [ 12 -lt 45 ];echo numeric test 2 ok;else;echo numeric test 2 ko;fi
|
||
if [ 999 -eq 999 ];echo numeric test 3 ok;else;echo numeric test 3 ko;fi
|
||
|
||
echo loop.....
|
||
set cnt = 1
|
||
while [ $cnt -lt 5 ]
|
||
echo loop $cnt
|
||
if [ $cnt -eq 3 ]
|
||
echo 3!
|
||
else
|
||
echo .
|
||
fi
|
||
set cnt = $cnt + 1
|
||
loop
|
||
|
||
if [ $cnt -eq 5 ]
|
||
echo if1 = true
|
||
if [ $cnt -lt 4 ]
|
||
echo if2 = true
|
||
else
|
||
echo if2 = false
|
||
fi
|
||
else
|
||
echo if1 = false
|
||
fi
|
||
|
||
echo end of test
|
||
MAN
|
||
TEXT root/shtest/sh1
|