improve the try.sh and try.alt.sh examples
We added more informative "XXX - ... - XXX" messages and improve the 2nd invocation example.
This commit is contained in:
1 parent
40b572cd14
commit
d50756f2e9
2 files changed
+72
-43
No files matched your search
+36
-22
@@ -2,9 +2,9 @@
|
||||
#
|
||||
# try.alt.sh - demonstrate alternate YYYY/XXX <<=== The IOCCC Judges will replace this line
|
||||
|
||||
# XXX - try.alt.sh example version: 28.1.0 2024-07-05 - XXX
|
||||
# XXX - NOTE: please remove all "XXX - ... - XXX" lines, including this one - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - NOTE: please remove the XXX lines in this file, including this one - XXX
|
||||
# XXX - try.alt.sh example version: 28.1.1 2024-07-06 - XXX
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy way.
|
||||
@@ -14,6 +14,7 @@
|
||||
# XXX - If you need other variables you can also set them in whatever way - XXX
|
||||
# XXX - you need; this is a good method, however, in cases where it's OK - XXX
|
||||
# XXX - to let the user redefine it. - XXX
|
||||
# XXX - - XXX
|
||||
[[ -z "$CC" ]] && CC="cc"
|
||||
|
||||
# make sure the program has been built
|
||||
@@ -22,28 +23,35 @@
|
||||
# XXX - if you need to build the alt code for the try.sh script, - XXX
|
||||
# XXX - then change the 'all' to 'all alt' in the below command. - XXX
|
||||
# XXX - Later, if the submission wins, it can be changed to 'everything'. - XXX
|
||||
# XXX - - XXX
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
# clear the screen
|
||||
#
|
||||
clear
|
||||
|
||||
# XXX - Invoke the program in one or more ways - XXX
|
||||
|
||||
# XXX - NOTE: you can include more than one command line and you - XXX
|
||||
# XXX - certainly can include pipelines. - XXX
|
||||
|
||||
# XXX - It is good to use the shell built-in read(1) to - XXX
|
||||
# XXX - let the user know what is about to be done, as - XXX
|
||||
# XXX - shown below, so they can proceed when ready. - XXX
|
||||
|
||||
# XXX - You may modify the command based on your program and you - XXX
|
||||
# XXX - may provide more than one invocation. - XXX
|
||||
|
||||
# XXX - Examples follow. - XXX
|
||||
|
||||
# XXX - if the prompt will not be too long, say no more than 80-100 - XXX
|
||||
# XXX - chars or so: - XXX
|
||||
# XXX - NOTE: You can include more than one command line, including pipes. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - It is good to use the shell built-in read(1) to let the user know - XXX
|
||||
# XXX - what is about to be executed. We suggest a double echo after the - XXX
|
||||
# XXX - use of the shell built-in read(1) to help separate the prompt from - XXX
|
||||
# XXX - any output your code may produce. We also suggest an echo after - XXX
|
||||
# XXX - any execution to help separate any output from the next prompt or - XXX
|
||||
# XXX - from the end of the script. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - We recommend sending echo's (both empty lines and messages) to - XXX
|
||||
# XXX - stderr as this makes it easier to separate script output (stderr) - XXX
|
||||
# XXX - from any stdout of your program. However, do NOT send the shell - XXX
|
||||
# XXX - built-in read(1) to stderr. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - You may modify the command based on your program and you may have - XXX
|
||||
# XXX - more than one invocation. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - Examples follow. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - For more examples, see the try.sh scripts under the 2024 directory. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - Remove/expand sections as needed: these are just examples. - XXX
|
||||
|
||||
# try the program
|
||||
#
|
||||
@@ -53,12 +61,18 @@ echo 1>&2
|
||||
./prog
|
||||
echo 1>&2
|
||||
|
||||
# XXX - Remove/expand sections as needed: these are just examples - XXX
|
||||
|
||||
# try the program with args
|
||||
#
|
||||
read -r -n 1 -p "Press any key to run: ./prog some long command line < data: "
|
||||
# XXX - Notice that the echo below is also sent to stderr, and there is an - XXX
|
||||
# XXX - empty echo written to stderr before the shell built-in read(1) call - XXX
|
||||
# XXX - - XXX
|
||||
echo 'Let us try another example. Observe the line count of output and the last line of data!' 1>&2
|
||||
echo 1>&2
|
||||
read -r -n 1 -p "Press any key to run: date | ./prog some command line | LANG=C sort > data: "
|
||||
echo 1>&2
|
||||
echo 1>&2
|
||||
./prog some long command line < data
|
||||
rm -f data
|
||||
date | ./prog some command line | LANG=C sort > data
|
||||
wc -l < data
|
||||
tail -n 1 data
|
||||
echo 1>&2
|
||||
+36
-21
@@ -2,9 +2,9 @@
|
||||
#
|
||||
# try.sh - demonstrate YYYY/XXX <<=== The IOCCC Judges will replace this line
|
||||
|
||||
# XXX - try.sh example version: 28.1.0 2024-07-05 - XXX
|
||||
# XXX - NOTE: please remove all "XXX - ... - XXX" lines, including this one - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - NOTE: please remove the XXX lines in this file, including this one - XXX
|
||||
# XXX - try.sh example version: 28.1.1 2024-07-06 - XXX
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy way.
|
||||
@@ -14,6 +14,7 @@
|
||||
# XXX - If you need other variables you can also set them in whatever way - XXX
|
||||
# XXX - you need; this is a good method, however, in cases where it's OK - XXX
|
||||
# XXX - to let the user redefine it. - XXX
|
||||
# XXX - - XXX
|
||||
[[ -z "$CC" ]] && CC="cc"
|
||||
|
||||
# make sure the program has been built
|
||||
@@ -22,27 +23,35 @@
|
||||
# XXX - if you need to build the alt code for the try.sh script, - XXX
|
||||
# XXX - then change the 'all' to 'all alt' in the below command. - XXX
|
||||
# XXX - Later, if the submission wins, it can be changed to 'everything'. - XXX
|
||||
# XXX - - XXX
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
# clear the screen
|
||||
#
|
||||
clear
|
||||
zsh:1: command not found: :w
|
||||
|
||||
# XXX - NOTE: you can include more than one command line and you - XXX
|
||||
# XXX - certainly can include pipelines. - XXX
|
||||
|
||||
# XXX - It is good to use the shell built-in read(1) to - XXX
|
||||
# XXX - let the user know what is about to be done, as - XXX
|
||||
# XXX - shown below, so they can proceed when ready. - XXX
|
||||
|
||||
# XXX - You may modify the command based on your program and you - XXX
|
||||
# XXX - may provide more than one invocation. - XXX
|
||||
|
||||
# XXX - Examples follow. - XXX
|
||||
|
||||
# XXX - if the prompt will not be too long, say no more than 80-100 - XXX
|
||||
# XXX - chars or so: - XXX
|
||||
# XXX - NOTE: You can include more than one command line, including pipes. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - It is good to use the shell built-in read(1) to let the user know - XXX
|
||||
# XXX - what is about to be executed. We suggest a double echo after the - XXX
|
||||
# XXX - use of the shell built-in read(1) to help separate the prompt from - XXX
|
||||
# XXX - any output your code may produce. We also suggest an echo after - XXX
|
||||
# XXX - any execution to help separate any output from the next prompt or - XXX
|
||||
# XXX - from the end of the script. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - We recommend sending echo's (both empty lines and messages) to - XXX
|
||||
# XXX - stderr as this makes it easier to separate script output (stderr) - XXX
|
||||
# XXX - from any stdout of your program. However, do NOT send the shell - XXX
|
||||
# XXX - built-in read(1) to stderr. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - You may modify the command based on your program and you may have - XXX
|
||||
# XXX - more than one invocation. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - Examples follow. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - For more examples, see the try.sh scripts under the 2024 directory. - XXX
|
||||
# XXX - - XXX
|
||||
# XXX - Remove/expand sections as needed: these are just examples. - XXX
|
||||
|
||||
# try the program
|
||||
#
|
||||
@@ -52,12 +61,18 @@ echo 1>&2
|
||||
./prog
|
||||
echo 1>&2
|
||||
|
||||
# XXX - Remove or expand sections as needed. - XXX
|
||||
|
||||
# try the program with args
|
||||
#
|
||||
read -r -n 1 -p "Press any key to run: ./prog some long command line < data: "
|
||||
# XXX - Notice that the echo below is also sent to stderr, and there is an - XXX
|
||||
# XXX - empty echo written to stderr before the shell built-in read(1) call - XXX
|
||||
# XXX - - XXX
|
||||
echo 'Let us try another example. Observe the line count of output and the last line of data!' 1>&2
|
||||
echo 1>&2
|
||||
read -r -n 1 -p "Press any key to run: date | ./prog some command line | LANG=C sort > data: "
|
||||
echo 1>&2
|
||||
echo 1>&2
|
||||
./prog some long command line < data
|
||||
rm -f data
|
||||
date | ./prog some command line | LANG=C sort > data
|
||||
wc -l < data
|
||||
tail -n 1 data
|
||||
echo 1>&2
|
||||
Reference in new issue
Block a user