diff --git a/2011/fredriksson/.gitignore b/2011/fredriksson/.gitignore index 541280740..6a4c5f542 100644 --- a/2011/fredriksson/.gitignore +++ b/2011/fredriksson/.gitignore @@ -5,6 +5,7 @@ ag.c *.dSYM fredriksson fredriksson.orig +fredriksson.txt indent indent.c indent.o diff --git a/2011/fredriksson/try.sh b/2011/fredriksson/try.sh index 99e1e8154..c3f37edd5 100755 --- a/2011/fredriksson/try.sh +++ b/2011/fredriksson/try.sh @@ -15,17 +15,25 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear +# remove temporary file +rm -f fredriksson.txt -echo "$ ./fredriksson -k3 cat < fredriksson.c" 1>&2 -read -r -n 1 -p "Press any key to have the program show its source code: " +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 own code (space = next page, q = quit): " +echo 1>&2 +./fredriksson -k3 cat < fredriksson.c | tee fredriksson.txt | less -rEXF 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 -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 -./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 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: " echo 1>&2 ./fredriksson -ck0 [0-9] < ag.c +echo 1>&2 -echo "Trying to set unlimited stack space for this process..." 1>&2 -ulimit -s unlimited 2>/dev/null -if [[ "$?" -ne 0 ]]; then - echo "...couldn't set unlimited stack space, will skip command." 1>&2 +if ! ulimit -s unlimited 2>/dev/null; then + echo "Couldn't set unlimited stack space, skipping next command." 1>&2 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 fi