Shellscript
cotrTypesBoolFalse
Bash Boolean False
# Bash represents false as 0.
cotrVarString
Bash Create String Variable
# Assign a string value:${1:myString}=${2:'myValue'}
cotrVar
Bash Variable
${1:myVar}=${2:value}
cotrIf
Bash If Statement
if [ ${1:condition} ]; then ${2:// Your code here}fi
cotrTypeCompare
Bash Type Comparison
# Bash doesn't have direct type comparison, but you can use file or grep for basic checks.
cotrStructure
Bash Project Structure (High-Level)
# Recommended High-Level Bash Project Structure:
# - bin/# - Contains executable scripts.# - lib/# - Contains reusable functions and libraries.# - src/# - Contains source code for scripts.# - test/# - Contains unit tests.
# Note:# - This is a basic structure; adjust based on project complexity and preferences.
cotrStructureFeatures
Bash Project Structure (Feature/Module)
# Organize source code by feature or module within src/:
# - src/# - rendering/# - Contains scripts for rendering features.# - physics/# - Contains scripts for physics features.# - networking/# - Contains scripts for networking features.# - ... (Organize by feature or module)
# Note:# - This approach promotes modularity and is suitable for larger projects.
cotrTypeConvert
Bash Type Conversion
# Bash is dynamically typed, so explicit conversion is often not needed.# However, you can use tools like awk or bc for specific conversions.
cotrTypes
Bash Types
# Bash is dynamically typed, but common data types include:- string: Textual data- integer: Numeric data (whole numbers)- float: Numeric data (decimals)- array: Ordered collection of values- associative array: Key-value pairs
cotrVarStatic
Bash Static Variable
# Bash doesn't have static variables in the same way as some other languages.
cotrInfo
Bash Info
Typing: Dynamically typedParadigm: ImperativeCompilation: InterpretedConcurrency: No
cotrConst
Bash Constant
# Bash uses readonly variables for constants:readonly ${1:myConst}=${2:value}
cotrFuncArrow
Bash Arrow Function
# Bash doesn't have arrow functions.
cotrTypesBool
Bash Boolean Type
# Bash uses 0 for false and non-zero values for true.
cotrCommentMulti
Bash Multi-Line Comment
: <<'END'${1:Your comment here}${2:Your comment here}${3:Your comment here}END
cotrFunc
Bash Function
${2:myFunction}() { ${3:// Your code here}}
cotrOperators
Bash Mathematical Operators
# Bash Mathematical Operators:- Addition: +- Subtraction: -- Multiplication: *- Division: /- Modulus (Remainder): %- Exponentiation: **- Increment: ((var++)) or ((var+=1))- Decrement: ((var--)) or ((var-=1))- Assignment: =- Addition assignment: +=- Subtraction assignment: -=- Multiplication assignment: *=- Division assignment: /=- Modulus assignment: %=- Exponentiation assignment: **=
cotrRead
Bash Read Input
read -p '${1:Prompt: }' ${2:varName}
cotrTypeCheck
Bash Type Check
# Bash is dynamically typed, but you can use file or grep for basic checks:file ${1:variable} | grep -q '${2:type}'
cotrTypesInt
Bash Integer Type
# Bash treats integers as numeric values without decimals.
cotrPrint
Bash Print
echo ${1:'Your message here'}
cotrFuncLambda
Bash Lambda
# Bash doesn't have lambda functions.
cotrTypesDynamic
Bash Dynamic Type
# Bash is dynamically typed; variables can hold different types of values.
cotrTypesList
Bash List Type
# Bash uses arrays for lists:myList=(item1 item2 item3)
cotrVarBool
Bash Create Boolean Variable
# Bash uses 0 for false and non-zero values for true:${1:myBoolean}=${2:0}
cotrIfElse
Bash If Else Statement
if [ ${1:condition} ]; then ${2:// Your code here}else ${3:// Your code here}fi
cotrConcat
Bash Concatenate Strings
# Bash uses string juxtaposition for concatenation:${1:var1}${2:var2}
cotrFuncArgsNamed
Bash Function Named Args
# Bash doesn't directly support named arguments, but you can simulate them using associative arrays or options parsing.
cotrGenList
Bash Generate List
# Bash doesn't have built-in list generation, but you can use loops or command substitution:${1:myList}=( $(for i in {1..${2:10}}; do echo item$i; done) )
cotrNotEqual
Bash Not Equal To
# Bash uses '!=' for string inequality and '-ne' for numeric inequality:[ ${1:var1} != ${2:var2} ]
cotrSwitch
Bash Switch Statement
case ${1:variable} in ${2:pattern1}) ${3:// Your code here} ;; ${4:pattern2}) ${5:// Your code here} ;; *) ${6:// Your code here} ;;esac
cotrOperatorsBool
Bash Boolean Operators
# Bash Boolean Operators:- Logical AND: &&- Logical OR: ||- Logical NOT: !- Equality: ==- Inequality: !=- Greater than: -gt- Less than: -lt- Greater than or equal to: -ge- Less than or equal to: -le
cotrThrow
Bash Throw Exception
# Bash doesn't have exceptions, but you can exit with an error message:echo "Error: ${1:Your message here}" >&2; exit 1
cotrVarNum
Bash Create Number Variable
# Assign a numeric value:${1:myNumber}=${2:10}
cotrVarMap
Bash Create Map Variable
# Create an associative array (map):declare -A ${1:myMap}${1:myMap}[${2:key1}]=${3:value1}${1:myMap}[${4:key2}]=${5:value2}
cotrVarStringMulti
Bash Create Multi-Line String Variable
# Use a here document for multi-line strings:${1:myString}<<EOF${2:Line 1}${3:Line 2}${4:Line 3}EOF
cotrVarTyped
Bash Create Typed Variable
# Bash is dynamically typed, so variables don't have explicit types.
cotrShebang
Bash Shebang
#!/bin/bash
cotrTryCatch
Bash Try Catch
# Bash doesn't have try/catch, but you can use set -e and trap ERR:set -e; trap 'echo "Error: ${1:Your message here}" >&2; exit 1' ERR; ${2:// Your code here}
cotrTypesString
Bash String Type
# Bash represents strings as sequences of characters.
cotrVarDate
Bash Create Date Variable
# Bash doesn't have a dedicated date type, but you can store date strings:${1:myDate}=\$(date)
cotrVarList
Bash Create List Variable
# Create an array (list):${1:myList}=( ${2:item1} ${3:item2} ${4:item3} )
cotrGenMap
Bash Generate Map
# Bash doesn't have built-in map generation, but you can use associative arrays:declare -A ${1:myMap}; for i in {1..${2:10}}; do myMap[key$i]=value$i; done
cotrPrintMulti
Bash Print Multi
# Use echo with -e for multi-line output:echo -e "${1:Line 1}\n${2:Line 2}\n${3:Line 3}"
cotrTypesMap
Bash Map Type
# Bash uses associative arrays for maps:declare -A myMap; myMap[key1]=value1; myMap[key2]=value2
cotrFuncArgs
Bash Function Args
${2:myFunction}() { local ${3:arg1}=${4:\$1} local ${5:arg2}=${6:\$2} ${7:// Your code here}}
cotrNow
Bash Date Now
# Get the current date and time:now=$(date)
cotrVarNullable
Bash Create Nullable Variable
# Bash doesn't have null, but you can use an empty string or a special value:${1:myVar}=${2:''}
cotrVarSyntax
Bash Variable Declaration Syntax
# Bash Variable Declaration Syntax:
# - varName=value: Assigns a value to a variable.# - declare varName: Declares a variable without assigning a value.# - readonly varName=value: Creates a read-only variable (constant).
cotrComment
Bash Comment
# ${1:Your comment here}
cotrEntry
Bash Entry Point
# Bash scripts typically start with the shebang line:#!/bin/bash
cotrFuncAnon
Bash Anonymous Function
# Bash doesn't have true anonymous functions, but you can use function expressions:${1:myFunction}() { ${2:// Your code here} }
cotrCase
Bash Case Statement
case ${1:variable} in ${2:pattern1}) ${3:// Your code here} ;; ${4:pattern2}) ${5:// Your code here} ;; *) ${6:// Your code here} ;;esac
cotrStructureFiles
Bash Project Structure (File Type)
# Organize source code by file type within src/:
# - src/# - utils/# - Contains utility functions.# - data/# - Contains data processing scripts.# - tasks/# - Contains scripts for specific tasks.# - ... (Organize by file type)
# Note:# - This approach can be helpful for smaller projects or specific use cases.
cotrTernary
Bash Ternary Operator
# Bash doesn't have a ternary operator, but you can use an if statement:${1:condition} && ${2:trueValue} || ${3:falseValue}
cotrTypesDate
Bash Date Type
# Bash doesn't have a dedicated date type, but you can use the 'date' command for date manipulation.
cotrTypesNum
Bash Number Type
# Bash treats numbers as either integers or floating-point values.
cotrWhileLoop
Bash While Loop
while [ ${1:condition} ]; do ${2:// Your code here}done
cotrFuncSyntax
Bash Function Syntax
# Bash Function Syntax:function ${1:functionName} { ${2:// Your code here}}
cotrTypesBoolTrue
Bash Boolean True
# Bash represents true as any non-zero value.
cotrInterpolate
Bash Interpolate String
# Bash uses double quotes for variable interpolation:echo "Hello, ${1:name}!"
cotrTypesNull
Bash Null Type
# Bash doesn't have a dedicated null type, but you can use an empty string or a special value like 'null' to represent null.
cotrForLoop
Bash For Loop
for ${1:i} in ${2:list}; do ${3:// Your code here}done
cotrEqual
Bash Equal To
# Bash uses '==' for string equality and '-eq' for numeric equality:[ ${1:var1} == ${2:var2} ]
cotrForIn
Bash For…In Loop
for ${1:item} in ${2:list}; do ${3:// Your code here}done