yab | yet another Basic for HAIKU
Using a command file for a shell script. - Printable Version

+- yab | yet another Basic for HAIKU (https://yab.orgfree.com/forum)
+-- Forum: General discussion (https://yab.orgfree.com/forum/forumdisplay.php?fid=8)
+--- Forum: yoshi (https://yab.orgfree.com/forum/forumdisplay.php?fid=12)
+--- Thread: Using a command file for a shell script. (/showthread.php?tid=67)



Using a command file for a shell script. - bbjimmy - 05-01-2016

Since yoshi does a good job of ignoring lines that do not have yoshi commands, one can use the same file for a bash scrip. copy the foollowing and save the file as "viewtext" then set the executable bits. This will display the Yoshi command file in a text display, then chose to run yoshi Default or not depending on the cancel button.

Code:
#!sh
test="NO"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
yoshi viewtext > /tmp/yoshout

while IFS='' read -r line || [[ -n "$line" ]]; do
    var1=$(echo $line | cut -f1 -d=)
    var2=$(echo $line | cut -f2 -d=)
    eval $var1='$var2'
done < "/tmp/yoshout"

if [ "$test" == "yes" ]; then
# skip over yoshi commands


*.title = Welcome to Yoshi
#*.look = no-border
#*.look = Bordered
#*.look = Floating
#*.look = Modal
#*.x = 50
#*.y = 260
*.bgcolor = 255,232,181

img1.type = image
img1.path = /boot/home/config/settings/fatelk/yoshi/blank.gif
img1.maxwidth = 8
img1.maxheight = 8

img3.type = image
img3.path = /boot/home/config/settings/fatelk/yoshi/grey.png
img3.maxwidth = 500
img3.maxheight = 2
img.border = 5

img.type = image
img.path = /boot/home/config/settings/fatelk/yoshi/blank.gif
img.maxwidth = 8
img.maxheight = 8

txt.type = text
txt.txtfile = /boot/home/config/settings/fatelk/yoshi/commands/Yoshi
txt.lines = 15
txt.scrollbar = 1
txt.bg = white
#txt.align = center
echo;
fi

if [ $cancel -eq 1 ]
then
exit 1
fi
yoshi



RE: Using a command file for a shell script. - clasqm - 05-02-2016

Interesting. You're relying on the fact that bash is a fairly primitive interpreter that works strictly line-by-line, unlike, say, the yab interpreter, which checks the entire program for errors before it is run. This opens up a lot of possibilities. I must think about this.


Free Web Hosting