2021-04-05 - SpaceLaunch space program ------------------------------------------------------------------- A while ago i was playing around with the Spacelaunch program on this ~team server. The sl command is a really nice little program which allows users to shoot rockets up over the terminal screen. The rockets consist of small rocket-sections made by all the other users on the server. And users are invited of course to also draw their own section. This neat program is made by cmccabe for the Zaibatsu server, and can be found over here [0]. It is apparently based on an old 'steam locomotive' Unix prank (which i assumed is called after mistyping the ls command) Anyhow, of course i started designing the most beautiful rocket section i could think of: ====================== | # # ## ### | | ## # # # # # | | # ## # # ### | | # # ## # | \_________________ / \ ~TEAM / | o o o o o o o| ( TO GOPHER ) \ SPACE / `----------` ==| [ NN ] |== ==|====[ OO ]====+== ==| [ PP ] |== /~~~~~~~~\ / ____ \ / | | \ ( |(oo)|__hey! ./ |m()m| \. / \ | o o O O O o o| |====================| After drawing this rocket section, i tested my .vroom file with the 'sl -t' command, but unfortunately, it seemed to fail every time :( The program would give a fairly "cryptic" output saying that my file wouldn't pass the requirements: nop:~$./sl.sh -t ========================================================== Testing your .vroom file... FAIL! Your .vroom file does not meet one or more of the following requirements: * Each line in the .vroom file must be exactly 22 characters in length. * The .vroom file may contain no more than 22 lines. ========================================================== I double, tripple and quadruple-checked my .vroom file, but couldn't see why it wouldn't conform to the requirements. It had 22 lines of exactly 22 characters wide. Strangely enough, when shooting up rockets in the air with the 'sl' command, my rocket section passed by occasionally as well. So my rocket section was working, but was reported to fail by the 'sl -t' function. So something strange was happending. To check it out i downloaded the spacelaunch program [0], and found out the whole program was actually a masterfully written bash-script by cmccabe. (I kinda expected a c program or so) I've never really written bash scripts, so i didn't know you could all these things with bash even. So after some figuring out how everything works, i found that the error was caused by a 'read' command, which was throwing away the leading spaces in my .vroom lines. This is apparently default behaviour of the read program. If i input a string with many leading spaces, the spaces get trimmed away by the read program. ============================== nop:~$ read; echo ${REPLY} <- Leading spaces <- Leading spaces ============================= But somehow, this only happened when the 'sl -t' function was run, and not when the 'sl' program was run. Turns out, this was caused by the IFS (Input File Seperator) which was not (un)set for the portion of the script that ran the 'sl -t' function. Normally the IFS is set to or so, but for this script it has to be set to blank '', for everything to function properly. This was done for the function that launched the rocket, but not for the function that checked the rocket. While i was testing this, i added debug lines to the function that tested the .vroom files; VALIDATE_VROOM(). As i found the 'sl -t' output to be rather cryptic earlier, (it didn't say exactly what was wrong with my rocket section), i decided to use my debug lines and add a 'verbose' mode to the function. This way, the 'sl -t' function would give a lot more verbose information on what is wrong with a .vroom file. Which is helpful for people like me... :) So now in the modified program, the output looks like this: nop:~$./sl.sh -t ========================================================== Performing rocket section diagnostics... Analyzing your .vroom file... 01:====================== Width:22 chars. PASS 02:| # # ## ### | Width:22 chars. PASS 03:| ## # # # # # | Width:22 chars. PASS 04:| # ## # # ### | Width:22 chars. PASS 05:| # # ## # | Width:22 chars. PASS 06: \_________________ / Width:22 chars. PASS 07: \ ~TEAM / Width:22 chars. PASS 08: | o o o o o o o| Width:21 chars. FAIL 09: ( TO GOPHER ) Width:22 chars. PASS 10: \ SPACE / Width:22 chars. PASS 11: `----------` Width:22 chars. PASS 12:==| [ NN ] |== Width:22 chars. PASS 13:==|====[ OO ]====+== Width:22 chars. PASS 14:==| [ PP ] |== Width:22 chars. PASS 15: /~~~~~~~~\ Width:22 chars. PASS 16: / ____ \ Width:22 chars. PASS 17: / | | \ Width:22 chars. PASS 18: ( |(oo)|__hey! Width:22 chars. PASS 19: ./ |m()m| \. Width:22 chars. PASS 20:/ \ Width:22 chars. PASS 21:| o o O O O o o| Width:22 chars. PASS 22:|====================| Width:22 chars. PASS ========================================================== Rocket section height: 22 lines. PASS FAIL! Your .vroom file does not meet one or more of the following requirements: * Each line in the .vroom file must be exactly 22 characters in length. * The .vroom file may contain no more than 22 lines. ========================================================== This way, you can see exactly on which line the .vroom file fails (in the above example on line 08, due to a too small width) Hopefully, with the small IFS bug fixed, and the improved diagnostics output, even more rockets will be launched over the console with cmccabe's awesome script. I will forward the modified script to cmccabe for review. I've never modified bash scripts before, so it's very possible i've missed some things when changing the script. The modified sl.sh script can also be found over at [1] for the time being. [0] gopher://zaibatsu.circumlunar.space/1/software/spacelaunch [1] gopher://tilde.team/0/~nop/misc/sl.txt