File: book2ys.sh

package info (click to toggle)
yacas 1.3.6-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 7,176 kB
  • ctags: 3,520
  • sloc: cpp: 13,960; java: 12,602; sh: 11,401; makefile: 552; perl: 517; ansic: 381
file content (46 lines) | stat: -rw-r--r-- 1,086 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

# Convert Yacas books to Yacas code, taking only code examples that don't begin with In> or Out>.
# All other lines become comments unless the -strip option is given.

ourdir=`dirname $0`

if [ x"$1" = x-run ]; then
	shift
	yacas="$1"
	shift
else
	yacas="$ourdir/../src/yacas --rootdir $ourdir/../scripts/"
fi

if [ x"$1" = x-strip ]; then
	shift
	strip="True"
else
	strip="False"
fi

if [ x"$1" = x ]; then
	echo "`basename $0`: extract code from Yacas docs"
	echo "Usage: `basename $0` [-run /path/yacas] [-strip] bookname.chapt [outputname.ys]"
else
if [ x"$2" = x ]; then
	target="$1.ys"
else
	target="$2"
fi

if [ -r "$1" ]; then
	rm -f "$target"
	echo "ToFile(\"$target\") [ Use(\"$ourdir/book2ys.ys\"); StripComments := $strip; Load(\"$1\"); ];" | $yacas -f
	if [ -s "$target" ]; then
		echo "File '$target' was created."
		#perl -e 'while(<>) { s/([%])/\\$1/g; print; }' < "$target" > "$target.tmp"
		#mv "$target.tmp" "$target"
	else
		echo "`basename $0`: Some problem generating file '$target', aborted."
	fi
else
	echo "Error: cannot read input file '$1'."
fi
fi