Skip to main content
  1. Take a glance/

Lumesh vs Bash Syntax Comparison

756 words·4 mins
Table of Contents

watch ppt demo
#

  1. Basic Concept Comparison

ConceptBash SyntaxLumesh SyntaxDescription
Interpreter Declaration#!/bin/bash#!/usr/bin/env lumeshLumesh recommends using the env method to call
Comment# comment content# comment contentSame as Bash
Line Continuation\\Same as Bash, but no continuation character needed inside strings
  1. Variable Operation Comparison

OperationBash SyntaxLumesh SyntaxDescription
Variable Declarationvar=valuelet var = valueSpaces are optional; must declare in strict mode
Variable Reference$var or ${var}$var or directly var$ is optional; must use $ in strict mode
Multiple Variable DeclarationNot supportedlet a, b = 1, 2
Delete Variableunset vardel var
Lazy AssignmentNot supportedx := 2 + 3
Type CheckNot supportedtype var == "Integer"
  1. Data Type Comparison

TypeBash HandlingLumesh SyntaxDescription
Integerdeclare -i var=10let var = 10Automatically assigns type
FloatNot supportedlet var = 10.0
Stringstr="hello"let str = "hello"
Arrayarr=(1 2 3)let arr = [1, 2, 3] or 1...<3
Dictionarydeclare -A dict=([k]=v)let dict = {k: v}
Range{1..10}1..10 or 1..<10Basic data type, can participate in calculations
File SizeString200MBasic data type, can participate in calculations
TimeStringFs.parse('2025-10-1')Basic data type, can participate in calculations
  1. Operator Comparison

OperatorBash SyntaxLumesh SyntaxDescription
Arithmetic$((a + b))a + bDirect calculation
String Concatenation"$a$b"a + b or format("a={}",a)format is an alias for String.format
Equality Check[ "$a" == "$b" ]a == b or a ~= bCross-type comparison with ~=
Inclusion Check[[ "str" =~ "pattern" ]]str ~: 'pattern'Inclusion operation can be used for arrays, ranges, dictionaries, and strings
Regex Match[[ "str" =~ "regex" ]]str ~~ 'regex'Has regex library available
  1. Control Flow Comparison

StructureBash SyntaxLumesh SyntaxDescription
if Statementif [ cond ]; then ... fiif cond {...} else {...}
for Loopfor i in {1..3}; do ... donefor i in 1..3 {...}
while Loopwhile [ cond ]; do ...while cond {...}
case Statementcase $var in ... esacmatch var {...}Match statement
repeat LoopNo direct equivalentrepeat 10 {...}Repeat loop, an alias for List.map
each LoopNo direct equivalenteach {} [1..3]An alias for List.map
  1. Function Comparison

FeatureBash SyntaxLumesh SyntaxDescription
Function Definitionfunc() { cmds; }fn func() {...}
Anonymous FunctionNonelet f = (x,y) -> x + yLambda expression
Function Parametersfunc() { $1,$2... }fn func(a,b) { a,b...}Parameter list
Default ParametersNot supportedfn f(a=1) {...}Default parameters
Rest Parameters"$@"fn f(*args) {...}Collects rest parameters
Function Callfunc a1func(a1) or func! a1
Higher-order FunctionNot directly supportedfuncA(funcB)Function as a parameter
ScopeOnly supports global scopeFunctions have isolated scope
  1. System Command Comparison

OperationBash SyntaxLumesh SyntaxDescription
Command Executioncmdcmd
Background Runcmd &cmd &
Close Outputcmd >/dev/nullcmd &-
Close Errorcmd 2>/dev/nullcmd &?
Pipe`cmd1cmd2``cmd1
Redirect Appendcmd >> filecmd >> fileSame as Bash
Redirect Overwritecmd > filecmd >! file
  1. Advanced Feature Comparison

FeatureBash SupportLumesh SupportDescription
Implicit Type ConversionNoAutomatically converts numbers and strings
Operator OverloadingNoSupports various types of addition, subtraction, multiplication, and division
Matrix OperationsNoSupports matrix multiplication
Error MessagesRoughDetailedWill provide line numbers, context, and error types
Error HandlingOnly $? status code detectionSupports exception capture, ignore, print, etc.More convenient exception handling mechanism
Interactive ModeSupportedSyntax highlighting, auto-completion, AI assistance, key bindingsEnhanced REPL interactive mode
Built-in LibsNoBuilt-in many useful functionsSee Libs
Structured PipelineNoSupports `Intowhere
  1. Migration Suggestions

  1. Variable Declaration: Keep var=value as is; in strict mode, change the first declaration to let var = value.

  2. Conditional Judgment: Change from [ "$a" == "$b" ] to a == b or $a == $b.

  3. Loop Statements: Change from for i in {1..10} to for i in 1..10.

  4. Function Definition: Change from func() {...} to fn func() {...}.

  5. Error Handling: Keep cmd || fallback as is or change to cmd ?: fallback.

  6. Notes


  1. Lumesh's array indexing starts from 0 (same as Bash).

  2. The range expression a..<b does not include b, while a..b includes b.

  3. Function calls require () or ! suffix.

  4. In strict mode, the $ prefix must be used to reference variables.

  5. Operator precedence differs from Bash.

  6. Learning Resources


  1. Official Documentation: Lumesh Syntax Manual
  2. Interactive Tutorial: Run lumesh to enter REPL mode for practice.

Related