-
This computer is a Windows 11 system with Cygwin Bash installed.
-
The
run_shell_commandtool that you use to execute shell commands usescmd.exe, because this is a Windows system, but you prefer to execute shell commands using Cygwin Bash. The next item explains how you will use Bash instead ofcmd.exe. -
When you need to execute a shell command, always execute it by running command
bash gemini_tmp.sh, wheregemini_tmp.shis a Bash shell script written by you that contains the Bash command(s) you need to execute. Additional details:-
Even though tool
run_shell_commandusescmd.exeto execute commands, the command you provide to the tool explicitly invokesbash, socmd.exeis simply used to "trampoline" into Bash. -
Most Linux commands are available in the Bash shell, such as
cd,ls,grep,find,wc,cp,mv,rm,sed,awk,sha1sum,sha256sum, and many others. -
The last line of script
gemini_tmp.shshould be/bin/rm "$0", which deletes the script so you don't have to delete it. -
If you need to execute the
rmcommand using Bash, always execute it using its full pathname (/bin/rm). This avoids a confirmation prompt displayed by my personalrmwrapper script.
-
-
When giving pathnames to commands executed by the Bash shell, always use forward slashes as the directory separator, even though this is a Windows system.
-
Absolute pathnames in Bash commands should start with a Windows drive letter and a forward slash. For example:
C:/path/to/file.
-
If you need to execute Python code, Python version 3.13.3 is available by running command
python C:/temp/gemini.py, whereC:/temp/gemini.pyis a Python script written by you and containing the Pythond command(s) you need to execute. -
As with Bash commands, you do not need to delete
C:/temp/gemini.pyafter executing it, but the next time you write Python code into that file, you must overwrite all of its contents with the new commands. -
If the Python code in file
C:/temp/gemini.pyhas pathnames embedded in the code, the pathnames should follow the same rules as above for pathnames in Bash commands.
-
If you need to execute MinGW/MSYS2 applications, first modify environment variable
PATHto have folder/cygdrive/c/apps/msys64/mingw64/binat the front.- Do this by prefixing the command with a temporary assignment to
PATH, as follows:PATH="/cygdrive/c/apps/msys64/mingw64/bin:$PATH" COMMAND ARG1 ARG2 .... Do not make persistent changes toPATH.
- Do this by prefixing the command with a temporary assignment to
-
New files that you create should use Unix-style newlines (a single line-feed character) instead of Windows-style newlines (a carriage return and line-feed pair).
-
But when you modify existing files, you must use the same newline convention as the rest of the file.
-
Never convert the entirety of a existing file from one newline convention to the other.
-
Keep lines of source code less than 100 columns wide.
-
Avoid single-character identfiers. In loops, use identifiers such as
index,counter, andloopCountinstead of single-character identifiers. -
When adding imports to Go code, you must add the imports along with the code that references those imports, otherwise the intelligent editor in VSCode will remove the unreferenced imports.
-
All scripts that you create must be Bash scripts. Never write a Windows batch script unless explicitly instructed to do so.
-
In Bash scripts, all variable names must be fully uppercase. For example:
COUNT=0,FILENAME="file.txt", etc. -
In Bash scripts, local variables in Bash functions must start with a leading underscore to avoid accidentally shadowing global variables. For example:
local _COUNTER=0. -
In Bash scripts use the new test command (
[[ ... ]]) instead of the traditional test command ([ ... ]). Be careful to use the proper argument syntax for the new test command, such as using&&instead of-ato indicate Boolean AND operations, and||instead of-oto indicate Boolean OR operations, as well as the other syntax differences required by the test command.
-
Always write well-commented source code.
-
Comments should be complete sentences that start with a capital letter and end with a period.
-
Sentences in comments should be separated by two spaces for readability.
-
Put comments on the line above the code they reference, rather than on the same line.
-
Comments can appear on the same line as code only if the comment is very short. In this case, the comment is exempt from the rule that it must be a complete sentence.
-
Comments should explain the purpose and rationale of the code and not simply restate what the code does.
-
Do not talk to the user through comments.
-
Aim to have nearly the same number of lines of comments as lines of code. This is a guideline not a hard and fast rule.
-
Do not comment trivial code, such as Python and Go
importstatements or the initialization of local variables, unless the comment explains something important for a developer to understand.
-
When running commands to build executables, always make the executable name end with
.exe, because this is a Windows system. -
When building a graphical Go application that uses the Fyne GUI toolkit, always modify environment variable
PATHto use MinGW tools as described above in section Executing MinGW/MSYS2 Applications. -
When building a graphical Go application, always pass switch
-ldflags "-H windowsgui"so that the application does not create a console window when it is launched. -
When using GCC to build a graphical application, always pass switch
-Wl,--subsystem,windowsso that the application does not create a console window when it is launched.
-
You have no way to see the GUI of a graphical application, which makes it difficult for you to test graphical applications.
-
Thus, you must test graphical applications as follows:
-
Tell the user to test the graphical application's GUI before you launch it.
-
Launch the graphical application, and wait for it to terminate. If it produces any error messages on standard error or standard output, you will see them just as you see the output of a non-graphical application.
-
After the app terminates, ask the user for their testing feedback, then wait for the user to enter their feedback.
-
Take the appropriate actions based on the user's feedback and any output produced by the application.
-
- When you need to perform mathematical calculations while thinking or planning, always use Python to do the math. This guarantees mathematical correctness in your reasoning and responses.