Improve and fix 2011/fredriksson/try.sh
The script now writes the output to a file (via tee(1)) and uses diff -s on the file and fredriksson.c. It also fixes a problem where if one were to hit space after the prompt (lines would be merged) rather than enter/return. Fixed shellcheck warning (no need to ignore it).
This commit is contained in:
1 parent
36ea689cea
commit
6cb855f95c
2 files changed
+23
-11
No files matched your search
@@ -5,6 +5,7 @@ ag.c
|
|||||||
*.dSYM
|
*.dSYM
|
||||||
fredriksson
|
fredriksson
|
||||||
fredriksson.orig
|
fredriksson.orig
|
||||||
|
fredriksson.txt
|
||||||
indent
|
indent
|
||||||
indent.c
|
indent.c
|
||||||
indent.o
|
indent.o
|
||||||
|
|||||||
+22
-11
@@ -15,17 +15,25 @@ make CC="$CC" all >/dev/null || exit 1
|
|||||||
# clear screen after compilation so that only the entry is shown
|
# clear screen after compilation so that only the entry is shown
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
# remove temporary file
|
||||||
|
rm -f fredriksson.txt
|
||||||
|
|
||||||
echo "$ ./fredriksson -k3 cat < fredriksson.c" 1>&2
|
echo "$ ./fredriksson -k3 cat < fredriksson.c | tee fredriksson.txt" 1>&2
|
||||||
read -r -n 1 -p "Press any key to have the program show its source code: "
|
read -r -n 1 -p "Press any key to have the program show its own code (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
|
./fredriksson -k3 cat < fredriksson.c | tee fredriksson.txt | less -rEXF
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
./fredriksson -k3 cat < fredriksson.c
|
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
read -r -n 1 -p "Press any key to run: diff -s fredriksson.c fredriksson.txt: "
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
read -r -n 1 -p "Press any key to run: ./fredriksson -k1 -i POOT < /etc/group: "
|
diff -s fredriksson.c fredriksson.txt
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
./fredriksson -k1 -i POOT < /etc/group
|
rm -f fredriksson.txt
|
||||||
|
|
||||||
|
echo "$ ./fredriksson -k1 -i POOT < /etc/group" 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
|
./fredriksson -k1 -i POOT < /etc/group | less -rEXF
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./fredriksson -ck0 [0-9] < fredriksson.c: "
|
read -r -n 1 -p "Press any key to run: ./fredriksson -ck0 [0-9] < fredriksson.c: "
|
||||||
@@ -36,12 +44,15 @@ echo 1>&2
|
|||||||
read -r -n 1 -p "Press any key to run: ./fredriksson -ck0 [0-9] < ag.c: "
|
read -r -n 1 -p "Press any key to run: ./fredriksson -ck0 [0-9] < ag.c: "
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
./fredriksson -ck0 [0-9] < ag.c
|
./fredriksson -ck0 [0-9] < ag.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "Trying to set unlimited stack space for this process..." 1>&2
|
if ! ulimit -s unlimited 2>/dev/null; then
|
||||||
ulimit -s unlimited 2>/dev/null
|
echo "Couldn't set unlimited stack space, skipping next command." 1>&2
|
||||||
if [[ "$?" -ne 0 ]]; then
|
|
||||||
echo "...couldn't set unlimited stack space, will skip command." 1>&2
|
|
||||||
else
|
else
|
||||||
read -r -n 1 -p "Press any key to run: ./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words: "
|
echo "Set unlimited stack space, continuing." 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
echo "$ ./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words" 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words
|
./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words
|
||||||
fi
|
fi
|
||||||
Reference in new issue
Block a user